Skip to content

Add host metadata challenges demo: multi-pipeline OTel setup - #213

Open
IbraheemA wants to merge 1 commit into
mainfrom
hostmetadata-challenges
Open

Add host metadata challenges demo: multi-pipeline OTel setup#213
IbraheemA wants to merge 1 commit into
mainfrom
hostmetadata-challenges

Conversation

@IbraheemA

Copy link
Copy Markdown
Contributor

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.

What does this PR do?

Motivation

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>
@IbraheemA
IbraheemA requested a review from a team as a code owner April 9, 2026 19:53
@IbraheemA
IbraheemA requested a review from mx-psi April 9, 2026 19:53
@@ -0,0 +1,11 @@
FROM golang:1.22-alpine AS builder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 😄

Comment on lines +21 to +29
endpoint := os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
if endpoint == "" {
endpoint = "localhost:4317"
}

exporter, err := otlptracegrpc.New(context.Background(),
otlptracegrpc.WithEndpoint(endpoint),
otlptracegrpc.WithInsecure(),
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think oteltracegrpc already supports this env variable, see https://pkg.go.dev/go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc#pkg-overview

Suggested change
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")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just use tp to avoid relying on global state

Suggested change
tracer := otel.Tracer("trace-generator")
tracer := tp.Tracer("trace-generator")

sdktrace.WithBatcher(exporter),
sdktrace.WithResource(res),
)
otel.SetTracerProvider(tp)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed if you apply my last suggestion I think

Suggested change
otel.SetTracerProvider(tp)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure we could use telemetrygen for this but I'll leave that choice up to you

Comment on lines +83 to +89
processors: [k8sattributes, batch]
exporters: [otlp]
# Host metrics with host-level resource attributes
metrics:
receivers: [hostmetrics]
processors: [batch]
exporters: [otlp]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continuation of previous-to-last comment

Suggested change
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']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +36 to +38
processors:
batch:
timeout: 10s

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
processors:
batch:
timeout: 10s

# App traces forwarded from DaemonSet agents (carry k8s.* attributes)
traces:
receivers: [otlp]
processors: [batch]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
processors: [batch]

# AND kube-state-metrics scraped by the Prometheus receiver (carry k8s object-state labels)
metrics:
receivers: [otlp, prometheus]
processors: [batch]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
processors: [batch]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants