Interface Configuration

OpenTelemetry SDK configuration.

interface Configuration {
    attributes?: Attributes;
    attributesFromHeaders?: AttributesFromHeaders;
    autoDetectResources?: boolean;
    contextManager?: ContextManager;
    idGenerator?: IdGenerator;
    instrumentationConfig?: InstrumentationConfiguration;
    instrumentations?: InstrumentationOptionOrName[];
    logRecordProcessors?: LogRecordProcessor[];
    metricReaders?: MetricReader[];
    propagators?: PropagatorOrName[];
    resourceDetectors?: ResourceDetector[];
    serviceName?: string;
    spanLimits?: SpanLimits;
    spanProcessors?: SpanProcessorOrName[];
    traceExporter?: SpanExporterOrName;
    traceSampler?: SampleOrName;
    views?: ViewOptions[];
}

Properties

attributes?: Attributes

The additional resource attributes to apply to all spans. By default, @vercel/otel configures relevant Vercel attributes based on the environment, including:

  • service.name - the service name.
  • node.env - the value of NODE_ENV environment variable.
  • deployment.environment.name - the Vercel deployment environment.
  • cloud.region - the Vercel deployment region.
  • process.runtime.name - the runtime when the SDK can determine it, such as "nodejs" or "edge".
  • vcs.ref.head.name - the Vercel Git ref when available.
  • vcs.ref.head.revision - the Vercel Git SHA.
  • vcs.repository.name - the Vercel repository slug when available.
  • deployment.id - the Vercel deployment ID.
  • service.version - the Vercel deployment ID.
  • legacy compatibility aliases such as env and vercel.*.
  • env - the Vercel deployment environment such as "production" or "preview" (VERCEL_ENV environment variable).
  • vercel.region - the Vercel deployment region (VERCEL_REGION environment variable).
  • vercel.runtime - "nodejs" or "edge" (NEXT_RUNTIME environment variable).
  • vercel.sha - the Vercel deployment Git SHA (VERCEL_GIT_COMMIT_SHA environment variable).
  • vercel.host - the Vercel deployment host for the Git SHA (VERCEL_URL environment variable).
  • vercel.branch_host - the Vercel deployment host for the branch (VERCEL_BRANCH_URL environment variable).
  • vercel.deployment_id - the Vercel deployment ID (VERCEL_DEPLOYMENT_ID environment variable).

Any additional attributes will be merged with the default attributes.

attributesFromHeaders?: AttributesFromHeaders

This configuration is used to compute root span's attributes based on the request's headers. The value can be one of the following:

  • A map with keys as attribute names and values as header names. An attribute would only be created if the specified header exists.
  • A function that can take an opaque headers object with the getter callback, and returns a set of computed attributes.
autoDetectResources?: boolean
contextManager?: ContextManager
idGenerator?: IdGenerator
instrumentationConfig?: InstrumentationConfiguration

Customize configuration for predefined instrumentations:

instrumentations?: InstrumentationOptionOrName[]

A set of instrumentations. By default, @vercel/otel configures "fetch" instrumentation.

logRecordProcessors?: LogRecordProcessor[]
metricReaders?: MetricReader[]
propagators?: PropagatorOrName[]

A set of propagators that may extend inbound and outbound contexts. Use the "auto" value to include all default propagators. By default, @vercel/otel configures W3C Trace Context propagator. This option can be also configured via the OTEL_PROPAGATORS environment variable.

Example: { propagators: ["auto", new MyPropagator()] }

resourceDetectors?: ResourceDetector[]
serviceName?: string

The name of your service, used as the app name in many OpenTelemetry backends. Can be overriden by the OTEL_SERVICE_NAME environment variable.

spanLimits?: SpanLimits
spanProcessors?: SpanProcessorOrName[]

A set of span processors to be used to process captured spans. Use the "auto" value to include all default span processors. By default, @vercel/otel auto-configures an export processor based on the environment. See traceExporter for more details.

traceExporter?: SpanExporterOrName

A custom exporter for traces. Use the "auto" value to include the best export mechanism for the environment. By default, @vercel/otel configures the best export mechanism for the environment. For instance, if a tracing integrations is configured on Vercel, this integration will be automatically used for export; otherwise an OTLP exporter can be used if configured via environment variables, such as OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL and OTEL_EXPORTER_OTLP_HEADERS.

traceSampler?: SampleOrName

The sampler to be used to decide which requests should be traced. Use the "auto" value to use the default sampler. By default, all requests are traced. This option can be changed to, for instance, only trace 1% of all requests. This option can also be configured via the OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG environment variable.

views?: ViewOptions[]