diff --git a/src/nxt_otel.c b/src/nxt_otel.c index eea12e24f..6fe3c9358 100644 --- a/src/nxt_otel.c +++ b/src/nxt_otel.c @@ -311,7 +311,7 @@ nxt_otel_test_and_call_state(nxt_task_t *task, nxt_http_request_t *r) void nxt_otel_request_error_path(nxt_task_t *task, nxt_http_request_t *r) { - if (r->otel->trace == NULL) { + if (r->otel == NULL || r->otel->trace == NULL) { return; } @@ -345,6 +345,11 @@ nxt_otel_parse_traceparent(void *ctx, nxt_http_field_t *field, uintptr_t data) r = ctx; + // opentelemetry unconfigured + if (r->otel == NULL) { + return NXT_OK; + } + if (field->value_length != NXT_OTEL_TRACEPARENT_LEN) { goto error_state; } @@ -391,6 +396,10 @@ nxt_otel_parse_tracestate(void *ctx, nxt_http_field_t *field, uintptr_t data) s.start = field->value; r = ctx; + if (r->otel == NULL) { + return NXT_OK; + } + r->otel->trace_state = s; /*