feat: write /etc/glueops/otel.env so CDE VMs ship metrics - #515
Open
venkatamutyala wants to merge 1 commit into
Open
feat: write /etc/glueops/otel.env so CDE VMs ship metrics#515venkatamutyala wants to merge 1 commit into
venkatamutyala wants to merge 1 commit into
Conversation
The codespaces image (GlueOps/codespaces#580) carries prometheus-node-exporter and an OpenTelemetry Collector whose systemd unit is gated on /etc/glueops/otel.env. This writes that file through cloud-init when OTEL_EXPORTER_OTLP_ENDPOINT is set on the bot: the OTLP/HTTP base URL plus OTEL_RESOURCE_ATTRIBUTES built from metadata the bot already has (region, instance type, image, owner, and APP_ENVIRONMENT as deployment.environment.name — the one thing the VM cannot know on its own). A `systemctl start otelcol-contrib || true` runcmd after `tailscale up` is belt-and-braces for the first boot and a no-op on older images. Unset endpoint = no file, and the generated user-data is byte-for-byte what it is today. Attribute values carrying ',', '=', '%' or whitespace are dropped rather than escaped — the same policy as TUNNEL_ENDPOINT — so one bad value cannot cost a VM its metrics, and a malformed endpoint writes nothing. codespace.env is untouched: it holds user secrets and is fed to the dev container, which is why it is not the carrier here. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013zxxz8592fPJaq2B81jsC2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Companion to GlueOps/codespaces#580, which bakes
prometheus-node-exporter+ an OpenTelemetry Collector into the CDE image with its systemd unit gated on/etc/glueops/otel.env. This PR makes the bot write that file through cloud-init — the same way it already writescde_tokenandtunnel_endpoint— so the collector turns on and knows which VM it is.When
OTEL_EXPORTER_OTLP_ENDPOINTis set on the bot, each new VM'swrite_filesgains (root,0600, b64 likecodespace.env):plus a
systemctl start otelcol-contrib || trueruncmd aftertailscale up(belt-and-braces for first boot; no-op on images that predate the unit).host.nameis deliberately absent — the collector takes it from the hostname cloud-init already sets.deployment.environment.nameis the one attribute the VM can't derive itself, which is the main reason this lives in the bot rather than the image.Behaviour / safety
,=%or whitespace are dropped, not escaped (they'd change the meaning of thek=v,k=vstring) — same policy asTUNNEL_ENDPOINT. A malformed endpoint writes nothing.codespace.envis untouched. It holds user profile secrets and is fed to the dev container, which is why it isn't the carrier.Files
util/get-user-data.js—otelEnvFile()(exported),write_filesnow emitted from a list, the runcmd start.example.env,CLAUDE.md,README.md— the new optional variable and the contract.Rollout
Either PR can land first. Old images ignore the file; new images without the file stay inert. The endpoint isn't routed yet (prod Traefik default backend), so nothing arrives until that's up — VMs queue and drop, bounded.
PR Checklist
codespace.envunchanged)🤖 Generated with Claude Code
https://claude.ai/code/session_013zxxz8592fPJaq2B81jsC2