From e4840c48152f7cbb4ca540b4b7634e654ffb3bf9 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 20 Sep 2024 16:47:48 +0200 Subject: [PATCH 1/2] ref(js): Simplify manual queue instrumentation code --- .../custom-instrumentation/queues-module.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx index f88ebdb58a6ca..2f74ef49a7d68 100644 --- a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx +++ b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx @@ -57,14 +57,14 @@ app.post("/publish", async (req, res) => { "messaging.message.body.size": messageBodySize, }, }, - async (span) => { - const traceHeader = Sentry.spanToTraceHeader(span); - const baggageHeader = Sentry.spanToBaggageHeader(span); + async () => { + const { "sentry-trace": sentryTrace, baggage: sentryBaggage } = + getTraceData(); await redisClient.lPush( "messages", JSON.stringify({ - traceHeader, - baggageHeader, + sentryTrace, + sentryBaggage, timestamp: Date.now(), messageId, }) @@ -99,7 +99,7 @@ const message = JSON.parse(await redisClient.lPop(QUEUE_KEY)); const latency = Date.now() - message.timestamp; Sentry.continueTrace( - { sentryTrace: message.traceHeader, baggage: message.baggageHeader }, + { sentryTrace: message.sentryTrace, baggage: message.sentryBaggage }, () => { Sentry.startSpan({ name: 'queue_consumer_transaction', From 30777fc60dec0769a87da9d9c837006889b95ccc Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 20 Sep 2024 16:54:01 +0200 Subject: [PATCH 2/2] add Sentry --- .../instrumentation/custom-instrumentation/queues-module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx index 2f74ef49a7d68..f48dac9b53bd7 100644 --- a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx +++ b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/queues-module.mdx @@ -59,7 +59,7 @@ app.post("/publish", async (req, res) => { }, async () => { const { "sentry-trace": sentryTrace, baggage: sentryBaggage } = - getTraceData(); + Sentry.getTraceData(); await redisClient.lPush( "messages", JSON.stringify({