Skip to content

Commit

Permalink
feat: allow to modify parentId, id and name of operation (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien authored Sep 30, 2024
1 parent 572b8df commit 309a3a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ export default <NitroAppPlugin>(async (nitro) => {

if(ctx.event) {
exceptionTelemetry.contextObjects = {
...exceptionTelemetry.contextObjects,
[ctx.event.$appInsights.client.context.keys.operationParentId]: ctx.event.$appInsights.trace.traceId,
[ctx.event.$appInsights.client.context.keys.operationName]: `${ctx.event.method}: ${ctx.event.path}`,
[ctx.event.$appInsights.client.context.keys.operationId]: ctx.event.$appInsights.trace.traceId
[ctx.event.$appInsights.client.context.keys.operationId]: ctx.event.$appInsights.trace.traceId,
...exceptionTelemetry.contextObjects,
}
}

Expand All @@ -124,11 +124,11 @@ async function trackEvent(nitro: NitroApp, event: H3Event) {
success: statusCode < 400,
properties: event.$appInsights.properties,
contextObjects: {
...event.$appInsights.tags,
[event.$appInsights.client.context.keys.operationParentId]:
getRequestHeader(event, 'traceparent')?.split('-')[2] ?? event.$appInsights.trace.spanId,
[event.$appInsights.client.context.keys.operationName]: name,
[event.$appInsights.client.context.keys.operationId]: event.$appInsights.trace.traceId
[event.$appInsights.client.context.keys.operationId]: event.$appInsights.trace.traceId,
...event.$appInsights.tags,
},
id: event.$appInsights.trace.spanId
}
Expand Down

0 comments on commit 309a3a0

Please sign in to comment.