opentelemetry-js-contrib icon indicating copy to clipboard operation
opentelemetry-js-contrib copied to clipboard

instrumentation-aws-lambda: Error when configuring tracing without metrics

Open jordankay13 opened this issue 9 months ago • 2 comments

What version of OpenTelemetry are you using?

instrumentation-aws-lambda: v0.50.3

What version of Node are you using?

22

What did you do?

Instrumented an AWS Lambda Function with opentelemetry

  const provider = new NodeTracerProvider({
    resource: new Resource({
      [ATTR_SERVICE_NAME]: 'my-service'
    }),
    sampler: new AlwaysOnSampler(),
    spanProcessors: [
      new BatchSpanProcessor(myExporter),
    ],
  });

  registerInstrumentations({
    instrumentations: [
      getNodeAutoInstrumentations({
        '@opentelemetry/instrumentation-aws-lambda': {
          disableAwsContextPropagation: true,
        },
      }),
    ],
  });

What did you expect to see?

Error logs should be clean.

What did you see instead?

Error logs: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/b520d048465d9b3dfdf275976010c989d2a78a2c/plugins/node/opentelemetry-instrumentation-aws-lambda/src/instrumentation.ts#L392-L394 Metrics may not be exported for the lambda function because we are not force flushing before callback.

Additional context

Despite not wanting metrics to be configured, the lambda instrumentation is requiring it through this error. We now either have to filter out these errors from our alerting or we have to configure a MeterProvider.

jordankay13 avatar Mar 07 '25 20:03 jordankay13

Categorized as P4 (logspam) - looks like there's no need to log an error in this case. cc @jj22ee (component owner)

(side note: It's a bit of a weird feature as it accesses SDK methods from an API instance, violating an OTel design principle. Though I can see why it would do that (avoiding data loss for a something as short-lived as a lambda).)

pichlermarc avatar Mar 12 '25 15:03 pichlermarc

I was initially thinking of changing this to a warn error, but then this issue would still pretty valid since the default info log level will still show this log by default. I've put up the PR#2753 to change this to debug log, given we don't need to warn the user as they have intended to not configure metrics/traces.

jj22ee avatar Mar 13 '25 08:03 jj22ee

Closing this as this was addressed by #2753

pichlermarc avatar Apr 10 '25 15:04 pichlermarc