Repository navigation
fix(opentelemetry): export OTEL_* variables to NGINX workers - #1618
Open
vedantikapatil wants to merge 1 commit into
Open
vedantikapatil wants to merge 1 commit into
vedantikapatil wants to merge 1 commit into
Conversation
NGINX replaces the environment of its worker processes, so only variables declared with the `env` directive survive the fork. The OpenTelemetry module resolves some of its settings in the worker (`OtelNgxStart` -> `Resource::Create` and the OTLP exporter), which meant OTEL_RESOURCE_ATTRIBUTES and OTEL_EXPORTER_OTLP_HEADERS were always read from an empty environment and silently ignored. Declare every OTEL_* variable found in the environment with the `env` directive when OpenTelemetry is enabled. Only the names are emitted, so credentials in OTEL_EXPORTER_OTLP_HEADERS are not written to the rendered nginx.conf. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
vedantikapatil
force-pushed
the
fix/1427-otel-env-vars
branch
from
December 4, 2026 14:19
424bc24 to
7cb5677
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Link: #1427
NGINX replaces the environment of its worker processes, so only variables
declared with the
envdirective survive the fork. The OpenTelemetry moduleresolves
OTEL_RESOURCE_ATTRIBUTESandOTEL_EXPORTER_OTLP_HEADERSin theworker (
OtelNgxStart→Resource::Create/OtlpGrpcExporter), so both werealways read from an empty environment and silently ignored.
This declares every
OTEL_*variable found in the environment whenOpenTelemetry is enabled. Only names are emitted, so the token in
OTEL_EXPORTER_OTLP_HEADERSis not written into the renderednginx.conf.OTEL_EXPORTER_OTLP_ENDPOINTandOTEL_SERVICE_NAMEwere unaffected — thoseare read at config-parse time in the master.
Verification steps
OTEL_RESOURCE_ATTRIBUTES=deployment.environment=dev-environmentoninclude
deployment.environment=dev-environment. Onmasterthat tag is absent.Unit coverage in
spec/cli/nginx_conf_spec.lua(make busted).Note
The issue also reports the parent TraceId being lost. That is
open-telemetry/opentelemetry-cpp-contrib#143 and needs a module bump, not a
config change —
opentelemetry_propagateis already set. Consider keeping #1427open for that half.