fix(otlptrace,otlpmetric): reject negative and overflowing timeout env values (#9338) `OTEL_EXPORTER_OTLP_TIMEOUT=-1` gives the trace and metric OTLP exporters a timeout of -1ms, and so does `9223372036854775807`, because multiplying it by `time.Millisecond` wraps around. The clients only set an export deadline when `exportTimeout > 0`, so either value quietly removes the timeout and an export can wait until the caller's context ends. Nothing is logged. `WithDuration` in `internal/shared/otlp/envconfig/envconfig.go.tmpl` now rejects negative values and values above `math.MaxInt64 / time.Millisecond`. It reports them through `global.Error` and skips the value, so the default 10s timeout or a valid generic `OTEL_EXPORTER_OTLP_TIMEOUT` stays in effect. This matches `envDuration` in `sdk/metric/env.go`. Zero is still accepted as before. I switched the parse from `strconv.Atoi` to `strconv.ParseInt(v, 10, 64)` so the overflow bound behaves the same on 32-bit targets. The template was regenerated with `make generate` into `otlptracegrpc`, `otlptracehttp`, `otlpmetricgrpc` and `otlpmetrichttp`. This is the trace and metric counterpart of the log exporter fixes in #9254 and #9155, which only touch `otlploggrpc` and `otlploghttp` and do not share this code. Testing: the shared `envconfig_test.go.tmpl` now covers 0, -1, the largest accepted value 9223372036854, the first overflowing value 9223372036855, and the max int64. The shared trace and metric `options_test.go.tmpl` check that a negative or overflowing `OTEL_EXPORTER_OTLP_TIMEOUT` leaves `DefaultTimeout` in place, and that a negative signal-specific timeout keeps the generic one. The new rejection cases fail on main in all four modules (got -1ms, want 10s) and pass with the change. Reverting only the non-test change makes them fail again. `go test -race ./...`, `go vet`, `gofmt` and `golangci-lint` v2.15.0 are clean for all four modules.
OpenTelemetry-Go is the Go implementation of OpenTelemetry. It provides a set of APIs to directly measure performance and behavior of your software and send this data to observability platforms.
| Signal | Status |
|---|---|
| Traces | Stable |
| Metrics | Stable |
| Logs | Stable |
Progress and status specific to this repository is tracked in our project boards and milestones.
Project versioning information and stability guarantees can be found in the versioning documentation.
OpenTelemetry-Go ensures compatibility with the current supported versions of the Go language:
Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release.
For versions of Go that are no longer supported upstream, opentelemetry-go will stop ensuring compatibility with these versions in the following manner:
Currently, this project supports the following environments.
| OS | Go Version | Architecture |
|---|---|---|
| Ubuntu | 1.27 | amd64 |
| Ubuntu | 1.26 | amd64 |
| Ubuntu | 1.27 | 386 |
| Ubuntu | 1.26 | 386 |
| Ubuntu | 1.27 | arm64 |
| Ubuntu | 1.26 | arm64 |
| macOS | 1.27 | amd64 |
| macOS | 1.26 | amd64 |
| macOS | 1.27 | arm64 |
| macOS | 1.26 | arm64 |
| Windows | 1.27 | amd64 |
| Windows | 1.26 | amd64 |
| Windows | 1.27 | 386 |
| Windows | 1.26 | 386 |
While this project should work for other systems, no compatibility guarantees are made for those systems currently.
You can find a getting started guide on opentelemetry.io.
OpenTelemetry's goal is to provide a single set of APIs to capture distributed traces and metrics from your application and send them to an observability platform. This project allows you to do just that for applications written in Go. There are two steps to this process: instrument your application, and configure an exporter.
To start capturing distributed traces and metric events from your application it first needs to be instrumented. The easiest way to do this is by using an instrumentation library for your code. Be sure to check out the officially supported instrumentation libraries.
If you need to extend the telemetry an instrumentation library provides or want to build your own instrumentation for your application directly you will need to use the Go otel package. The examples are a good way to see some practical uses of this process.
Now that your application is instrumented to collect telemetry, it needs an export pipeline to send that telemetry to an observability platform.
All officially supported exporters for the OpenTelemetry project are contained in the exporters directory.
| Exporter | Logs | Metrics | Traces |
|---|---|---|---|
| OTLP | ✓ | ✓ | ✓ |
| Prometheus | ✓ | ||
| stdout | ✓ | ✓ | ✓ |
| Zipkin | ✓ |
See the contributing documentation.