http-otel #

Sends OpenTelemetry traces from nginx to a collector over OTLP/gRPC and passes W3C trace context on to the backend. Use it to see nginx as one span in a distributed trace, next to your application.

Source: upstream source

Directives

batch_count #

syntax: batch_count 1 arg (size (k/m/g));

Size in bytes; accepts k / m / g suffixes.

batch_size #

syntax: batch_size 1 arg (size (k/m/g));

Size in bytes; accepts k / m / g suffixes.

endpoint #

syntax: endpoint 1 arg (string);

Stores a single string value.

interval #

syntax: interval 1 arg (duration in ms);

Duration in milliseconds; accepts ms / s / m suffixes.

otel_service_name #

syntax: otel_service_name 1 arg (string);  ·  context: http

Stores a single string value.

otel_span_attr #

syntax: otel_span_attr 2 args;  ·  context: http, server, location

Adds a custom OpenTelemetry span attribute whose value may reference variables.

otel_span_name #

syntax: otel_span_name 1 arg;  ·  context: http, server, location

Sets the OpenTelemetry span name, defaulting to the matched location's name.

otel_trace #

syntax: otel_trace 1 arg;  ·  context: http, server, location

Enables or disables OpenTelemetry tracing for the current context.

otel_trace_context #

syntax: otel_trace_context 1 arg (enum);  ·  context: http, server, location

Pick one of an enumerated set of values.

Example

http {
    # trace 10% of requests
    split_clients $otel_trace_id $ratio_sampler {
        10%     on;
        *       off;
    }

    # or we can trace 10% of user sessions
    split_clients $cookie_sessionid $session_sampler {
        10%     on;
        *       off;
    }

    server {
        location / {
            otel_trace $ratio_sampler;
            otel_trace_context inject;

            proxy_pass http://backend;
        }
    }
}

↑ back to index