Skip to content

Commit 90fe178

Browse files
🐛 add missing ddtags to telemetry events (#3873)
1 parent e560b57 commit 90fe178

7 files changed

Lines changed: 23 additions & 8 deletions

File tree

packages/core/src/domain/configuration/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ export {
99
export type { EndpointBuilder, TrackType } from './endpointBuilder'
1010
export { createEndpointBuilder, buildEndpointHost } from './endpointBuilder'
1111
export { computeTransportConfiguration, isIntakeUrl } from './transportConfiguration'
12-
export { buildTags, buildTag, sanitizeTag } from './tags'

packages/core/src/domain/configuration/tags.spec.ts renamed to packages/core/src/domain/tags.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { display } from '../../tools/display'
1+
import { display } from '../tools/display'
22
import type { Configuration } from './configuration'
33
import { buildTag, buildTags, supportUnicodePropertyEscapes, TAG_SIZE_LIMIT } from './tags'
44

packages/core/src/domain/configuration/tags.ts renamed to packages/core/src/domain/tags.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DOCS_ORIGIN, MORE_DETAILS, display } from '../../tools/display'
1+
import { DOCS_ORIGIN, MORE_DETAILS, display } from '../tools/display'
22
import type { Configuration } from './configuration'
33

44
export const TAG_SIZE_LIMIT = 200

packages/core/src/domain/telemetry/telemetry.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,18 @@ describe('telemetry', () => {
234234
expect((await getTelemetryEvents()).length).toBe(1)
235235
})
236236

237+
it('should collect ddtags', async () => {
238+
const { getTelemetryEvents } = startAndSpyTelemetry({
239+
service: 'foo',
240+
env: 'bar',
241+
version: '123',
242+
})
243+
244+
addTelemetryUsage({ feature: 'set-tracking-consent', tracking_consent: 'granted' })
245+
246+
expect((await getTelemetryEvents())[0].ddtags).toEqual('sdk_version:test,env:bar,service:foo,version:123')
247+
})
248+
237249
describe('assemble telemetry hook', () => {
238250
it('should add default telemetry event attributes', async () => {
239251
const { getTelemetryEvents, hooks } = startAndSpyTelemetry()

packages/core/src/domain/telemetry/telemetry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { NO_ERROR_STACK_PRESENT_MESSAGE, isError } from '../error/error'
44
import { toStackTraceString } from '../../tools/stackTrace/handlingStack'
55
import { getExperimentalFeatures } from '../../tools/experimentalFeatures'
66
import type { Configuration } from '../configuration'
7+
import { buildTags } from '../tags'
78
import { INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../intakeSites'
89
import { BufferedObservable, Observable } from '../../tools/observable'
910
import { clocksNow } from '../../tools/utils/timeUtils'
@@ -195,6 +196,7 @@ export function startTelemetryCollection(
195196
connectivity: getConnectivity(),
196197
sdk_setup: __BUILD_ENV__SDK_SETUP__,
197198
}) as TelemetryEvent['telemetry'],
199+
ddtags: buildTags(configuration).join(','),
198200
experimental_features: Array.from(getExperimentalFeatures()),
199201
}
200202

packages/core/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ export {
77
isSampleRate,
88
buildEndpointHost,
99
isIntakeUrl,
10-
buildTags,
11-
buildTag,
12-
sanitizeTag,
1310
} from './domain/configuration'
1411
export * from './domain/intakeSites'
1512
export type { TrackingConsentState } from './domain/trackingConsent'
@@ -164,4 +161,5 @@ export * from './domain/deflate'
164161
export * from './domain/connectivity'
165162
export * from './tools/stackTrace/handlingStack'
166163
export * from './tools/abstractHooks'
164+
export * from './domain/tags'
167165
export { WARN_DOES_NOT_HAVE_ALLOWED_TRACKING_ORIGIN } from './domain/allowedTrackingOrigins'

packages/logs/src/domain/logger.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { ErrorWithCause } from '@datadog/browser-core'
2-
import { display, ErrorHandling, NO_ERROR_STACK_PRESENT_MESSAGE } from '@datadog/browser-core'
3-
import { supportUnicodePropertyEscapes } from '@datadog/browser-core/src/domain/configuration/tags'
2+
import {
3+
display,
4+
ErrorHandling,
5+
NO_ERROR_STACK_PRESENT_MESSAGE,
6+
supportUnicodePropertyEscapes,
7+
} from '@datadog/browser-core'
48
import type { LogsMessage } from './logger'
59
import { HandlerType, Logger, STATUSES } from './logger'
610
import { StatusType } from './logger/isAuthorized'

0 commit comments

Comments
 (0)