Otel Collector Trace Collection
kf-agent is a Kubernetes-native collector that receives spans from OTel SDK-instrumented applications over OTLP and forwards them to the Kloudfuse ingester.
Applications send spans to kf-agent over the cluster-internal network; no direct internet access from application pods is required.
Overview
kf-agent runs as a Kubernetes Deployment and exposes two OTLP endpoints:
| Port | Protocol | Endpoint |
|---|---|---|
|
OTLP/gRPC |
|
|
OTLP/HTTP (Protobuf) |
Replace <namespace> with the namespace where kf-agent is deployed (typically kloudfuse).
All spans received by kf-agent are forwarded to the Kloudfuse ingester over HTTPS.
kf-agent buffers and compresses spans in transit, reducing the number of outbound connections from your cluster.
For agent installation and Helm configuration, see OTel Kubernetes Integration. This page focuses on configuring applications to send spans to a running agent.
Prerequisites
Before you begin, ensure the following requirements are in place:
| Requirement | Details |
|---|---|
|
|
OpenTelemetry SDK |
Applications instrumented with an OpenTelemetry SDK. See the language guides under APM Instrumentation for SDK setup. |
Configure Applications to Send Traces
Environment Variables
Configure every application pod with the following environment variables:
| Variable | Value |
|---|---|
|
|
|
|
|
A stable logical name for your service (e.g., |
|
|
OTEL_SERVICE_NAME determines how the service appears in APM views and the service map.
Use a stable, consistent name — avoid pod names or hostnames.
Kubernetes Pod Spec
env:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://kf-agent.kloudfuse:4317"
- name: OTEL_SERVICE_NAME
value: payments-api
- name: OTEL_RESOURCE_ATTRIBUTES
value: "service.namespace=payments,deployment.environment.name=production"
If your application namespace is isolated by a NetworkPolicy, you may need an egress rule to allow traffic to kf-agent — see NetworkPolicy.
gRPC vs HTTP
Most OTel SDKs default to gRPC on port 4317.
Use HTTP on port 4318 if your language SDK or runtime does not support gRPC, or if your network blocks gRPC:
env:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://kf-agent.kloudfuse:4318"
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: "http/protobuf"
The SDK appends /v1/traces automatically when using the HTTP exporter — do not include it in the endpoint value.
Language-Specific Notes
The environment variables above work for Java, Python, and Go without additional code changes when the SDK is configured to read from the environment.
Java (auto-instrumentation agent) — the Java agent reads all OTEL_* variables automatically.
Attach the agent with:
env:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/agent/opentelemetry-javaagent.jar"
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: "http://kf-agent.kloudfuse:4317"
- name: OTEL_SERVICE_NAME
value: payments-api
Python (auto-instrumentation) — wrap the application command with opentelemetry-instrument:
command: ["opentelemetry-instrument", "python", "app.py"]
Then set OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_SERVICE_NAME as environment variables on the container.
Go (manual SDK) — initialize the SDK from environment variables using autoconf:
import "go.opentelemetry.io/contrib/exporters/autoexport"
import "go.opentelemetry.io/otel/sdk/trace"
exp, _ := autoexport.NewSpanExporter(ctx)
tp := sdktrace.NewTracerProvider(sdktrace.WithBatcher(exp))
otel.SetTracerProvider(tp)
autoexport reads OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_PROTOCOL automatically.
Alternatively, configure the exporter explicitly — see APM Go Instrumentation.
NetworkPolicy
If your cluster enforces NetworkPolicy, add an egress rule to each application namespace that allows outbound traffic to kf-agent on ports 4317 and 4318:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-kf-agent-traces
namespace: <app-namespace>
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- ports:
- protocol: TCP
port: 4317
- protocol: TCP
port: 4318
If kf-agent is in a different namespace, also add the namespaceSelector:
- ports:
- protocol: TCP
port: 4317
- protocol: TCP
port: 4318
to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kloudfuse
Verify Traces Are Arriving
-
Confirm
kf-agentis running and listening:kubectl get pods -n kloudfuse -l app=kf-agent kubectl exec -it <app-pod> -- nc -zv kf-agent.kloudfuse 4317 -
Generate traffic through your application — make a request to an instrumented endpoint.
-
In the Kloudfuse UI, click APM in the top navigation.
-
Select Services from the drop-down and set the time range to the last 15 minutes.
-
Your service name (from
OTEL_SERVICE_NAME) should appear. Click it, then select the Traces tab to see individual trace records.
Troubleshooting
Connection Refused to kf-agent
If nc -zv kf-agent.kloudfuse 4317 fails:
-
Confirm
kf-agentpods are running:kubectl get pods -n kloudfuse -l app=kf-agent -
Confirm the
kf-agentService exists and targets the correct port:kubectl get svc -n kloudfuse kf-agent -
Check whether a
NetworkPolicyin the application namespace blocks egress on port 4317. Add the egress rule from NetworkPolicy if needed. -
Verify the DNS name resolves from inside the application pod:
kubectl exec -it <app-pod> -- nslookup kf-agent.kloudfuse
Spans Not Appearing in Kloudfuse
If kf-agent is reachable but traces do not appear:
-
Enable SDK debug logging to see export attempts and errors:
SDK Debug flag Java agent
-Dotel.javaagent.debug=truePython
OTEL_LOG_LEVEL=debugGo
Log any errors returned from
tp.Shutdown(ctx)and from the exporter initialization -
Check
kf-agentlogs for export errors:kubectl logs -n kloudfuse -l app=kf-agent | grep -i "error\|warn\|failed" -
Confirm
OTEL_SERVICE_NAMEis set — without it the SDK defaults tounknown_service:<binary>. -
Confirm the endpoint does not include a path suffix —
http://kf-agent.kloudfuse:4317is correct;http://kf-agent.kloudfuse:4317/v1/tracesis not (gRPC uses no path).
Wrong Protocol (gRPC vs HTTP)
Symptoms: HTTP 415 Unsupported Media Type or HTTP 405 Method Not Allowed in SDK logs.
-
Port
4317accepts gRPC only. -
Port
4318accepts HTTP/Protobuf only.
Match the SDK exporter type to the port:
# gRPC (default for most SDKs)
OTEL_EXPORTER_OTLP_ENDPOINT=http://kf-agent.kloudfuse:4317
# HTTP
OTEL_EXPORTER_OTLP_ENDPOINT=http://kf-agent.kloudfuse:4318
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
Partial or Broken Traces (Orphan Spans)
Orphan spans (spans with no parent in the UI) indicate that context propagation between services is broken.
-
Confirm all services in the call chain are using W3C TraceContext propagation (
OTEL_PROPAGATORS=tracecontext,baggage). -
Confirm outbound HTTP or gRPC calls pass the propagated headers — this is handled automatically by instrumentation libraries (
otelhttp,otelgrpc) but requires explicit header injection for manual HTTP clients.
See Partial or Broken Traces for language-specific fixes.
Spans Dropped Under Load
Symptoms: traces appear complete at low throughput but are missing spans under high load; SDK logs show BatchSpanProcessor queue is full.
Increase the queue and batch sizes:
OTEL_BSP_MAX_QUEUE_SIZE=8192
OTEL_BSP_MAX_EXPORT_BATCH_SIZE=1024
OTEL_EXPORTER_OTLP_COMPRESSION=gzip
If drops persist after tuning the BSP, add tail-based sampling at the kf-agent level using the Tail Sampling Processor in the agent configuration.
Contact Kloudfuse support to enable this in the managed kf-agent configuration.
Authentication Errors (401 / 403)
If kf-agent logs show 401 Unauthorized or 403 Forbidden on the outbound ingester request:
-
Confirm the API key in the
kf-agentHelm values matches an active key in Kloudfuse under Administration → API Keys. -
The API key is set at the agent level, not the application level — application pods do not need to pass API credentials.
-
If you recently rotated the key, update the
kf-agentHelm values and restart the agent pods.
External References
-
Tracing Architecture Integration — end-to-end tracing architecture
-
OTel Kubernetes Integration — kf-agent installation and Helm values
-
APM Go Instrumentation — Go SDK instrumentation
-
APM Java Instrumentation — Java SDK instrumentation
-
APM Python Instrumentation — Python SDK instrumentation
-
Common Setup Issues — Common APM setup issues