[PR #67] [MERGED] Integrate OpenTelemetry and Prometheus metrics across services #1137

Closed
opened 2026-07-13 12:36:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/gerbil/pull/67
Author: @marcschaeferger
Created: 4/3/2026
Status: Merged
Merged: 4/3/2026
Merged by: @oschwartz10612

Base: devHead: metrics


📝 Commits (5)

  • f322b4c Add OpenTelemetry and Prometheus metrics infrastructure
  • 4357ddf Integrate metrics instrumentation across core services
  • e47a57c Enhance metrics tracking in SNIProxy connection handling
  • 652d9c5 Add metrics tracking for UDP packet handling and session management
  • f07c83f Update Go version to 1.25.0 and add gRPC dependency

📊 Changes

22 files changed (+2958 additions, -47 deletions)

View changed files

📝 README.md (+18 -0)
docs/observability.md (+269 -0)
examples/otel-collector-config.yaml (+46 -0)
examples/prometheus.yml (+24 -0)
📝 go.mod (+33 -6)
📝 go.sum (+79 -10)
internal/metrics/metrics.go (+506 -0)
internal/metrics/metrics_test.go (+258 -0)
internal/observability/config.go (+119 -0)
internal/observability/metrics.go (+152 -0)
internal/observability/metrics_test.go (+198 -0)
internal/observability/noop.go (+71 -0)
internal/observability/noop_test.go (+67 -0)
internal/observability/otel/backend.go (+210 -0)
internal/observability/otel/backend_test.go (+141 -0)
internal/observability/otel/exporter.go (+50 -0)
internal/observability/otel/resource.go (+25 -0)
internal/observability/prometheus/backend.go (+185 -0)
internal/observability/prometheus/backend_test.go (+173 -0)
📝 main.go (+207 -13)

...and 2 more files

📄 Description

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

This pull request introduces comprehensive OpenTelemetry-based observability and metrics instrumentation for Gerbil, supporting both Prometheus-native and OTel/OTLP metrics export. It includes a pluggable backend architecture, detailed documentation, example configurations for both Prometheus and OTel Collector, and a full test suite for the metrics subsystem. The changes also add new dependencies for OpenTelemetry and Prometheus clients.

Observability and Metrics Architecture:

  • Added a pluggable metrics backend system supporting "prometheus", "otel", and "none" (disabled), with clear configuration, validation, and documentation. This enables runtime selection of metrics export method and prepares for future tracing/logging integration. [1] [2]

Documentation and Examples:

  • Added docs/observability.md detailing the observability design, configuration (CLI, env vars), metric catalog, and backend selection guidance.
  • Updated README.md to summarize observability features and direct users to the new documentation.
  • Added example configs: examples/prometheus.yml for Prometheus scraping and examples/otel-collector-config.yaml for OTel Collector pipelines, demonstrating both pull and push-based metric flows. [1] [2]

Testing and Validation:

  • Added a comprehensive test suite in internal/metrics/metrics_test.go covering backend initialization, metric recording, and HTTP scraping for Prometheus, as well as validation for noop and invalid backends.

Dependency Updates:

  • Updated go.mod to include OpenTelemetry and Prometheus client libraries, plus their transitive dependencies, enabling the new observability features.

How to test?

See docs/observability.md


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fosrl/gerbil/pull/67 **Author:** [@marcschaeferger](https://github.com/marcschaeferger) **Created:** 4/3/2026 **Status:** ✅ Merged **Merged:** 4/3/2026 **Merged by:** [@oschwartz10612](https://github.com/oschwartz10612) **Base:** `dev` ← **Head:** `metrics` --- ### 📝 Commits (5) - [`f322b4c`](https://github.com/fosrl/gerbil/commit/f322b4c92165adc031522e36533d2dffb70b1027) Add OpenTelemetry and Prometheus metrics infrastructure - [`4357ddf`](https://github.com/fosrl/gerbil/commit/4357ddf64b9b5c32409548b547c5a7af26e36429) Integrate metrics instrumentation across core services - [`e47a57c`](https://github.com/fosrl/gerbil/commit/e47a57cb4f62cf956fc2ceb60c0b3c78ed74e316) Enhance metrics tracking in SNIProxy connection handling - [`652d9c5`](https://github.com/fosrl/gerbil/commit/652d9c5c6833be8933557746e0f7cdb021decaf7) Add metrics tracking for UDP packet handling and session management - [`f07c83f`](https://github.com/fosrl/gerbil/commit/f07c83fde4314ee02ce51acab89c9e6ee77862ca) Update Go version to 1.25.0 and add gRPC dependency ### 📊 Changes **22 files changed** (+2958 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+18 -0) ➕ `docs/observability.md` (+269 -0) ➕ `examples/otel-collector-config.yaml` (+46 -0) ➕ `examples/prometheus.yml` (+24 -0) 📝 `go.mod` (+33 -6) 📝 `go.sum` (+79 -10) ➕ `internal/metrics/metrics.go` (+506 -0) ➕ `internal/metrics/metrics_test.go` (+258 -0) ➕ `internal/observability/config.go` (+119 -0) ➕ `internal/observability/metrics.go` (+152 -0) ➕ `internal/observability/metrics_test.go` (+198 -0) ➕ `internal/observability/noop.go` (+71 -0) ➕ `internal/observability/noop_test.go` (+67 -0) ➕ `internal/observability/otel/backend.go` (+210 -0) ➕ `internal/observability/otel/backend_test.go` (+141 -0) ➕ `internal/observability/otel/exporter.go` (+50 -0) ➕ `internal/observability/otel/resource.go` (+25 -0) ➕ `internal/observability/prometheus/backend.go` (+185 -0) ➕ `internal/observability/prometheus/backend_test.go` (+173 -0) 📝 `main.go` (+207 -13) _...and 2 more files_ </details> ### 📄 Description ## Community Contribution License Agreement By creating this pull request, I grant the project maintainers an unlimited, perpetual license to use, modify, and redistribute these contributions under any terms they choose, including both the AGPLv3 and the Fossorial Commercial license terms. I represent that I have the right to grant this license for all contributed content. ## Description This pull request introduces comprehensive OpenTelemetry-based observability and metrics instrumentation for Gerbil, supporting both Prometheus-native and OTel/OTLP metrics export. It includes a pluggable backend architecture, detailed documentation, example configurations for both Prometheus and OTel Collector, and a full test suite for the metrics subsystem. The changes also add new dependencies for OpenTelemetry and Prometheus clients. **Observability and Metrics Architecture:** - Added a pluggable metrics backend system supporting "prometheus", "otel", and "none" (disabled), with clear configuration, validation, and documentation. This enables runtime selection of metrics export method and prepares for future tracing/logging integration. [[1]](diffhunk://#diff-f15bc6b1df5b569f21d2272a8907a7b37ab63bc15afedd93441d3b88f51fb38bR1-R119) [[2]](diffhunk://#diff-9d00dc5bdea981219f46e2b98ed6b89fbccb252cc2fd53e6f7ce820baaa3e9f9R1-R269) **Documentation and Examples:** - Added `docs/observability.md` detailing the observability design, configuration (CLI, env vars), metric catalog, and backend selection guidance. - Updated `README.md` to summarize observability features and direct users to the new documentation. - Added example configs: `examples/prometheus.yml` for Prometheus scraping and `examples/otel-collector-config.yaml` for OTel Collector pipelines, demonstrating both pull and push-based metric flows. [[1]](diffhunk://#diff-5e00c28118edea77e66a843c460986b459818b7ff55b1b925da5d6c6911cc06eR1-R24) [[2]](diffhunk://#diff-d69dc33d0da3c7101855deb343d0d264781840455eb4227500b2a1c2eb78492bR1-R46) **Testing and Validation:** - Added a comprehensive test suite in `internal/metrics/metrics_test.go` covering backend initialization, metric recording, and HTTP scraping for Prometheus, as well as validation for noop and invalid backends. **Dependency Updates:** - Updated `go.mod` to include OpenTelemetry and Prometheus client libraries, plus their transitive dependencies, enabling the new observability features. ## How to test? See [docs/observability.md](https://github.com/fosrl/gerbil/blob/652d9c5c6833be8933557746e0f7cdb021decaf7/docs/observability.md) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-07-13 12:36:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gerbil#1137