Add host metadata challenges demo: multi-pipeline OTel setup - #213
Add host metadata challenges demo: multi-pipeline OTel setup#213IbraheemA wants to merge 1 commit into
Conversation
Demonstrates how a standard Kubernetes OTel deployment (DaemonSet agent + Deployment gateway) produces three independent OTLP payload shapes — each carrying a different slice of host/workload identity: 1. App traces with k8s.* workload attributes (from k8sattributes processor) 2. Host metrics with host.* attributes (from hostmetrics receiver) 3. kube-state-metrics with Kubernetes object-state labels (from Prometheus scrape) Includes a Go trace-generator app, agent/gateway collector configs, kube-state-metrics deployment, Makefile for kind cluster setup, and a detailed README explaining exactly how and why the separation occurs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| @@ -0,0 +1,11 @@ | |||
| FROM golang:1.22-alpine AS builder | |||
There was a problem hiding this comment.
I think if we merge this we will immediately get a PR to update this Go version so we may as well upgrade it here 😄
| endpoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") | ||
| if endpoint == "" { | ||
| endpoint = "localhost:4317" | ||
| } | ||
|
|
||
| exporter, err := otlptracegrpc.New(context.Background(), | ||
| otlptracegrpc.WithEndpoint(endpoint), | ||
| otlptracegrpc.WithInsecure(), | ||
| ) |
There was a problem hiding this comment.
I think oteltracegrpc already supports this env variable, see https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc#pkg-overview
| endpoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") | |
| if endpoint == "" { | |
| endpoint = "localhost:4317" | |
| } | |
| exporter, err := otlptracegrpc.New(context.Background(), | |
| otlptracegrpc.WithEndpoint(endpoint), | |
| otlptracegrpc.WithInsecure(), | |
| ) | |
| exporter, err := otlptracegrpc.New(context.Background(), | |
| otlptracegrpc.WithInsecure(), | |
| ) |
| } | ||
| defer func() { _ = tp.Shutdown(context.Background()) }() | ||
|
|
||
| tracer := otel.Tracer("trace-generator") |
There was a problem hiding this comment.
You could just use tp to avoid relying on global state
| tracer := otel.Tracer("trace-generator") | |
| tracer := tp.Tracer("trace-generator") |
| sdktrace.WithBatcher(exporter), | ||
| sdktrace.WithResource(res), | ||
| ) | ||
| otel.SetTracerProvider(tp) |
There was a problem hiding this comment.
Not needed if you apply my last suggestion I think
| otel.SetTracerProvider(tp) |
There was a problem hiding this comment.
I am pretty sure we could use telemetrygen for this but I'll leave that choice up to you
| processors: [k8sattributes, batch] | ||
| exporters: [otlp] | ||
| # Host metrics with host-level resource attributes | ||
| metrics: | ||
| receivers: [hostmetrics] | ||
| processors: [batch] | ||
| exporters: [otlp] |
There was a problem hiding this comment.
Continuation of previous-to-last comment
| processors: [k8sattributes, batch] | |
| exporters: [otlp] | |
| # Host metrics with host-level resource attributes | |
| metrics: | |
| receivers: [hostmetrics] | |
| processors: [batch] | |
| exporters: [otlp] | |
| processors: [k8sattributes] | |
| exporters: [otlp] | |
| # Host metrics with host-level resource attributes | |
| metrics: | |
| receivers: [hostmetrics] | |
| exporters: [otlp] |
| - job_name: 'kube-state-metrics' | ||
| scrape_interval: 15s | ||
| static_configs: | ||
| - targets: ['kube-state-metrics.otel-multi-pipeline-demo.svc.cluster.local:8080'] |
There was a problem hiding this comment.
No strong opinion on this but we could use https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/k8sclusterreceiver instead
| processors: | ||
| batch: | ||
| timeout: 10s |
There was a problem hiding this comment.
| processors: | |
| batch: | |
| timeout: 10s |
| # App traces forwarded from DaemonSet agents (carry k8s.* attributes) | ||
| traces: | ||
| receivers: [otlp] | ||
| processors: [batch] |
There was a problem hiding this comment.
| processors: [batch] |
| # AND kube-state-metrics scraped by the Prometheus receiver (carry k8s object-state labels) | ||
| metrics: | ||
| receivers: [otlp, prometheus] | ||
| processors: [batch] |
There was a problem hiding this comment.
| processors: [batch] |
Demonstrates how a standard Kubernetes OTel deployment (DaemonSet agent + Deployment gateway) produces three independent OTLP payload shapes — each carrying a different slice of host/workload identity:
Includes a Go trace-generator app, agent/gateway collector configs, kube-state-metrics deployment, Makefile for kind cluster setup, and a detailed README explaining exactly how and why the separation occurs.
What does this PR do?
Motivation