Skip to content

Commit

Permalink
feat(nodejs): add propagator auto-configuration (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkuba authored Aug 12, 2024
1 parent 3869f3a commit 0725e69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nodejs/packages/layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
},
"dependencies": {
"@opentelemetry/api": "^1.7.0",
"@opentelemetry/exporter-trace-otlp-proto": "^0.52.1",
"@opentelemetry/auto-configuration-propagators": "^0.2.0",
"@opentelemetry/exporter-metrics-otlp-proto": "^0.52.1",
"@opentelemetry/exporter-trace-otlp-proto": "^0.52.1",
"@opentelemetry/instrumentation": "^0.52.1",
"@opentelemetry/instrumentation-aws-lambda": "^0.43.0",
"@opentelemetry/instrumentation-aws-sdk": "^0.43.0",
Expand Down
5 changes: 5 additions & 0 deletions nodejs/packages/layer/src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { getEnv } from '@opentelemetry/core';
import { AwsLambdaInstrumentationConfig } from '@opentelemetry/instrumentation-aws-lambda';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
import { MeterProvider, MeterProviderOptions } from '@opentelemetry/sdk-metrics';
import { getPropagator } from '@opentelemetry/auto-configuration-propagators';

function defaultConfigureInstrumentations() {
// Use require statements for instrumentation to avoid having to have transitive dependencies on all the typescript
Expand Down Expand Up @@ -121,6 +122,10 @@ async function initializeProvider() {
if (typeof configureSdkRegistration === 'function') {
sdkRegistrationConfig = configureSdkRegistration(sdkRegistrationConfig);
}
// auto-configure propagator if not provided
if (!sdkRegistrationConfig.propagator) {
sdkRegistrationConfig.propagator = getPropagator();
}
tracerProvider.register(sdkRegistrationConfig);

// Configure default meter provider (doesn't export metrics)
Expand Down

0 comments on commit 0725e69

Please sign in to comment.