Per-Instrumentation Configuration via Environment Variables

Abierto
#2,018 2 comentarios 1 reacción 1 asignado Ver en GitHub

Los mantenedores suelen responder en 2 días

@wpessers ya está trabajando en esto.

Desde el 30/11/2025.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

enhancement

Is your feature request related to a problem? Please describe.

Yes. Currently, users cannot configure instrumentation-specific options (like GraphQLInstrumentation.mergeItems, PinoInstrumentation.disableLogSending, etc.) without using global.configureInstrumentations(), which requires code changes and defeats the "zero-code" promise.

The problem: When you define global.configureInstrumentations(), it completely replaces the default instrumentation system. You must manually import and configure ALL instrumentations you want, and OTEL_NODE_ENABLED_INSTRUMENTATIONS is ignored.

Example: To configure GraphQL with mergeItems: true while keeping http, grpc, pg, pino enabled, you must manually import and configure all 5 instrumentations in code, even though you only want to customize GraphQL.

// Must be at the top of handler file, before any imports
global.configureInstrumentations = async () => {
  // Must import ALL instrumentations manually
  const { GraphQLInstrumentation } = await import(
    "@opentelemetry/instrumentation-graphql"
  );
  const { HttpInstrumentation } = await import(
    "@opentelemetry/instrumentation-http"
  );
  const { GrpcInstrumentation } = await import(
    "@opentelemetry/instrumentation-grpc"
  );
  const { PgInstrumentation } = await import(
    "@opentelemetry/instrumentation-pg"
  );
  const { PinoInstrumentation } = await import(
    "@opentelemetry/instrumentation-pino"
  );

  return [
    new GraphQLInstrumentation({ mergeItems: true }), // Only GraphQL needs custom config
    new HttpInstrumentation(), // But must still include all others
    new GrpcInstrumentation(),
    new PgInstrumentation(),
    new PinoInstrumentation(),
  ];
};

Describe the solution you'd like

Add support for OTEL_INSTRUMENTATION_CONFIGS environment variable that accepts a JSON object mapping instrumentation names to their configurations. This works alongside OTEL_NODE_ENABLED_INSTRUMENTATIONS:

# Environment variables only - no code changes needed!
OTEL_NODE_ENABLED_INSTRUMENTATIONS="graphql,http,grpc,pg,pino"
OTEL_INSTRUMENTATION_CONFIGS={"graphql":{"mergeItems":true},"pino":{"disableLogSending":true}}

This would:

  • Use OTEL_NODE_ENABLED_INSTRUMENTATIONS to determine which instrumentations to load (existing behavior)
  • Apply configuration from OTEL_INSTRUMENTATION_CONFIGS to respective instrumentations
  • Use defaults for instrumentations not specified in the config

Implementation: Add loadInstrumentationConfigs() function to parse the env var, and update defaultConfigureInstrumentations() in nodejs/packages/layer/src/wrapper.ts to merge user configs with defaults when creating instrumentations.

Describe alternatives you've considered

  1. Per-instrumentation environment variables (e.g., OTEL_PINO_CONFIG) - Rejected: Would pollute env vars and doesn't scale with 30+ instrumentations
  2. Keep current global.configureInstrumentations() approach - Rejected: Requires code changes, breaks zero-code promise
  3. Configuration file - Rejected: Environment variables are more standard for Lambda and work better with AWS Systems Manager Parameter Store/Secrets Manager

Additional context

Benefits:

  • True zero-code configuration via environment variables
  • Works seamlessly with existing OTEL_NODE_ENABLED_INSTRUMENTATIONS
  • Fully backwards compatible
  • No code changes required in Lambda functions

Affected instrumentations: All 30+ instrumentations in the layer

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Lenguaje dominante
Go
Estrellas
433
Forks
249
Merge medio
1 d 12 h
PR fusionados (30 d)
39

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de open-telemetry/opentelemetry-lambda

Todos los issues de open-telemetry/opentelemetry-lambda

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.