diff --git a/aws-distro-opentelemetry-node-autoinstrumentation/src/register.ts b/aws-distro-opentelemetry-node-autoinstrumentation/src/register.ts index 8b9f1050..d3d0b2fa 100644 --- a/aws-distro-opentelemetry-node-autoinstrumentation/src/register.ts +++ b/aws-distro-opentelemetry-node-autoinstrumentation/src/register.ts @@ -47,19 +47,19 @@ export function setAwsDefaultEnvironmentVariables() { process.env.OTEL_PROPAGATORS = 'baggage,xray,tracecontext'; } if (!process.env.OTEL_NODE_DISABLED_INSTRUMENTATIONS) { - if (isAgentObservabilityEnabled()) { - // Assume users only need instrumentations that are manually set-up outside of OpenTelemetry - process.env.OTEL_NODE_DISABLED_INSTRUMENTATIONS = - 'amqplib,aws-lambda,aws-sdk,bunyan,cassandra-driver,connect,cucumber,dataloader,dns,express,fastify,fs,generic-pool,graphql,grpc,hapi,http,ioredis,kafkajs,knex,koa,lru-memoizer,memcached,mongodb,mongoose,mysql2,mysql,nestjs-core,net,pg,pino,redis,redis-4,restify,router,socket.io,tedious,undici,winston'; - } else { - // Disable the following instrumentations by default - // This auto-instrumentation for the `fs` module generates many low-value spans. `dns` is similar. - // https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1344#issuecomment-1618993178 - process.env.OTEL_NODE_DISABLED_INSTRUMENTATIONS = 'fs,dns'; - } + // Disable the following instrumentations by default + // This auto-instrumentation for the `fs` module generates many low-value spans. `dns` is similar. + // https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1344#issuecomment-1618993178 + process.env.OTEL_NODE_DISABLED_INSTRUMENTATIONS = 'fs,dns'; } if (isAgentObservabilityEnabled()) { + if (!process.env.OTEL_NODE_ENABLED_INSTRUMENTATIONS) { + // Assume users only need aws-sdk and aws-lambda instrumentations, as well as + // instrumentations that are manually set-up outside of OpenTelemetry + process.env.OTEL_NODE_ENABLED_INSTRUMENTATIONS = 'aws-lambda,aws-sdk'; + } + // Set exporter defaults if (!process.env.OTEL_TRACES_EXPORTER) { process.env.OTEL_TRACES_EXPORTER = 'otlp'; diff --git a/aws-distro-opentelemetry-node-autoinstrumentation/test/register.test.ts b/aws-distro-opentelemetry-node-autoinstrumentation/test/register.test.ts index c2358ac9..47e4d5ac 100644 --- a/aws-distro-opentelemetry-node-autoinstrumentation/test/register.test.ts +++ b/aws-distro-opentelemetry-node-autoinstrumentation/test/register.test.ts @@ -28,6 +28,7 @@ describe('Register', function () { delete process.env.OTEL_EXPORTER_OTLP_PROTOCOL; delete process.env.OTEL_PROPAGATORS; delete process.env.OTEL_NODE_DISABLED_INSTRUMENTATIONS; + delete process.env.OTEL_NODE_ENABLED_INSTRUMENTATIONS; delete process.env.AWS_REGION; delete process.env.AWS_DEFAULT_REGION; @@ -100,9 +101,8 @@ describe('Register', function () { expect(process.env.OTEL_METRICS_EXPORTER).toEqual('awsemf'); expect(process.env.OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT).toEqual('true'); expect(process.env.OTEL_TRACES_SAMPLER).toEqual('parentbased_always_on'); - expect(process.env.OTEL_NODE_DISABLED_INSTRUMENTATIONS).toEqual( - 'amqplib,aws-lambda,aws-sdk,bunyan,cassandra-driver,connect,cucumber,dataloader,dns,express,fastify,fs,generic-pool,graphql,grpc,hapi,http,ioredis,kafkajs,knex,koa,lru-memoizer,memcached,mongodb,mongoose,mysql2,mysql,nestjs-core,net,pg,pino,redis,redis-4,restify,router,socket.io,tedious,undici,winston' - ); + expect(process.env.OTEL_NODE_DISABLED_INSTRUMENTATIONS).toEqual('fs,dns'); + expect(process.env.OTEL_NODE_ENABLED_INSTRUMENTATIONS).toEqual('aws-lambda,aws-sdk'); expect(process.env.OTEL_AWS_APPLICATION_SIGNALS_ENABLED).toEqual('false'); expect(process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT).toEqual('https://xray.us-east-1.amazonaws.com/v1/traces'); expect(process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT).toEqual('https://logs.us-east-1.amazonaws.com/v1/logs');