Skip to content

feat(otel): consolidate all metrics on OpenTelemetry#57

Merged
jasoet merged 4 commits intomainfrom
refactor/grpc-otel-metrics-consolidation
Apr 8, 2026
Merged

feat(otel): consolidate all metrics on OpenTelemetry#57
jasoet merged 4 commits intomainfrom
refactor/grpc-otel-metrics-consolidation

Conversation

@jasoet
Copy link
Copy Markdown
Owner

@jasoet jasoet commented Apr 8, 2026

Summary

  • grpc/: Remove legacy Prometheus MetricsManager and consolidate on the existing OTel instrumentation layer. Delete metrics.go (379 lines), remove enableMetrics/metricsPath/enableLogging config options, add OTel observable gauges for server uptime/start_time
  • temporal/: Replace tally/Prometheus metrics with native OTel via temporalotel.MetricsHandler. Fixes Go 1.22+ panic from duplicate http.Handle("/metrics") when multiple Temporal clients exist in the same process. Simplify NewClient signature from (client.Client, io.Closer, error) to (client.Client, error)
  • deps: uber-go/tally/v4 and go.temporal.io/sdk/contrib/tally removed entirely; prometheus/client_golang demoted from direct to indirect

Net: -1,418 lines, +427 lines (mostly the design doc). All 6 instrumented packages now consistently use otel.Config.MeterProvider.

Test plan

  • task test — all unit tests pass (grpc 71.2% cov, temporal 2.9% cov)
  • task lint — 0 issues
  • go build ./... — entire project compiles
  • go build -tags integration ./temporal/... — integration tests compile
  • Verified no remaining references to removed APIs across examples and docs

🤖 Generated with Claude Code

jasoet added 4 commits April 8, 2026 00:21
Remove the duplicate Prometheus MetricsManager in grpc/ package and
consolidate all metrics on the existing OpenTelemetry instrumentation
layer. The OTel layer in otel_instrumentation.go already covered all
the same metrics with proper semantic conventions.

- Delete grpc/metrics.go (MetricsManager, Prometheus registry, promhttp)
- Delete grpc/metrics_test.go
- Remove enableMetrics, metricsPath, enableLogging config fields
- Remove WithMetrics, WithoutMetrics, WithMetricsPath, WithLogging,
  WithoutLogging options
- Remove legacy fallback branch in setupEchoServer
- Remove metricsManager, stopUptime, trackUptime from Server
- Add registerServerMetrics() with OTel observable gauges for
  server.uptime and server.start_time
- Update README.md to reflect OTel-only metrics

Net: -1016 lines added, +76 lines. prometheus/client_golang now only
imported by temporal/client.go.

BREAKING CHANGE: MetricsManager, GetMetricsManager(), WithMetrics(),
WithoutMetrics(), WithMetricsPath(), WithLogging(), WithoutLogging()
removed. Use WithOTelConfig() for metrics instrumentation.
Replace the tally/Prometheus metrics system in temporal/ with native
OTel metrics via temporalotel.MetricsHandler. This fixes the Go 1.22+
panic caused by duplicate http.Handle("/metrics") registration when
multiple Temporal clients are created in the same process.

- Rewrite NewClient: return (client.Client, error) instead of
  (client.Client, io.Closer, error)
- Remove NewClientWithMetrics — no longer needed
- Remove newPrometheusScope and all tally/prometheus imports
- Remove MetricsListenAddress from Config
- Add OTel metrics handler when OTelConfig.MeterProvider is set
- Remove metricsCloser from WorkerManager, WorkflowManager,
  ScheduleManager
- Update all tests and examples

Dependencies removed: uber-go/tally/v4, go.temporal.io/sdk/contrib/tally
Dependencies demoted: prometheus/client_golang (direct → indirect)

BREAKING CHANGE: NewClient signature changed from
(client.Client, io.Closer, error) to (client.Client, error).
NewClientWithMetrics and MetricsListenAddress removed.
- Remove WithMetrics() from grpc server example
- Remove /metrics endpoint from status JSON in grpc example
- Remove MetricsListenAddress from dashboard example README
- Remove NewClientWithMetrics references from temporal example README
- Update PROJECT_TEMPLATE.md grpc feature table and temporal API
…nature

Remove closer pattern from schedule_integration_test.go — missed in
the initial refactor because integration tests are excluded from
unit test builds.
@jasoet jasoet merged commit 6b066ae into main Apr 8, 2026
0 of 2 checks passed
jasoet added a commit that referenced this pull request Apr 8, 2026
Remove legacy Prometheus metrics from grpc/ and temporal/ packages,
consolidating all metrics on OpenTelemetry.

grpc/: Delete MetricsManager, remove enableMetrics/metricsPath/enableLogging
config options, add OTel observable gauges for server uptime/start_time.

temporal/: Replace tally/Prometheus with temporalotel.MetricsHandler. Simplify
NewClient from (client.Client, io.Closer, error) to (client.Client, error).
Fixes Go 1.22+ panic from duplicate http.Handle("/metrics").

Dependencies removed: uber-go/tally/v4, go.temporal.io/sdk/contrib/tally.
Dependencies demoted: prometheus/client_golang (direct to indirect).

Breaking changes in grpc: WithMetrics/WithoutMetrics/WithMetricsPath/WithLogging/
WithoutLogging/GetMetricsManager removed. Use WithOTelConfig() for metrics.
Breaking changes in temporal: NewClientWithMetrics and MetricsListenAddress removed.
NewClient signature changed to (client.Client, error).
jasoet added a commit that referenced this pull request Apr 8, 2026
Remove legacy Prometheus metrics from grpc/ and temporal/ packages,
consolidating all metrics on OpenTelemetry.

grpc/: Delete MetricsManager, remove enableMetrics/metricsPath/enableLogging
config options, add OTel observable gauges for server uptime/start_time.

temporal/: Replace tally/Prometheus with temporalotel.MetricsHandler. Simplify
NewClient from (client.Client, io.Closer, error) to (client.Client, error).
Fixes Go 1.22+ panic from duplicate http.Handle("/metrics").

Dependencies removed: uber-go/tally/v4, go.temporal.io/sdk/contrib/tally.
Dependencies demoted: prometheus/client_golang (direct to indirect).

Breaking changes in grpc: WithMetrics/WithoutMetrics/WithMetricsPath/WithLogging/
WithoutLogging/GetMetricsManager removed. Use WithOTelConfig() for metrics.
Breaking changes in temporal: NewClientWithMetrics and MetricsListenAddress removed.
NewClient signature changed to (client.Client, error).
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