Skip to content

feat(go): add custom metrics example with OTel SDK#196

Open
prathamesh-sonpatki wants to merge 4 commits into
mainfrom
prathamesh/go-custom-metrics-example
Open

feat(go): add custom metrics example with OTel SDK#196
prathamesh-sonpatki wants to merge 4 commits into
mainfrom
prathamesh/go-custom-metrics-example

Conversation

@prathamesh-sonpatki
Copy link
Copy Markdown
Member

@prathamesh-sonpatki prathamesh-sonpatki commented May 24, 2026

Summary

  • Adds go/custom-metrics/ example demonstrating raw OTel Go SDK usage
  • Shows counter, histogram, and gauge with attributes via OTLP HTTP export
  • Includes guard pattern for empty string attribute values ()

What's included

  • main.go — MeterProvider setup + counter/histogram/gauge recording loop
  • go.mod / go.sum — dependencies pinned to OTel v1.33.0
  • .gitignore — excludes compiled binaries

Test plan

  • go mod tidy && go build ./... passes
  • Run with OTEL_EXPORTER_OTLP_ENDPOINT and OTEL_EXPORTER_OTLP_HEADERS set — metrics appear in Last9 with correct labels

🤖 Generated with Claude Code

prathamesh-sonpatki and others added 4 commits May 16, 2026 12:08
Send Gemini CLI telemetry — traces, metrics, and logs — to Last9 via
OpenTelemetry. Two paths documented:

- Direct: GEMINI_TELEMETRY_* env vars set endpoint; standard
  OTEL_EXPORTER_OTLP_HEADERS provides auth (picked up by underlying
  OpenTelemetry JS SDK even though gemini-cli does not pass headers
  explicitly to its OTLP exporters).
- Local OTel Collector: useful for batching or fan-out.

Traces are opt-in via GEMINI_TELEMETRY_TRACES_ENABLED=true.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Demonstrates dual-pipeline filterprocessor approach for handling delta
and cumulative OTLP metrics across multi-replica collectors:

- nginx round-robin simulates K8s Service load-balancing
- filter/keep_delta + setshardkey + deltatocumulative per-pod isolation
- filter/keep_cumulative passthrough (SDK owns the counter)
- metrics/delta_broken pipeline shows undercount without setshardkey
- verify.sh queries local VictoriaMetrics for series count sanity check

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…usions

- Replace split mounts with single /:hostfs:ro,rslave to prevent ENOENT
  errors when hostmetrics prepends /hostfs to /proc/mounts paths
- Add exclude_fs_types for squashfs/snap/tmpfs/overlay to eliminate snap
  loopback noise without per-revision exclusion rules
- Fix exclude_mount_points patterns to match new single-mount layout
- Bump image to otel/opentelemetry-collector-contrib:0.144.0
- Update process: scraper comment to document TOCTOU limitation
- Add comment on when to use network_mode: host for prometheus scraping

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Demonstrates counter, histogram, and gauge using raw OTel Go SDK
with OTLP HTTP export. Includes guard against empty string attribute
values which are silently dropped per the Prometheus data model.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@prathamesh-sonpatki prathamesh-sonpatki force-pushed the prathamesh/go-custom-metrics-example branch from fec193b to 6b58e9c Compare May 24, 2026 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant