mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-18 03:22:12 +02:00
Document the Reader and Exporter concurrent safe requirements (#4381)
This commit is contained in:
parent
bf29fc6f68
commit
2899fcfdca
@ -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)
|
||||
- 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)
|
||||
- Document the `Temporality` and `Aggregation` methods of the `"go.opentelemetry.io/otel/sdk/metric".Exporter"` need to be concurrent safe. (#4381)
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -30,9 +30,15 @@ var ErrExporterShutdown = fmt.Errorf("exporter is shutdown")
|
||||
// the final component in the metric push pipeline.
|
||||
type Exporter interface {
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// Export serializes and transmits metric data to a receiver.
|
||||
|
@ -65,9 +65,15 @@ type Reader interface {
|
||||
RegisterProducer(Producer)
|
||||
|
||||
// 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
|
||||
|
||||
// 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.
|
||||
|
||||
// Collect gathers and returns all metric data related to the Reader from
|
||||
|
@ -168,6 +168,18 @@ func (ts *readerTestSuite) TestMethodConcurrentSafe() {
|
||||
var wg sync.WaitGroup
|
||||
const threads = 2
|
||||
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)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
Loading…
x
Reference in New Issue
Block a user