Skip to content

Commit 9fa740e

Browse files
committed
fix: duration as a measurement
1 parent f35e932 commit 9fa740e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

packages/salesforcedx-vscode-services/src/observability/applicationInsightsNodeExporter.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,11 @@ const sendSpan = (span: ReadableSpan, otelLogger: ReturnType<LoggerProvider['get
109109
Effect.gen(function* () {
110110
const telemetryTag = workspace.getConfiguration()?.get<string>('salesforcedx-vscode-core.telemetry-tag');
111111

112-
const orgRefResult = yield* Effect.gen(function* () {
112+
const { userId, webUserId } = yield* Effect.gen(function* () {
113113
const orgRef = yield* getDefaultOrgRef();
114114
return yield* SubscriptionRef.get(orgRef);
115115
}).pipe(Effect.catchAll(() => Effect.succeed({ userId: undefined, webUserId: undefined })));
116116

117-
const { userId, webUserId } = orgRefResult;
118-
119117
const isError = span.status?.code === SpanStatusCode.ERROR;
120118

121119
// Emit a LogRecord — the "microsoft.custom_event.name" attribute tells Azure Monitor
@@ -126,7 +124,12 @@ const sendSpan = (span: ReadableSpan, otelLogger: ReturnType<LoggerProvider['get
126124
// https://github.com/open-telemetry/opentelemetry-js/blob/main/api/src/logs/LogRecord.ts
127125
severityNumber: isError ? 17 : 9,
128126
severityText: isError ? 'ERROR' : 'INFO',
129-
body: span.name,
127+
// The customEvent name comes from the microsoft.custom_event.name attribute (below), so body
128+
// is free to carry numeric measurements: the Azure log→customEvent mapping reads
129+
// body.measurements into baseData.measurements (logUtils.getLegacyApplicationInsightsMeasurements).
130+
// duration is ALSO kept in attributes → properties (string) so existing properties consumers
131+
// keep working; measurements gives the queryable numeric copy.
132+
body: { measurements: { duration: spanDuration(span) } },
130133
attributes: {
131134
// Magic attribute: routes this LogRecord to the customEvents table
132135
'microsoft.custom_event.name': span.name,

0 commit comments

Comments
 (0)