Skip to content

Commit

Permalink
✨ add simulation label to events during simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Oct 4, 2022
1 parent b2e7c67 commit 29fda3d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/domain/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { ConsoleApiName } from '../../tools/display'
import { toStackTraceString } from '../../tools/error'
import { assign, combine, jsonStringify, performDraw, includes, startsWith, arrayFrom } from '../../tools/utils'
import type { Configuration } from '../configuration'
import { getExperimentalFeatures, INTAKE_SITE_STAGING, INTAKE_SITE_US1_FED } from '../configuration'
import {
getExperimentalFeatures,
getSimulationLabel,
INTAKE_SITE_STAGING,
INTAKE_SITE_US1_FED,
isSimulationActive,
} from '../configuration'
import type { StackTrace } from '../tracekit'
import { computeStackTrace } from '../tracekit'
import { Observable } from '../../tools/observable'
Expand Down Expand Up @@ -82,7 +88,8 @@ export function startTelemetry(configuration: Configuration): Telemetry {
telemetry: event as any, // https://github.com/microsoft/TypeScript/issues/48457
experimental_features: arrayFrom(getExperimentalFeatures()),
},
contextProvider !== undefined ? contextProvider() : {}
contextProvider !== undefined ? contextProvider() : {},
isSimulationActive() ? { simulation_label: getSimulationLabel() } : {}
)
}

Expand Down
6 changes: 6 additions & 0 deletions packages/logs/src/domain/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
combine,
createEventRateLimiter,
getRelativeTime,
isSimulationActive,
getSimulationLabel,
} from '@datadog/browser-core'
import type { CommonContext } from '../rawLogsEvent.types'
import type { LogsConfiguration } from './configuration'
Expand Down Expand Up @@ -52,6 +54,10 @@ export function startLogsAssembly(
messageContext
)

if (isSimulationActive()) {
log.simulation_label = getSimulationLabel()
}

if (
// Todo: [RUMF-1230] Move this check to the logger collection in the next major release
!isAuthorized(rawLogsEvent.status, HandlerType.http, logger) ||
Expand Down
6 changes: 6 additions & 0 deletions packages/rum-core/src/domain/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
display,
createEventRateLimiter,
canUseEventBridge,
isSimulationActive,
getSimulationLabel,
} from '@datadog/browser-core'
import type { RumEventDomainContext } from '../domainContext.types'
import type {
Expand Down Expand Up @@ -133,6 +135,10 @@ export function startRumAssembly(
const serverRumEvent = combine(rumContext as RumContext & Context, rawRumEvent) as RumEvent & Context
serverRumEvent.context = combine(commonContext.context, customerContext)

if (isSimulationActive()) {
serverRumEvent.context.simulation_label = getSimulationLabel()
}

if (!('has_replay' in serverRumEvent.session)) {
;(serverRumEvent.session as Mutable<RumEvent['session']>).has_replay = commonContext.hasReplay
}
Expand Down

0 comments on commit 29fda3d

Please sign in to comment.