open-telemetry / opentelemetry-js

OpenTelemetry JavaScript Client
https://opentelemetry.io
Apache License 2.0
2.75k stars 809 forks source link

TracerProvider should return no-op tracer when shutdown #3211

Open pichlermarc opened 2 years ago

pichlermarc commented 2 years ago

Description

According to the spec a TracerProvider should return no-op tracer when shutdown.

Steps to Reproduce

Test for BasicTracerProvider.test.ts

  describe('.getTracer()', () => {
    it('should return no-op tracer when already shutdown', () => {
      const tracerProvider = new BasicTracerProvider();
      tracerProvider.shutdown();

      // returned tracer should be no-op, not instance of Tracer (from SDK) 
      assert.ok(!(tracerProvider.getTracer('foo') instanceof Tracer));
    });
  });

Additional Details

Spec: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#shutdown Link to getTracer() code: https://github.com/open-telemetry/opentelemetry-js/blob/3db10568be4387ef024aa431ca1addef18c2441e/packages/opentelemetry-sdk-trace-base/src/BasicTracerProvider.ts#L93-L101

sudhanshu-chauhan commented 2 years ago

would like to take this up!

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.