1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00
Commit Graph

11 Commits

Author SHA1 Message Date
David Ashpole 988a625a10 Document metric api interfaces that methods need to be safe to be called concurrently (#7952)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7864

Follows this spec change:
https://github.com/open-telemetry/opentelemetry-specification/pull/4868

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2026-02-26 10:15:08 -08:00
Antoine Gagniere 570bcc37ae Explicitly discourage the use of mutexes inside callbacks (#7792)
The
[specifications](https://opentelemetry.io/docs/specs/otel/metrics/api/#asynchronous-instrument-api)
about callbacks say:

> Callback functions MUST be documented as follows for the end user:
> - **Callback functions SHOULD be reentrant safe.** The SDK expects to
evaluate callbacks for each MetricReader independently.
> - **Callback functions SHOULD NOT take an indefinite amount of time.**
> - Callback functions SHOULD NOT make duplicate observations (more than
one Measurement with the same attributes) across all registered
callbacks.
>
> The resulting behavior when a callback violates any of these
RECOMMENDATIONS is explicitly not specified at the API level.

Currently the Go API mentions that callbacks "needs to complete in a
finite amount of time" and "needs to be concurrent safe", but does not
mention reentrancy.

And while close in meaning, there is a nuance between reentrant and
concurrent safe, and a function locking a plain (non-recursive) mutex is
an example of a function that is concurrent safe while not being
reentrant.

Furthermore, in the Go implementation provided in this repo, the metrics
pipeline locks a mutex (in `produce`) then calls all callbacks, which
means that locking a mutex from within a callback would mean holding 2
mutexes at the same time, which opens the door to a deadlock.

In conclusion, users should be made aware in no uncertain terms that
locking a mutex from callbacks is discouraged and not a supported
behavior

(Relates to the discussion in #7755)

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2026-01-19 09:19:24 +01:00
Tyler Yahn 7512a2be2e Add the golines golangci-lint formatter (#6513)
Ensure consistent line wrapping (<= 120 characters) within the project.
2025-03-30 03:46:44 -07:00
Nathan Baulch 506a9baf5e Fix typos (#5763) 2024-09-09 08:53:15 +02:00
Tyler Yahn f8840b9a51 Fix type error in float64 instrument docs (#5302) 2024-05-06 19:04:57 +02:00
Robert Pająk 7dea232a46 [chore] Simplify the license header (#4987) 2024-02-29 07:05:28 +01:00
Tyler Yahn 02c0001307 Document how to pass attributes for all record methods (#4058)
* Document how to pass attributes for all record methods

* Update based on feedback
2023-05-09 08:07:39 -07:00
Tyler Yahn 476d00aa2c Fix the broken [Option] link in metric docs (#4057)
The `Option` type was replaced with `InstrumentOption` when the
`metric/instrument` package was moved to `metric`.
2023-05-08 08:16:34 -07:00
Tyler Yahn 07bf5913a1 Add comment on all uses of embedded types (#4059) 2023-05-08 08:05:08 -07:00
Tyler Yahn 2aadf656e2 Update metric iface warnings (#4056)
Remove self-reference to the package in the expandable interfaces.
2023-05-08 07:56:53 -07:00
Tyler Yahn 15d6ba2921 Unify metric API into the one otel/metric package (#4018)
* Move instrument into metric

* Update metric docs to include instrument

* Update package names

* Update all imports of sdk/metric/instrument

* Rename Option to InstrumentOption

* Deprecate otel/metric/instrument

* Add changelog entry
2023-04-27 11:25:48 -07:00