-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: @opentelemetry/api: Attempted duplicate registration of API: trace #12717
Comments
Hey, I do not think we have a great setup yet for AWS + Custom OTEL setup. Just so I understand, what's the reason for going with a custom setup vs. just using If you have a manual setup, you do not need to add Generally, if you set |
Yes. We are using the AWS provided lambda layer from https://aws-otel.github.io/docs/getting-started/lambda/lambda-js, there's no custom setup code on our side. It uses the stock otel layer under the hood with some custom config for AWS. Most of the setup happens in this wrapper.ts file which you can see in the stacktrace. It calls the
You are correct, but what is happening is that the stock initialization in wrapper.ts is running after Sentry's initialization which is resulting in the duplication errors. |
OK, I see, I think! I think the problem is that you are calling import * as Sentry from "@sentry/aws-serverless";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { SentryPropagator, SentrySpanProcessor } from "@sentry/opentelemetry";
import { SentryContextManager, validateOpenTelemetrySetup } from "@sentry/node";
const sentryClient = Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.SENTRY_ENVIRONMENT,
normalizeDepth: 8,
skipOpenTelemetrySetup: true,
integrations: [Sentry.extraErrorDataIntegration({ depth: 8 })],
});
declare global {
// Global hook exposed by otel layer
function configureTracerProvider(tracerProvider: NodeTracerProvider): void;
function configureSdkRegistration(config: Record<string, any>): Record<string, any>;
function configureInstrumentations(): any[];
function configureTracer(config: any): any;
}
const oldConfigureTracerProvider = global.configureTracerProvider;
const oldConfigureSdkRegistration = global.configureSdkRegistration;
// We let Sentry register instrumentation
global.configureInstrumentation = function() {
return [];
}
global.configureTracer = (config) => {
config.sampler = sentryClient ? new SentrySampler(sentryClient) : undefined,
return config;
}
global.configureSdkRegistration = (config) => {
config.propagator = new SentryPropagator();
config.contextManager = new SentryContextManager();
if (typeof oldConfigureSdkRegistration === 'function') {
return oldConfigureTracerProvider(config);
}
return config;
};
global.configureTracerProvider = (provider) => {
if (typeof oldConfigureTracerProvider === "function") {
oldConfigureTracerProvider(provider);
}
provider.addSpanProcessor(new SentrySpanProcessor());
}; Something like this should work, I believe! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/aws-serverless
SDK Version
8.13.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup/Reproduction Example
Steps to Reproduce
Expected Result
AWS otel w/ xray and Sentry work together in beautiful harmony :)
I attempted to use the manual setup guide in the docs. It's not entirely clear to me from the docs how Sentry is supposed to fit into an existing opentelemetry setup.
Actual Result
The configs clash and log the following error:
The text was updated successfully, but these errors were encountered: