Integrate OpenTelemetry Weaver into Cortex (Distributor POC)#7387
Draft
CharlieTLe wants to merge 9 commits intocortexproject:masterfrom
Draft
Integrate OpenTelemetry Weaver into Cortex (Distributor POC)#7387CharlieTLe wants to merge 9 commits intocortexproject:masterfrom
CharlieTLe wants to merge 9 commits intocortexproject:masterfrom
Conversation
Schema-driven telemetry: define metrics/spans in YAML, generate Go code and documentation from the schema using OpenTelemetry Weaver. - Add telemetry/registry/ with Distributor metric and span definitions - Add Jinja2 templates for Go code generation and markdown docs - Generate pkg/distributor/telemetry_gen.go with metric registration - Refactor distributor.go New() to use generated registerDistributorMetrics() - Add Makefile targets: telemetry-check, telemetry-generate, check-telemetry - Add CI steps for schema validation and generated code freshness - Add Weaver binary to build-image Dockerfile - Add Rego naming policy for Cortex metric conventions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
- Fix Dockerfile: use .tar.xz format, update to v0.22.1, handle missing arm64 Linux builds gracefully - Fix generated markdown: replace HTML comments with Hugo frontmatter to avoid Hugo build errors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
The tar archive contains weaver-x86_64-unknown-linux-gnu/weaver, not a top-level weaver binary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
The current CI build image doesn't include Weaver yet. Add an install-weaver target that downloads it on-demand so telemetry checks work before the build image is updated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
The CI build image lacks xz-utils. Use the official installer script which handles its own decompression dependencies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
The installer script doesn't support --yes or --install-dir. Use --no-modify-path --quiet flags and configure PATH to find the installed binary in ~/.cargo/bin. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
The CI build image has python3 but not xz-utils. Use python3's built-in lzma module to decompress the .tar.xz archive. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Charlie Le <charlie_le@apple.com>
Weaver v0.22.1 sorts attributes alphabetically, which would change
the label order in generated []string{} slices and break existing
WithLabelValues() call sites. Add explicit label ordering in
params.labels to preserve the original Go label order regardless
of Weaver version. Regenerate with v0.22.1.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Charlie Le <charlie_le@apple.com>
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.
Summary
telemetry/registry/distributor/)pkg/distributor/telemetry_gen.go) and markdown documentation (docs/telemetry/cortex_distributor.md) from the schema using Jinja2 templatesdistributor.goNew()to call the generatedregisterDistributorMetrics()instead of ~100 lines of inlinepromauto.With(reg)callstelemetry-check,check-telemetry) to validate the schema and ensure generated code stays in syncTest plan
go build ./pkg/distributor/...compiles cleanlymake lintpasses (golangci-lint 0 issues, misspell, faillint all clean)make telemetry-checkvalidates the schemamake check-telemetryconfirms generated code is up-to-datepkg/distributorunit tests pass unchangedpkg/cortex,pkg/querier,pkg/ruler,pkg/ingester,pkg/alertmanager,pkg/storegateway,cmd/cortexTestDistriubtorAcceptMixedHASamplesRunningInMicroservicesModepasses — the only e2e test that asserts on refactored metrics (cortex_distributor_deduped_samples_total,cortex_distributor_non_ha_samples_received_total)TestOTLPIngestExemplar,TestIngesterSharding,TestRulerAPI,TestAlertmanager,TestQuerierRemoteRead🤖 Generated with Claude Code