feat: add distributed tracing (Jaeger) to local-setup#922
feat: add distributed tracing (Jaeger) to local-setup#922
Conversation
Signed-off-by: Alexander Cristurean <acristur@redhat.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Jaeger tracing documentation and wiring for local environments: new docs, Makefile variables and targets to configure Istio and Kuadrant for OTLP/Jaeger, updated local-setup flow to conditionally deploy and configure tracing, and testsuite/tools configuration changes to use a configurable namespace and collector endpoint. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer (make)
participant Kube as Kubernetes API
participant Istio as Istio control plane
participant Kuadrant as Kuadrant operator / CR
participant Jaeger as Jaeger collector/query
Dev->>Kube: run `make local-setup` (INSTALL_TRACING=true)
Note right of Dev: create tools namespace & install test tools
Dev->>Kube: apply `configure-istio-tracing` (if GATEWAYAPI_PROVIDER=istio)
Kube->>Istio: patch Istio CR (enable tracing, add extensionProvider)
Dev->>Kube: apply Telemetry resource -> Istio
Dev->>Kube: run `configure-kuadrant-tracing-operator`
Kube->>Kuadrant: patch operator Deployment (OTEL env vars)
Dev->>Kube: run `configure-kuadrant-tracing-cr`
Kube->>Kuadrant: patch kuadrant-sample CR (observability.tracing.defaultEndpoint)
Kuadrant->>Jaeger: emit OTLP traces to `JAEGER_COLLECTOR_ENDPOINT`
Dev->>Jaeger: access Jaeger UI via `kubectl port-forward` (per docs)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
make/istio.mk (1)
35-36: Consider extracting the complex JSON patch for maintainability.The single-line
kubectl patchcommand at line 36 is very long and difficult to read or modify. Consider using a heredoc or external JSON file to improve maintainability.Suggested refactor using heredoc
`@echo` "Configuring Istio for tracing with Jaeger..." @# Patch Istio CR to add tracing extension provider and JSON access logs - `@kubectl` patch istio default -n istio-system --type=merge -p '{"spec":{"values":{"meshConfig":{"accessLogFile":"/dev/stdout","accessLogEncoding":"JSON","accessLogFormat":"{\"start_time\":\"%START_TIME%\",\"method\":\"%REQ(:METHOD)%\",\"path\":\"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%\",\"protocol\":\"%PROTOCOL%\",\"response_code\":\"%RESPONSE_CODE%\",\"response_flags\":\"%RESPONSE_FLAGS%\",\"bytes_received\":\"%BYTES_RECEIVED%\",\"bytes_sent\":\"%BYTES_SENT%\",\"duration\":\"%DURATION%\",\"upstream_service_time\":\"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%\",\"x_forwarded_for\":\"%REQ(X-FORWARDED-FOR)%\",\"user_agent\":\"%REQ(USER-AGENT)%\",\"request_id\":\"%REQ(X-REQUEST-ID)%\",\"authority\":\"%REQ(:AUTHORITY)%\",\"upstream_host\":\"%UPSTREAM_HOST%\",\"upstream_cluster\":\"%UPSTREAM_CLUSTER%\",\"route_name\":\"%ROUTE_NAME%\"}","enableTracing":true,"defaultConfig":{"tracing":{}},"extensionProviders":[{"name":"jaeger-otlp","opentelemetry":{"port":4317,"service":"jaeger-collector.$(TOOLS_NAMESPACE).svc.cluster.local"}}]}}}}' + `@kubectl` patch istio default -n istio-system --type=merge -p "$$( \ + cat <<-EOF + { + "spec": { + "values": { + "meshConfig": { + "accessLogFile": "/dev/stdout", + "accessLogEncoding": "JSON", + "enableTracing": true, + "defaultConfig": {"tracing": {}}, + "extensionProviders": [{ + "name": "jaeger-otlp", + "opentelemetry": { + "port": 4317, + "service": "jaeger-collector.$(TOOLS_NAMESPACE).svc.cluster.local" + } + }] + } + } + } + } + EOF + )"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@make/istio.mk` around lines 35 - 36, The long single-line kubectl patch command (the line invoking "kubectl patch istio default -n istio-system --type=merge -p") embeds a large JSON payload (including keys like accessLogFile, accessLogEncoding, accessLogFormat, enableTracing, defaultConfig.tracing, and extensionProviders) which is hard to read and maintain; extract that JSON into a separate, well-formatted artifact (either a checked-in JSON/YAML file or a heredoc block) and update the kubectl invocation to read the payload from that source (e.g., pass the file contents or heredoc output into the -p argument), ensuring the accessLogFormat and extensionProviders JSON remains valid and quoting is preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CLAUDE.md`:
- Around line 78-81: The docs and implementation disagree on Jaeger OTLP port:
update either the documentation text or the default JAEGER_COLLECTOR_ENDPOINT so
they match; specifically, change the documentation line that claims traces are
sent to port 4318 to reflect port 4317, or change the default value of
JAEGER_COLLECTOR_ENDPOINT (in make/vars.mk) to use 4318 if you intend to use
OTLP/HTTP. Locate the symbol JAEGER_COLLECTOR_ENDPOINT and the doc text
"Operator sends traces to jaeger-collector.tools.svc.cluster.local:4318" and
make them consistent (pick 4317 for OTLP/gRPC or 4318 for OTLP/HTTP) and update
any related README/CLAUDE.md references accordingly.
In `@make/vars.mk`:
- Around line 42-44: The JAEGER_COLLECTOR_ENDPOINT default uses an unsupported
"rpc://" scheme; update the JAEGER_COLLECTOR_ENDPOINT variable to use an http or
https scheme (e.g., change JAEGER_COLLECTOR_ENDPOINT ?= rpc://... to
JAEGER_COLLECTOR_ENDPOINT ?=
http://jaeger-collector.$(TOOLS_NAMESPACE).svc.cluster.local:4317) so the
OpenTelemetry OTLP exporter accepts the endpoint; ensure any related logic that
reads JAEGER_COLLECTOR_ENDPOINT continues to work with the http/https URL.
---
Nitpick comments:
In `@make/istio.mk`:
- Around line 35-36: The long single-line kubectl patch command (the line
invoking "kubectl patch istio default -n istio-system --type=merge -p") embeds a
large JSON payload (including keys like accessLogFile, accessLogEncoding,
accessLogFormat, enableTracing, defaultConfig.tracing, and extensionProviders)
which is hard to read and maintain; extract that JSON into a separate,
well-formatted artifact (either a checked-in JSON/YAML file or a heredoc block)
and update the kubectl invocation to read the payload from that source (e.g.,
pass the file contents or heredoc output into the -p argument), ensuring the
accessLogFormat and extensionProviders JSON remains valid and quoting is
preserved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0131b018-c2a7-4ee2-8208-4a58fbca094a
📒 Files selected for processing (7)
CLAUDE.mdconfig/settings.local.yaml.tplmake/istio.mkmake/kuadrant.mkmake/local-setup.mkmake/tools.mkmake/vars.mk
Signed-off-by: Alexander Cristurean <acristur@redhat.com>
Signed-off-by: Alexander Cristurean <acristur@redhat.com>
Summary
Implements #907 - Adds complete distributed tracing configuration to
make local-setupfor debugging control plane (operator) and data plane (gateway) flows locally.Changes
1. Infrastructure Setup
Tools namespace (
make/tools.mk):TOOLS_NAMESPACEvariable (default:tools)--namespace $(TOOLS_NAMESPACE)Tracing variables (
make/vars.mk):2. Control Plane Tracing (kuadrant-operator)
New target (
make/kuadrant.mk):configure-kuadrant-tracing-operatorOTEL_EXPORTER_OTLP_ENDPOINT=rpc://jaeger-collector.tools.svc.cluster.local:4317OTEL_EXPORTER_OTLP_INSECURE=trueLOG_LEVEL=debug3. Data Plane Tracing (gateway/envoy)
New target (
make/kuadrant.mk):configure-kuadrant-tracing-cr4. Istio Observability Configuration
New target (
make/istio.mk):configure-istio-tracingTelemetryresource with 100% sampling rateAccess log format includes:
5. Deployment Flow
Updated (
make/local-setup.mk):Key improvement: Tracing configuration happens AFTER Jaeger is deployed (no broken references)
6. Configuration & Documentation
Settings template (
config/settings.local.yaml.tpl):Documentation (
CLAUDE.md):Test Plan
Verify OTEL env vars on operator
Verify Kuadrant CR tracing config
Verify Istio tracing config
Run tracing tests
Access Jaeger UI
Expected Impact
Before:
After:
Configuration Options
Enable (default):
make local-setup # Tracing enabled by defaultDisable:
Custom tools namespace:
Technical Details
Endpoints:
rpc://jaeger-collector.tools.svc.cluster.local:4317(OTLP)http://jaeger-query.tools.svc.cluster.local:80Tracing components:
kuadrant-olm/tools-instancesHelm chartSampling:
randomSamplingPercentage: 100)Related
deploy-testsuite-tools🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Chores