From a171f4b3d699d77d3519c265a3eed45dead8b0ea Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Mon, 13 Jul 2026 14:40:20 -0400 Subject: [PATCH 1/2] add details for opentelemetry and monotonic counters --- docs/develop/go/platform/observability.mdx | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/develop/go/platform/observability.mdx b/docs/develop/go/platform/observability.mdx index 463ccc7700..889f192050 100644 --- a/docs/develop/go/platform/observability.mdx +++ b/docs/develop/go/platform/observability.mdx @@ -56,10 +56,37 @@ client.Options{ } ``` -The Go SDK currently supports the [Tally](https://pkg.go.dev/go.temporal.io/sdk/contrib/tally) library; however, Tally offers [extensible custom metrics reporting](https://github.com/uber-go/tally#report-your-metrics), which is exposed through the [`WithCustomMetricsReporter`](/references/server-options#withcustommetricsreporter) API. +The Go SDK provides metrics handlers for [Tally](https://pkg.go.dev/go.temporal.io/sdk/contrib/tally) and [OpenTelemetry](https://pkg.go.dev/go.temporal.io/sdk/contrib/opentelemetry). Tally offers [extensible custom metrics reporting](https://github.com/uber-go/tally#report-your-metrics), which is exposed through the [`WithCustomMetricsReporter`](/references/server-options#withcustommetricsreporter) API. For more information, see the [Go sample for metrics](https://github.com/temporalio/samples-go/tree/main/metrics). +### Configure OpenTelemetry counters as monotonic {/* #opentelemetry-monotonic-counters */} + +:::note + +`UseMonotonicCounters` is available in `go.temporal.io/sdk/contrib/opentelemetry` version 0.8.0 and later. + +::: + +By default, the OpenTelemetry metrics handler represents counters as `Int64UpDownCounter` instruments to preserve compatibility with earlier releases. +To represent Temporal SDK counters as monotonic `Int64Counter` instruments, set `UseMonotonicCounters` to `true` when you create the handler: + +```go +metricsHandler := temporalotel.NewMetricsHandler(temporalotel.MetricsHandlerOptions{ + Meter: otel.GetMeterProvider().Meter("temporal-sdk-go"), + UseMonotonicCounters: true, +}) + +temporalClient, err := client.Dial(client.Options{ + MetricsHandler: metricsHandler, +}) +``` + +Monotonic counters let exporters and metrics backends classify Temporal SDK counters correctly. +The [`MetricsCounter`](https://pkg.go.dev/go.temporal.io/sdk/client#MetricsCounter) contract defines counters as ever-increasing. +If you create custom counters through the same metrics handler, pass only non-negative values to `Inc`. +Negative values can produce invalid or backend-dependent metric data when `UseMonotonicCounters` is enabled. + ## Tracing {/* #tracing */} Tracing allows you to view the call graph of a Workflow along with its Activities, Nexus Operations, and Child Workflows. From e862927fccdf2d226ed0be1b0df4c1d84b224ae2 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Thu, 16 Jul 2026 14:22:34 -0400 Subject: [PATCH 2/2] make it clear what Inc is --- docs/develop/go/platform/observability.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/develop/go/platform/observability.mdx b/docs/develop/go/platform/observability.mdx index 889f192050..07c07d1337 100644 --- a/docs/develop/go/platform/observability.mdx +++ b/docs/develop/go/platform/observability.mdx @@ -84,7 +84,7 @@ temporalClient, err := client.Dial(client.Options{ Monotonic counters let exporters and metrics backends classify Temporal SDK counters correctly. The [`MetricsCounter`](https://pkg.go.dev/go.temporal.io/sdk/client#MetricsCounter) contract defines counters as ever-increasing. -If you create custom counters through the same metrics handler, pass only non-negative values to `Inc`. +If you create custom counters through the same metrics handler, pass only non-negative values to [`client.MetricsCounter.Inc`](https://pkg.go.dev/go.temporal.io/sdk/internal/common/metrics#Counter). Negative values can produce invalid or backend-dependent metric data when `UseMonotonicCounters` is enabled. ## Tracing {/* #tracing */}