Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
    Paul Rhodes

    Heya. We're using opentelemetry across a number of languages. In our python code we're able to do the following to set default attributes for every span.

            'RELEASE': os.environ.get('RELEASE_NAME', 'unknown'),
            'COMPONENT': os.environ.get('COMPONENT', 'appname'),
            'VERSION': os.environ.get('APP_VERSION', 'unknown')

    Is there a way to do something similar in the node library?

    Daniel Dyla
    Please either use github discussions or the CNCF slack https://slack.cncf.io #otel-js
    Marcelo Olivas

    hey guys while trying to run the example on opentelemetry-js https://github.com/open-telemetry/opentelemetry-js/tree/main/getting-started#initialize-a-global-tracer I am getting the following error once I added the followingtracing.js code:

    'use strict';
    const { LogLevel } = require("@opentelemetry/core");
    const { NodeTracerProvider } = require("@opentelemetry/node");
    const { registerInstrumentations } = require("@opentelemetry/instrumentation");
    const provider = new NodeTracerProvider({
      logLevel: LogLevel.ERROR
      tracerProvider: provider,

    and then try to run node -r ./tracing.js app.js

    node -r ./tracing.js app.js 
      logLevel: LogLevel.ERROR
    TypeError: Cannot read property 'ERROR' of undefined
        at Object.<anonymous> (/Users/marcelo/development/open-source/opentelemetry-js/getting-started/example/tracing.js:8:22)
        at Module._compile (internal/modules/cjs/loader.js:1151:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
        at Module.load (internal/modules/cjs/loader.js:1000:32)
        at Function.Module._load (internal/modules/cjs/loader.js:899:14)
        at Module.require (internal/modules/cjs/loader.js:1040:19)
        at Module._preloadModules (internal/modules/cjs/loader.js:1296:12)
        at loadPreloadModules (internal/bootstrap/pre_execution.js:435:5)
        at prepareMainThreadExecution (internal/bootstrap/pre_execution.js:68:3)
        at internal/main/run_main_module.js:7:1
    3 replies
    Bojanche Stojchevski
    good morning opentelemetry people... just created open-telemetry/opentelemetry-js-contrib#375 and open-telemetry/opentelemetry-js-contrib#376 regarding instrumentation-graphql and express example issues... willing to help in any shape and form just will need some guidance since I'm fairly new to opentelemetry and don't know the SDK and APIs properly yet...
    S Raghav Pillai
    Hi is there any way to auto-instrument "sequelize": "^5.21.7", "@opentelemetry/plugin-mysql" and "opentelemetry-plugin-sequelize" are not working?
    andrew quartey
    Hi i'm trying to instrument a node app that makes grpc calls. However, it appears that the instrumentation is not being applied. This is my tracing.ts file:
    import { NodeTracerProvider } from '@opentelemetry/node';
    import { BatchSpanProcessor } from '@opentelemetry/tracing';
    import { CollectorTraceExporter } from '@opentelemetry/exporter-collector';
    import { registerInstrumentations } from '@opentelemetry/instrumentation'
    import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'
    import { GrpcInstrumentation } from '@opentelemetry/instrumentation-grpc'
    const SERVICE_NAME: string = 'test-app'
    const provider = new NodeTracerProvider();
      tracerProvider: provider,
      instrumentations: [
        new HttpInstrumentation(),
        new GrpcInstrumentation(),
    const exporter =  new CollectorTraceExporter({serviceName: SERVICE_NAME});
    provider.addSpanProcessor(new BatchSpanProcessor(exporter));
    console.log('Tracing Initialized');
    9 replies
    anything i'm doing wrong? I'm using version 0.18.0 of the libraries referenced
    Barend Bootha
    Screen Shot 2021-03-18 at 9.10.32 AM.png
    Hi All looking for some guidence
    I'm trying to set some context to a trace that I can reuse in the same process down the line. It can be global to the trace, it doesn't need to be set be bound to a specific span.
    I've tried setting a value on the context, but not getting any values back down the line (same process)
     context.setValue(TEST_KEY, 'some value');
    Jakub Kisielewski

    Is NodeTracerProvider#register() supposed to update the global context manager on context (from @opentelemetry/api@0.18.0)?

    If so, that's not happening for me. Also there's no method to get the context manager from the provider, so seems like the only option is:

    const contextManager = new AsyncHooksContextManager();
    const provider = new NodeTracerProvider();
    provider.register({ contextManager });

    Is that it?

    Sandes de Silva
    Hi all, is there a way to pass trace context to metrics? I'm trying to deep link a trace to a metric.
    andrew quartey
    Hi. I have my tracing all setup and working correctly with jaeger & zipkin. Anyway, i wanted to extract the traceId of the current span and include that as part of a custom error response sent back to a calling client. I keep getting the traceId of the NoopSpan instead: "traceId":"00000000000000000000000000000000". Here's my sample code:
    import * as api from '@opentelemetry/api';
    const tracer = api.trace.getTracer('payroll-tracer')
    employeesRouter.get('/', (_request: Request, response: Response, next: NextFunction) => {
        const span = tracer.startSpan('payroll: getAllEmployees');
        api.context.with(api.setSpan(api.context.active(), span), () => {
            const traceId = span.context().traceId;  // <---- returns NoopSpan traceId: 00000000000000000000000000000000
            employeeService.getAllEmployees({}, (err: any, result: any) => {
                if (err) {
                    next(createError(...[convertGrpcToHttpErrorCode(err)], {
                        developerMessage: err.message, 
    7 replies
    Can anyone help me with integrating AWS-XRAY with OTEL with a sample Example
    3 replies
    This message was deleted
    1 reply
    How can I use Elastic Search as a backend for Zipkin ?
    1 reply
    Raghavendra Sai

    Hey everyone, I got a simple use case. I wanna send logs from node-app to collector and export those logs to loki. I managed to integrate collector with loki exporter using this -> https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/lokiexporter/example

    So now I am trying to read logs from oltp as receiver through http endpoint (instead of fluent forward/fluentd) and export them to loki. After going through docs I found out that otel log format is required, couldn't find any references on how to send logs from node-app in the official documentation

    There are npm packages for tracing and metrics, can the same be used for sending logs to otlp and will they work the same to export logs to loki? Thoughts on what to do here?

    P.S I checked https://opentelemetry.io/docs/js/ and there's no mention/references on sending logs.

    2 replies
    Jakub Malinowski
    Fix for opentelemetry.io docs, appreciated if someone from OTel JS approvers can stamp it open-telemetry/opentelemetry.io#512
    Hi Everyone, I don't need any help with an issue, but I wanted to show how I got past an issue I hit before using opentelemetry version v0.19.0. I've got two servicesboth written in golang that communicate using a bi-directional gRPC stream and I wanted to have context propagation between the services in order to display the span traces for requests between the services in Tempo. Unfortunately, it looks like you cannot do context propagation with a bi-directional gRPC stream, so I had to resort to setting the Trace Id on each proto sent between the services. Once a service receives a proto with a Trace Id, I needed to build a context and set the Trace Id on it. This code snippet is what I used to create a new Span that eventually got displayed on Tempo. Hope this is useful to somone
    2 replies

    Hi everyone. I want to reuse the traceId through some async processes in our architecture. (One use case is that we have a scheduler that we call to create jobs that will run at set times)
    I am doing this by storing the traceId manually and picking it back up.

    In nodejs:

    1. How can I re-use this traceId when starting a span?
    2. How can I set this context as active? (Our log factory is getting traceId/spanId from active context)

    I have made this work in golang (the same way as "hettothecool" in the post above), but can't find a way to do it in nodejs.
    Thanks in advance!

    1 reply
    Jordan Sinko
    Anyone having issues with Xray Id Generator creating non unique trace ids? I am seeing some of my traces grouping 4-5 traces that should have their own id. We arent carrying through the parent context, so the root id is always generated
    1 reply

    In my jest testing I am running into this error

    TypeError: Cannot read property 'INFO' of undefined
     1 | import { SimpleSpanProcessor } from "@opentelemetry/tracing";
            | ^
          2 | import { WebTracerProvider } from "@opentelemetry/web";
          3 | import { trace } from "@opentelemetry/api";
          4 | import IntuitTraceExporter from "../../../src/utils/trace/IntuitTraceExporter";
          at Object.<anonymous> (node_modules/@opentelemetry/core/src/utils/environment.ts:101:32)
          at Object.<anonymous> (node_modules/@opentelemetry/core/src/platform/node/environment.ts:18:1)
          at Object.<anonymous> (node_modules/@opentelemetry/core/src/platform/node/index.ts:17:1)
          at Object.<anonymous> (node_modules/@opentelemetry/core/src/platform/index.ts:16:1)
          at Object.<anonymous> (node_modules/@opentelemetry/core/src/common/time.ts:18:1)
          at Object.<anonymous> (node_modules/@opentelemetry/core/src/index.ts:20:1)
          at Object.<anonymous> (node_modules/@opentelemetry/tracing/src/Tracer.ts:18:1)
          at Object.<anonymous> (node_modules/@opentelemetry/tracing/src/index.ts:17:1)
          at Object.<anonymous> (test/utils/trace/IntuitTraceActionHandler.test.js:1:1)

    I don't see it in actual runtime, only in the unit tests. Any ideas?

    1 reply
    Dharin Shah
    hi, can someone please help me with this issue
    open-telemetry/opentelemetry-js#2235, new to typescript
    Dharin Shah

    hi, can someone please help me with this issue
    open-telemetry/opentelemetry-js#2235, new to typescript

    Resolved :)

    Dharin Shah
    question : will the http instrumentation registration work after the server is started ?

    I having a real hard time tried to get distributed traces working with 0.19 (haven't tried previous). Have two node services A,B. In this case A calls B. I can get traces showing up in Jaegar for both A and B but not as a single trace. Looking at the headers in B I don't see any trace related ones.

    per the examples I could find A looks like

    const serviceName = 'A'
      const provider = new NodeTracerProvider()
        tracerProvider: provider,
        instrumentations: [new HttpInstrumentation()],
      const consoleExporter = new ConsoleSpanExporter()
      const spanProcessor = new SimpleSpanProcessor(consoleExporter)
      const jaegerExporter = new JaegerExporter({
        host: 'localhost',
      const zipkinProcessor = new SimpleSpanProcessor(jaegerExporter)
      const tracer = trace.getTracer(serviceName)

    from what I can gather it should be hooking directly into the http module. Since A calls B via node-fetch, (which uses http) this should get auto propagated correct?

    3 replies
    deepak khetwal
    What's the best way to propagate tracing between services communicated through message broker like kafka. Can someone share code or advise, how that can be implemented
    I tried passing span context and retrieved at other end and added it to span created, but getting error context.value is not a function
    3 replies
    Can some one help me with this error
    hi guys, anyone encountered this ? was following the otel nodejs getting-started, however not sure why my service.name always ended up as unknown_service even though i have specifically indicated serviceName:"getting-started" inside the tracking.js file
    1 reply
    deepak khetwal
    @dyladan I am having trouble in setting up trace between two azure functions producing and consuming using keda(kafka trigger). Do you have sample code to set up trace between kafka producer and consumer, can't use kafkajs as instrumentation library for context propagation and maintain trace between these two, as Azure functions are handling producing and consuming messages through their wrapper internally.
    {"stack":"Error: 14 UNAVAILABLE: No connection established\n    at Object.callErrorFromStatus (D:\\Users\\akashdeep\\Desktop\\Examples\\sampleTracing\\node_modules\\@grpc\\grpc-js\\build\\src\\call.js:31:26)\n
    Getting this error while using it whenever I hit the endpoint.... I get the traces in the
    console but this error is also there\
    Pier-Luc Gagnon
    How do you create child spans now? I see a lot of documentation saying something like
    const childSpan = tracer.startSpan('foo', {parent: bar}); // but parent is not in SpanOptions
    // or
    const childSpan = tracer.withSpan(...); // this is not a method on tracer
    Anupam Dalmia


    I am using this extension for instrumenting in the browser: https://github.com/svrnm/opentelemetry-browser-extension/

    It is using opentelemetry for web, I wanted to know if there is any way to pass on the info of traces generated by this extension with the actual web request to backend.

    One way I can think of is using chrome.WebRequest API but wanted to know if the library itself gives any option to do so.


    Is there a way to add custom header to be attached to each span in one trace? I'm trying to tie a frontend session to a trace but I want the frontend session ID to be attached to every span in that trace. Right now I can only attach a frontend session ID by setting it as an attribute on the first span.

    "use strict";
    const PORT = process.env.PORT || "8080";
    const { trace, context } = require('@opentelemetry/api')
    const express = require("express");
    const axios = require("axios");
    const app = express();
    app.get("/", (req, res) => { 
      let headers = req.headers;
      let sessionURL = headers["sessionurl"];
      let currentSpan = trace.getSpan(context.active());
      currentSpan.setAttribute("frontendSession", sessionURL);
        .then(() => axios.get(`http://localhost:${PORT}/middle-tier`))
        .then((result) => {
        .catch((err) => {

    The tracing.js file looks like this:

    "use strict";
    const { NodeTracerProvider } = require("@opentelemetry/node");
    const { diag, DiagConsoleLogger, DiagLogLevel } = require("@opentelemetry/api");
    const { registerInstrumentations } = require("@opentelemetry/instrumentation");
    const { HttpInstrumentation } = require("@opentelemetry/instrumentation-http");
    const { GrpcInstrumentation } = require("@opentelemetry/instrumentation-grpc");
    const { Resource } = require("@opentelemetry/resources");
    const { ResourceAttributes } = require("@opentelemetry/semantic-conventions");
    const { SimpleSpanProcessor } = require("@opentelemetry/tracing");
    const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
    const provider = new NodeTracerProvider({});
    diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ALL);
    provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({})));
      instrumentations: [new HttpInstrumentation(), new GrpcInstrumentation()],
    console.log("tracing initialized :)");

    Here's a screenshot of the trace in Zipkin: https://www.screencast.com/t/qnKakEzNym

    And here's the package.json file:
      "dependencies": {
        "@opentelemetry/api": "^0.21.0",
        "@opentelemetry/core": "^0.21.0",
        "@opentelemetry/exporter-prometheus": "^0.21.0",
        "@opentelemetry/exporter-zipkin": "^0.21.0",
        "@opentelemetry/instrumentation-express": "^0.22.0",
        "@opentelemetry/instrumentation-grpc": "^0.21.0",
        "@opentelemetry/instrumentation-http": "^0.21.0",
        "@opentelemetry/metrics": "^0.21.0",
        "@opentelemetry/node": "^0.21.0",
        "@opentelemetry/tracing": "^0.21.0",
        "axios": "^0.21.0",
        "express": "^4.17.1"
    Jason Kuhrt
    Can someone point me to docs for adding OT to node+lambda?
    Raja Moola Mahadevan
    Hi, I have been trying to setup Otl for Javascript (Angular) application. Everything works fine. But it is showing "unknown service " in the zipkin after the trace. Does anyone know how to mention the service name ?
    Can someone PLEASE point me to where/how I can configure additional attributes/labels on metrics being consumed by the host metric receiver in the otel agent configuration and being exported with the awsemf exporter? I have not been able to successfully apply additional attributes/dimensions and this seems like a rudimentary feature so I must just be doing it wrong.
    Anupam Dalmia
    11 replies
    Aritra Das

    Using lightstep-opentelemetry-launcher-node
    When I use the public sattelite spans are received correctly on the dashboard.
    But as soon as I put my private satellite it stops receiving spans.
    My private satellite is reachable from the host machine.

    Satellite Status
    ✓ ready / healthy
    ✓ alive
    ✓ configuration parsed

    Satellite staus also shows ok.
    Can someone tell what could be wrong?

    new WinstonInstrumentation({
            // Optional hook to insert additional context to log metadata.
            // Called after trace context is injected to metadata.
            logHook: (record, span) => {
              record['resource.service.name'] =

    Im trying top instrument winston in my application. then logging inside this example function

    const winston = require('winston');
    const logger = winston.createLogger({
      transports: [new winston.transports.Console()],
    export async function nExample() {
      const span = track.startSpan('spanStarted', {
        attributes: {
          'code.function': 'Example Function',
      for (var i = 0; i < 10; i++) {
        await console.log('Span is started');

    But im not able to see trace id and spanid in the log. Can anyone suggest me the solution or if i am doing something wrong or am i missing something


    Has anyone seen this error when trying to write to Amazon Managed Prometheus

    2021-08-26T19:17:41.683Z    error    exporterhelper/queued_retry.go:288    Exporting failed. The error is not retryable. Dropping data.    {"kind": "exporter", "name": "awsprometheusremotewrite", "error": "Permanent error: [Permanent error: invalid temporality and type combination; Permanent error: invalid temporality and type combination; Permanent error: invalid temporality and type combination]", "dropped_items": 66}

    The error doesn't really make much sense to me and I can't seem to find any instances of others having the same issue. Thoughts?

    Opened a bug ticket about prometheus writter. Any input would be greatly apprecaited: open-telemetry/opentelemetry-collector-contrib#4909
    Ivan Pukhtin
    I need my child span to be in child_process. How can I pass context to subprocesses?