Skip to content

Commit

Permalink
Create a "RUM" batch for telemetry events in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Feb 25, 2022
1 parent d935cd9 commit 5f884b7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/logs/src/boot/startLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
initConsoleObservable,
ConsoleApiName,
ErrorSource,
startMonitoringBatch,
} from '@datadog/browser-core'
import { trackNetworkError } from '../domain/trackNetworkError'
import type { Logger, LogsMessage } from '../domain/logger'
Expand All @@ -32,6 +33,12 @@ const LogStatusForApi = {

export function startLogs(configuration: LogsConfiguration, logger: Logger) {
const internalMonitoring = startInternalMonitoring(configuration)
const monitoringBatch = startMonitoringBatch(
configuration,
configuration.rumEndpointBuilder,
configuration.replica?.rumEndpointBuilder
)
internalMonitoring.telemetryEventObservable.subscribe((event) => monitoringBatch.add(event))

const rawErrorObservable = new Observable<RawError>()

Expand Down Expand Up @@ -62,6 +69,20 @@ export function doStartLogs(
view: { name: null, url: null, referrer: null },
})
)
internalMonitoring.setTelemetryContextProvider(() => ({
application: {
id: getRUMInternalContext()?.application_id,
},
session: {
id: sessionManager.findTrackedSession()?.id,
},
view: {
id: (getRUMInternalContext()?.view as Context)?.id,
},
action: {
id: (getRUMInternalContext()?.user_action as Context)?.id,
},
}))

const assemble = buildAssemble(sessionManager, configuration, reportRawError)

Expand Down

0 comments on commit 5f884b7

Please sign in to comment.