| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package exemplar // import "go.opentelemetry.io/otel/sdk/metric/exemplar" |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
"time" |
| 9 |
|
| 10 |
"go.opentelemetry.io/otel/attribute" |
| 11 |
) |
| 12 |
|
| 13 |
// Reservoir holds the sampled exemplar of measurements made. |
| 14 |
type Reservoir interface { |
| 15 |
// Offer accepts the parameters associated with a measurement. The |
| 16 |
// parameters will be stored as an exemplar if the Reservoir decides to |
| 17 |
// sample the measurement. |
| 18 |
// |
| 19 |
// The passed ctx needs to contain any baggage or span that were active |
| 20 |
// when the measurement was made. This information may be used by the |
| 21 |
// Reservoir in making a sampling decision. |
| 22 |
// |
| 23 |
// The time t is the time when the measurement was made. The val and attr |
| 24 |
// parameters are the value and dropped (filtered) attributes of the |
| 25 |
// measurement respectively. |
| 26 |
Offer(ctx context.Context, t time.Time, val Value, attr []attribute.KeyValue) |
| 27 |
|
| 28 |
// Collect returns all the held exemplars. |
| 29 |
// |
| 30 |
// The Reservoir state is preserved after this call. |
| 31 |
Collect(dest *[]Exemplar) |
| 32 |
} |
| 33 |
|
| 34 |
// ReservoirProvider creates new [Reservoir]s. |
| 35 |
// |
| 36 |
// The attributes provided are attributes which are kept by the aggregation, and |
| 37 |
// are exclusive with attributes passed to Offer. The combination of these |
| 38 |
// attributes and the attributes passed to Offer is the complete set of |
| 39 |
// attributes a measurement was made with. |
| 40 |
type ReservoirProvider func(attr attribute.Set) Reservoir |