OpenTelemetry `host.name` causing huge bills in observability tooling
What's happening
OpenTofu stamps host.name on every span using os.Hostname(). In CI that's the container ID, so every run shows up as a new host.
When using observability tooling like Datadog bills APM by concurrent hosts. When using CI/CD tools like Spacelift or GitHub Actions, that's a different host (container ID), and would make the bill absurdly high.
Fix
Initially, OTEL_RESOURCE_ATTRIBUTES=host.name=something-consistent was thought to be the solution.
But it doesn't override it.
internal/tracing/init.go builds the resource with resource.WithHost() sets it.
Why "just set it to a constant" isn't the whole answer
Even if OpenTofu honored the env var, there's no way to remove host.name. The env var can only add or overwrite. For an ephemeral runner the right value is "no host at all", and there's no knob for that. Setting it to an empty string is a hack and backends may treat it oddly.
What we're doing in the meantime
Datadog resolves hostname from datadog.host.name before host.name, and OpenTofu doesn't touch that key, so we set datadog.host.name=opentofu and all runs collapse onto one host. Works, but it's Datadog-specific.
Ideal world
This isn't set by default or opt in, or another solution.
This is tribal knowledge to know that setting up OTEL tracing, if using a tooling like Datadog, that we have to override it and set it to empty.
Source: opentofu/opentofu