You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-29 23:07:45 +02:00
Document the Reader and Exporter concurrent safe requirements (#4381)
This commit is contained in:
@@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
- Add info and debug logging to the metric SDK. (#4315)
|
- Add info and debug logging to the metric SDK. (#4315)
|
||||||
- The `go.opentelemetry.io/otel/semconv/v1.21.0` package.
|
- The `go.opentelemetry.io/otel/semconv/v1.21.0` package.
|
||||||
The package contains semantic conventions from the `v1.21.0` version of the OpenTelemetry Semantic Conventions. (#4362)
|
The package contains semantic conventions from the `v1.21.0` version of the OpenTelemetry Semantic Conventions. (#4362)
|
||||||
|
- Document the `Temporality` and `Aggregation` methods of the `"go.opentelemetry.io/otel/sdk/metric".Exporter"` need to be concurrent safe. (#4381)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,15 @@ var ErrExporterShutdown = fmt.Errorf("exporter is shutdown")
|
|||||||
// the final component in the metric push pipeline.
|
// the final component in the metric push pipeline.
|
||||||
type Exporter interface {
|
type Exporter interface {
|
||||||
// Temporality returns the Temporality to use for an instrument kind.
|
// Temporality returns the Temporality to use for an instrument kind.
|
||||||
|
//
|
||||||
|
// This method needs to be concurrent safe with itself and all the other
|
||||||
|
// Exporter methods.
|
||||||
Temporality(InstrumentKind) metricdata.Temporality
|
Temporality(InstrumentKind) metricdata.Temporality
|
||||||
|
|
||||||
// Aggregation returns the Aggregation to use for an instrument kind.
|
// Aggregation returns the Aggregation to use for an instrument kind.
|
||||||
|
//
|
||||||
|
// This method needs to be concurrent safe with itself and all the other
|
||||||
|
// Exporter methods.
|
||||||
Aggregation(InstrumentKind) aggregation.Aggregation
|
Aggregation(InstrumentKind) aggregation.Aggregation
|
||||||
|
|
||||||
// Export serializes and transmits metric data to a receiver.
|
// Export serializes and transmits metric data to a receiver.
|
||||||
|
|||||||
@@ -65,9 +65,15 @@ type Reader interface {
|
|||||||
RegisterProducer(Producer)
|
RegisterProducer(Producer)
|
||||||
|
|
||||||
// temporality reports the Temporality for the instrument kind provided.
|
// temporality reports the Temporality for the instrument kind provided.
|
||||||
|
//
|
||||||
|
// This method needs to be concurrent safe with itself and all the other
|
||||||
|
// Reader methods.
|
||||||
temporality(InstrumentKind) metricdata.Temporality
|
temporality(InstrumentKind) metricdata.Temporality
|
||||||
|
|
||||||
// aggregation returns what Aggregation to use for an instrument kind.
|
// aggregation returns what Aggregation to use for an instrument kind.
|
||||||
|
//
|
||||||
|
// This method needs to be concurrent safe with itself and all the other
|
||||||
|
// Reader methods.
|
||||||
aggregation(InstrumentKind) aggregation.Aggregation // nolint:revive // import-shadow for method scoped by type.
|
aggregation(InstrumentKind) aggregation.Aggregation // nolint:revive // import-shadow for method scoped by type.
|
||||||
|
|
||||||
// Collect gathers and returns all metric data related to the Reader from
|
// Collect gathers and returns all metric data related to the Reader from
|
||||||
|
|||||||
@@ -168,6 +168,18 @@ func (ts *readerTestSuite) TestMethodConcurrentSafe() {
|
|||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
const threads = 2
|
const threads = 2
|
||||||
for i := 0; i < threads; i++ {
|
for i := 0; i < threads; i++ {
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
_ = ts.Reader.temporality(InstrumentKindCounter)
|
||||||
|
}()
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
|
_ = ts.Reader.aggregation(InstrumentKindCounter)
|
||||||
|
}()
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|||||||
Reference in New Issue
Block a user