You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to integrate open-telemetry in a nuxt application, and I am trying to add the traceId and spanId globally to my logger.
I am using Pino and I was attempting to use a mixin to retrieve the current span, but I was always getting undefined.
To try to isolate the issue, I tried the same code in my Nuxt API endpoint and I also get undefined.
The http instrumentation is working, as I get the spans in console output. I just can´t seem to get the active span in my application.
tracing.ts
/*instrumentation.ts*/import{NodeSDK}from'@opentelemetry/sdk-node'import{trace}from'@opentelemetry/api'importtype{Tracer}from'@opentelemetry/api'import{BatchSpanProcessor,ConsoleSpanExporter,SimpleSpanProcessor,}from'@opentelemetry/sdk-trace-node'import{HttpInstrumentation}from'@opentelemetry/instrumentation-http'importtype{AppConfig}from'./config'import{Resource}from'@opentelemetry/resources'import{ATTR_SERVICE_NAME,ATTR_SERVICE_VERSION,}from'@opentelemetry/semantic-conventions'constsetupTracing=(config: AppConfig)=>{if(!config.tracing.enabled){console.log('Tracing is disabled')return}constsdk=newNodeSDK({resource: newResource({[ATTR_SERVICE_NAME]: config.tracing.appName,[ATTR_SERVICE_VERSION]: '1.0.0',}),spanProcessors: [newBatchSpanProcessor(newConsoleSpanExporter())],traceExporter: newConsoleSpanExporter(),instrumentations: [newHttpInstrumentation()],})console.log('Starting tracing sdk')sdk.start()process.on('SIGTERM',()=>shutdown(sdk))process.on('SIGINT',()=>shutdown(sdk))}constshutdown=(sdk: NodeSDK)=>{console.log('Shutting down tracing sdk')sdk.shutdown().then(()=>{console.log('Tracing sdk has been shutdown')process.exit(0)})}export{setupTracing}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello.
I am trying to integrate open-telemetry in a nuxt application, and I am trying to add the
traceId
andspanId
globally to my logger.I am using Pino and I was attempting to use a mixin to retrieve the current span, but I was always getting
undefined
.To try to isolate the issue, I tried the same code in my Nuxt API endpoint and I also get undefined.
The http instrumentation is working, as I get the spans in console output. I just can´t seem to get the active span in my application.
tracing.ts
Handler:
The
setupTracing
is called the start of my nuxt.config file.What I am missing?
Beta Was this translation helpful? Give feedback.
All reactions