Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document public metric SDK interfaces to remain stable #4396

Merged
merged 8 commits into from
Sep 6, 2023
10 changes: 10 additions & 0 deletions sdk/metric/exporter.go
Expand Up @@ -33,12 +33,16 @@ type Exporter interface {
// This method needs to be concurrent safe with itself and all the other
// Exporter methods.
Temporality(InstrumentKind) metricdata.Temporality
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.
pellared marked this conversation as resolved.
Show resolved Hide resolved

// 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
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.

// Export serializes and transmits metric data to a receiver.
//
Expand All @@ -55,6 +59,8 @@ type Exporter interface {
// exporter needs to hold this data after it returns, it needs to make a
// copy.
Export(context.Context, *metricdata.ResourceMetrics) error
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.

// ForceFlush flushes any metric data held by an exporter.
//
Expand All @@ -63,6 +69,8 @@ type Exporter interface {
//
// This method needs to be concurrent safe.
ForceFlush(context.Context) error
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.

// Shutdown flushes all metric data held by an exporter and releases any
// held computational resources.
Expand All @@ -75,4 +83,6 @@ type Exporter interface {
//
// This method needs to be concurrent safe.
Shutdown(context.Context) error
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.
}
7 changes: 7 additions & 0 deletions sdk/metric/reader.go
Expand Up @@ -50,6 +50,8 @@ var errNonPositiveDuration = fmt.Errorf("non-positive duration")
//
// Pull-based exporters will typically implement Register
// themselves, since they read on demand.
//
// Warning: methods may be added to this interface in minor releases.
MrAlias marked this conversation as resolved.
Show resolved Hide resolved
type Reader interface {
// register registers a Reader with a MeterProvider.
// The producer argument allows the Reader to signal the sdk to collect
Expand Down Expand Up @@ -101,10 +103,15 @@ type sdkProducer interface {

// Producer produces metrics for a Reader from an external source.
type Producer interface {
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.

// Produce returns aggregated metrics from an external source.
//
// This method should be safe to call concurrently.
Produce(context.Context) ([]metricdata.ScopeMetrics, error)
// DO NOT CHANGE: any modification will not be backwards compatible and
// must never be done outside of a new major release.
}

// produceHolder is used as an atomic.Value to wrap the non-concrete producer
Expand Down