Skip to content

Commit b5d17f9

Browse files
authored
feat: 4/x attribute RUM workflow vitals to origin views (#13764)
## Stack 1. [#13767 — feat: 3/x record RUM workflow execution vitals](#13767) 2. [#13764 — feat: 4/x attribute RUM workflow vitals to origin views](#13764) ## Summary Attributes each `workflow_execution` vital to the native Datadog view where the workflow began. The stateless provider resolves historical RUM context with the workflow start time and adds `origin_view_id` when Datadog returns a view ID. ## Verification - The provider regression test calls `getInternalContext(42)` and observes `origin_view_id: 'view-a'` in the authoritative `DD_RUM.addDurationVital('workflow_execution', ...)` payload. - Manual Cloud console verification recorded for this head confirmed that current and historical timestamps resolve to distinct Datadog views. - Merge blocker: GitHub currently reports this branch conflicts with #13767, so it requires a rebase before merge. Created by Codex Co-authored-by: huang47 <157390+huang47@users.noreply.github.com>
1 parent 25e74da commit b5d17f9

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/platform/telemetry/providers/cloud/DatadogRumTelemetryProvider.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
22

33
import { DatadogRumTelemetryProvider } from './DatadogRumTelemetryProvider'
44

5-
const { addDurationVital } = vi.hoisted(() => ({
6-
addDurationVital: vi.fn()
5+
const { addDurationVital, getInternalContext } = vi.hoisted(() => ({
6+
addDurationVital: vi.fn(),
7+
getInternalContext: vi.fn()
78
}))
89

910
vi.mock('@datadog/browser-rum', () => ({
10-
datadogRum: { addDurationVital }
11+
datadogRum: { addDurationVital, getInternalContext }
1112
}))
1213

1314
afterEach(() => {
@@ -19,17 +20,20 @@ describe('DatadogRumTelemetryProvider', () => {
1920
it.for(['success', 'failure'] as const)(
2021
'records a workflow vital with a %s outcome',
2122
(outcome) => {
23+
getInternalContext.mockReturnValue({ view: { id: 'view-a' } })
2224
vi.spyOn(performance, 'now').mockReturnValue(142)
2325

2426
new DatadogRumTelemetryProvider().trackExecutionOutcome({
2527
startTime: 42,
2628
outcome
2729
})
2830

31+
expect(getInternalContext).toHaveBeenCalledWith(42)
2932
expect(addDurationVital).toHaveBeenCalledWith('workflow_execution', {
3033
startTime: performance.timeOrigin + 42,
3134
duration: 100,
3235
context: {
36+
origin_view_id: 'view-a',
3337
outcome,
3438
product: 'cloud_generation'
3539
}

src/platform/telemetry/providers/cloud/DatadogRumTelemetryProvider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ export class DatadogRumTelemetryProvider implements TelemetryProvider {
77
startTime,
88
outcome
99
}: ExecutionOutcomeMetadata): void {
10+
const originViewId = datadogRum.getInternalContext(startTime)?.view?.id
1011
datadogRum.addDurationVital('workflow_execution', {
1112
startTime: performance.timeOrigin + startTime,
1213
duration: performance.now() - startTime,
1314
context: {
1415
outcome,
15-
product: 'cloud_generation'
16+
product: 'cloud_generation',
17+
...(originViewId && { origin_view_id: originViewId })
1618
}
1719
})
1820
}

0 commit comments

Comments
 (0)