Skip to content

otel: send traces directly to otel-collector by default - #1031

Closed
marcleblanc2 wants to merge 1 commit into
mainfrom
marc/otel-agent-disabled-by-default
Closed

marcleblanc2 wants to merge 1 commit into
mainfrom
marc/otel-agent-disabled-by-default

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stop deploying the otel-agent DaemonSet by default. Application pods send traces straight to the otel-collector Service, like Docker Compose already does. Relates to FE-158 (DaemonSets blocked on shared clusters, hostPort clashes between instances on one cluster).

Why the agent isn't needed

  • Its whole config is OTLP in, otlp exporter out to otel-collector:4317, with a 100-batch sending_queue and retry_on_failure. The batch and memory_limiter processors are commented out as a TODO. It adds no processors or node metadata.
  • Sourcegraph services already batch spans (NewBatchSpanProcessor in internal/tracer/otel.go), and the OTLP exporter retries on its own.
  • Tracing defaults to selective sampling, so otel-collector (1 CPU / 1Gi requested) handles direct traffic easily.
  • It was added in Add otel-collector and make Jaeger optional #167 as the standard agent + gateway pattern, without a stated need. otel-agent: support Deployment kind, routing directly to existing otel-collector #863 added kind: Deployment to skip it.

Changes

  • New openTelemetry.agent.enabled (default false) deploys the agent.
  • openTelemetry.agent.kind is deprecated and removed from values.yaml. kind: DaemonSet still deploys the agent, and kind: Deployment matches the new default.
  • The otel-agent ConfigMap is now gated on the agent too. It was rendered even with kind: Deployment.

Upgrade impact

  • Default installs: Helm deletes the otel-agent DaemonSet and ConfigMap, and pods roll out with OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317.
  • Post-renderers that patch the otel-agent ConfigMap fail without the agent. Sourcegraph Cloud does this (controller internal/kubernetes/set-otel-agent-config.patch.yaml, and some instances in sourcegraph/cloud add a metrics pipeline to the agent). The controller must set openTelemetry.agent.enabled: true (or kind: DaemonSet) before Cloud picks up this chart version.
  • NetworkPolicies or meshes that allowed pod → node IP but not pod → otel-collector:4317 need a rule.

Checklist

Test plan

  • helm unittest charts/sourcegraph: 264 tests and 120 snapshots pass. The selector label golden snapshots are unchanged; suites that cover every workload enable the agent so they still cover the DaemonSet.
  • helm template diffs against main:
    • agent.enabled: true and kind: DaemonSet render byte-for-byte the same as the main default.
    • The new default renders the same as main with kind: Deployment, minus the orphaned otel-agent ConfigMap.
  • helm lint passes with and without the agent.
  • Tested on m5, a test instance on a shared EKS cluster with other Sourcegraph instances in other namespaces, and restricted Pod Security enforced. Release rev 94 was main (6315f79) with m5's values, and otel-agent was already broken there: 2 of 3 pods Pending (didn't have free ports for the requested pod ports), and the third rejected (violates PodSecurity "restricted:latest": hostPort).
    • Test-only values, passed last on both charts: openTelemetry.gateway.args makes the collector's OTLP receivers listen on 0.0.0.0 and the debug exporter log every span. Without them, the image's logging.yaml receivers listen on 127.0.0.1 and no span arrives with either chart. Site config had "observability.tracing": {"sampling": "all"} during each run. Traffic was 5 GraphQL searches, then spans logged by the collector were counted by service.name.
    • main + test values: 0 spans reached m5's collector. App pods sent to $(status.hostIP):4317, and from sourcegraph-frontend, worker, and searcher that port accepted TCP connections on both nodes they ran on, though m5 had no agent running. The hostPort listeners belong to other instances' agents, so m5's traces went into another instance's pipeline. I could not see which, as the test role has no access to the other namespaces. helm upgrade --wait also failed: DaemonSet/m5/otel-agent not ready ... Current: 2/3.
    • PR (012e869) + test values: helm diff showed only the expected changes: the otel-agent DaemonSet and ConfigMap removed, and OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317 replacing OTEL_AGENT_HOST in 8 containers of 7 workloads. helm upgrade --wait succeeded in 51 s, and all 19 pods were Running, none Pending. The collector logged 1079 spans from frontend, gitserver, searcher, worker, precise-code-intel-worker, and syntactic-code-intel-worker, at 3m CPU and 43Mi memory, with 0 errors in its log.
    • Not seen: spans from indexed-search (zoekt-webserver logs using OpenTelemetry tracer); none of the searches may have reached zoekt, and it sent none on main either.
    • Not tested on a cluster: openTelemetry.agent.enabled: true and kind: DaemonSet, which render identically to main (above), and an upgrade with a post-renderer patching the otel-agent ConfigMap.
    • m5 is restored: rev 98 is helm rollback to rev 94 (manifest identical to rev 94), and site config is back to its original contents.

Add openTelemetry.agent.enabled (default false) to deploy the otel-agent
DaemonSet, and stop rendering the otel-agent ConfigMap without it.
Application pods now send traces to the otel-collector Service by
default, so tracing no longer needs DaemonSets or hostPorts on every node.

openTelemetry.agent.kind is deprecated: kind: DaemonSet still deploys
the agent, and kind: Deployment matches the new default.

Amp-Thread-ID: https://ampcode.com/threads/T-01a20faa-7870-70ad-b747-bdc5a40a9524
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

@marcleblanc2
marcleblanc2 marked this pull request as ready for review November 25, 2026 00:05
@marcleblanc2
marcleblanc2 requested a review from a team November 25, 2026 00:05
@michaellzc michaellzc added the wontfix This will not be worked on label Nov 25, 2026
@michaellzc

michaellzc commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

realistically speaking on-prem customers have their own o11y setup. On Cloud, we still strong prefer the use of otel-agent as DS.

for custom use cases, they should opt to setup their own pipeline.

@michaellzc michaellzc closed this Nov 25, 2026
@marcleblanc2
marcleblanc2 deleted the marc/otel-agent-disabled-by-default branch November 25, 2026 03:50
@marcleblanc2

marcleblanc2 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

realistically speaking on-prem customers have their own o11y setup. On Cloud, we still strong prefer the use of otel-agent as DS.

for custom use cases, they should opt to setup their own pipeline.

Unfortunately @michaellzc, the bulk of our self-hosted customers hit one speed bump then slash everything they can to shove it through. We have more customers with 0 Observability than any.

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

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants