Skip to content

docs(observability): document OpenTelemetry tracing config - #459

Merged
edenreich merged 1 commit into
mainfrom
docs/issue-457-20260722-1402
Jul 22, 2026
Merged

edenreich merged 1 commit into
mainfrom
docs/issue-457-20260722-1402

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Summary

Documents the two new tracing env vars added by inference-gateway/inference-gateway#483 (closes inference-gateway/inference-gateway#450).

  • configuration.md: added TELEMETRY_TRACING_ENABLE (default false) and TELEMETRY_TRACING_OTLP_ENDPOINT (default http://localhost:4318) to the Telemetry settings table and the complete-config example, and clarified that tracing is a separate opt-in from metrics.
  • observability.md: expanded the Distributed Tracing section to reflect the two-flag opt-in, and added subsections for:
    • Span coverage - root spans on all routes except /health and /v1/metrics; gen_ai provider/model attributes on /v1/chat/completions and /v1/messages; one child span per MCP tool execution.
    • Context propagation - W3C traceparent honored inbound; carried outbound on provider, proxy, and MCP requests.
    • Sampling and exporter tuning via the standard OTEL_TRACES_SAMPLER / OTEL_EXPORTER_OTLP_* env vars.
    • Updated the 'Traces missing' troubleshooting entry and the Jaeger endpoint reference.

Acceptance criteria:

  • Both env vars documented with defaults
  • Tracing behavior (span coverage, propagation, excluded routes) described on the observability page
  • Note that sampling/exporter tuning uses standard OTEL_* env vars

lint:md, format:check, and build all pass locally.

Closes #457

Document TELEMETRY_TRACING_ENABLE and TELEMETRY_TRACING_OTLP_ENDPOINT
in the configuration reference, and expand the Distributed Tracing
section with span coverage, W3C context propagation, excluded routes,
and standard OTEL_* sampling/exporter tuning.

Closes #457
@edenreich

Copy link
Copy Markdown
Contributor

@claude Can you check if the environment variables are actually relevant with the current state of the operator?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 3m 56s —— View job


Checking tracing env vars against the operator

  • Read the PR changes (tracing env vars documented)
  • Inspect the operator's current state (CRD + env var rendering for telemetry)
  • Determine whether TELEMETRY_TRACING_ENABLE / TELEMETRY_TRACING_OTLP_ENDPOINT are relevant to the operator
  • Report findings

Verdict

This PR's docs are correct - merge as-is. But I found a real mismatch in the operator that you'll want to fix separately.

1. The documented names match the gateway binary ✅

The gateway reads these via sethvargo/go-envconfig with the telemetry block nested under a TELEMETRY_ prefix (inference-gateway config/config.go):

Telemetry *TelemetryConfig `env:", prefix=TELEMETRY_"`
// ...
TracingEnable       bool   `env:"TRACING_ENABLE, default=false"`        // -> TELEMETRY_TRACING_ENABLE
TracingOtlpEndpoint string `env:"TRACING_OTLP_ENDPOINT, default=http://localhost:4318"` // -> TELEMETRY_TRACING_OTLP_ENDPOINT

So the composed names are exactly TELEMETRY_TRACING_ENABLE and TELEMETRY_TRACING_OTLP_ENDPOINT (also confirmed in the gateway's own Configurations.md). The defaults in this PR (false, http://localhost:4318) are right too. These vars are relevant for direct / docker-compose / Helm / bare-binary deploys.

2. Operator users don't set these raw vars - they use the CRD

With the operator, tracing is configured through the Gateway CR, not raw env vars:

spec:
  telemetry:
    enabled: true
    traces:
      exporter:
        otlp:
          endpoint: http://otel-collector:4318
          protocol: http/protobuf

The operator translates that into env vars on the gateway pod. That translation layer is expected - no need to document raw env vars for operator users on this page.

3. ⚠️ The operator emits the WRONG env var names (real bug)

inference-gateway/operator internal/controller/gateway_controller.go:466-472:

tel := gateway.Spec.Telemetry
if tel != nil && tel.Enabled && tel.Traces != nil && tel.Traces.Exporter != nil && tel.Traces.Exporter.OTLP != nil {
    otlp := tel.Traces.Exporter.OTLP
    envVars = append(envVars, corev1.EnvVar{Name: "TRACING_ENABLE", Value: "true"})           // <- missing TELEMETRY_ prefix
    if otlp.Endpoint != "" {
        envVars = append(envVars, corev1.EnvVar{Name: "TRACING_OTLP_ENDPOINT", Value: otlp.Endpoint}) // <- missing TELEMETRY_ prefix
    }
}

It sets TRACING_ENABLE / TRACING_OTLP_ENDPOINT, but the gateway binary only reads TELEMETRY_TRACING_ENABLE / TELEMETRY_TRACING_OTLP_ENDPOINT. Result: tracing configured through the operator CR silently never reaches the gateway. Note the inconsistency in the same file - the master switch at line 457 is correctly TELEMETRY_ENABLE (prefix included), only the two tracing vars drop the prefix.

Timeline confirms it's stale, not intentional: gateway #483 merged today at 12:31 UTC (nesting tracing under the TELEMETRY_ prefix); operator #169 merged today at 14:17 UTC with the message "matching what the gateway binary reads" - but it was written against the pre-#483 (un-prefixed) layout.

Recommendation

  • Merge this docs PR - it's accurate for the gateway.
  • Fix the operator: rename the two emitted vars to TELEMETRY_TRACING_ENABLE / TELEMETRY_TRACING_OTLP_ENDPOINT in gateway_controller.go:469,471 (and update the corresponding gateway_controller_test.go assertions).

Want me to open a bug issue in inference-gateway/operator with these details? I'll do it on your go-ahead.

@edenreich
edenreich merged commit 60a2cc2 into main Jul 22, 2026
1 check passed
@edenreich
edenreich deleted the docs/issue-457-20260722-1402 branch July 22, 2026 14:31
inference-gateway-releaser Bot added a commit that referenced this pull request Jul 22, 2026
## [0.9.3](0.9.2...0.9.3) (2026-07-22)

### 🐛 Bug Fixes

* **configuration:** update Z-AI API URL to match canonical schema ([#443](#443)) ([2ad9f95](2ad9f95))

### 📚 Documentation

* **api-reference:** document community context-window fallback ([#450](#450)) ([be74471](be74471))
* **api-reference:** document community pricing fallback ([#449](#449)) ([3504c8f](3504c8f))
* **api-reference:** document context_window resolution for GET /v1/models include param ([#445](#445)) ([ca01a1b](ca01a1b))
* **api-reference:** document include query parameter on GET /v1/models ([#442](#442)) ([566dd19](566dd19))
* **api-reference:** document include=pricing model pricing metadata on GET /v1/models ([#446](#446)) ([88f0573](88f0573))
* **api-reference:** document subscription field in pricing metadata ([#456](#456)) ([ae251c1](ae251c1))
* document llamacpp LLAMACPP_API_KEY bearer auth ([#437](#437)) ([c8cd256](c8cd256))
* **go-sdk:** document include=context_window on ListModels and ListProviderModels ([#452](#452)) ([ec3a520](ec3a520))
* **observability:** document tracing config env vars ([#459](#459)) ([60a2cc2](60a2cc2)), closes [#457](#457)
* **operator:** add GPU CRD reference page with spec, status, lifecycle, and Gateway consumption example ([#458](#458)) ([39c66e7](39c66e7))
* **operator:** add keyless Llamacpp Gateway CR example ([#431](#431)) ([2937e3c](2937e3c))
* **operator:** note llamacpp requires operator v0.19.0+ ([#433](#433)) ([eca2735](eca2735))
* **typescript-adk:** PascalCase MessageRole enum members ([#427](#427)) ([23d43bc](23d43bc))
* **typescript-sdk:** document listModels include parameter and model metadata fields ([#454](#454)) ([a0cfd8b](a0cfd8b))

### 🔧 Miscellaneous

* **deps-dev:** bump the bun group with 2 updates ([#435](#435)) ([cc8f36c](cc8f36c))
* **deps:** bump actions/setup-node in the github-actions group ([#434](#434)) ([53324e0](53324e0))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.9.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DOCS] Document OpenTelemetry tracing configuration (TELEMETRY_TRACING_ENABLE) [FEATURE] Add OpenTelemetry tracing spans across gateway call paths

1 participant