Debian Codegraph @

sdk/metric/exporter.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package metric // import "go.opentelemetry.io/otel/sdk/metric"
5
6 import (
7 "context"
8 "errors"
9
10 "go.opentelemetry.io/otel/sdk/metric/metricdata"
11 )
12
13 // ErrExporterShutdown is returned if Export or Shutdown are called after an
14 // Exporter has been Shutdown.
15 var ErrExporterShutdown = errors.New("exporter is shutdown")
16
17 // Exporter handles the delivery of metric data to external receivers. This is
18 // the final component in the metric push pipeline.
19 type Exporter interface {
20 // Temporality returns the Temporality to use for an instrument kind.
21 //
22 // This method needs to be concurrent safe with itself and all the other
23 // Exporter methods.
24 Temporality(InstrumentKind) metricdata.Temporality
25 // DO NOT CHANGE: any modification will not be backwards compatible and
26 // must never be done outside of a new major release.
27
28 // Aggregation returns the Aggregation to use for an instrument kind.
29 //
30 // This method needs to be concurrent safe with itself and all the other
31 // Exporter methods.
32 Aggregation(InstrumentKind) Aggregation
33 // DO NOT CHANGE: any modification will not be backwards compatible and
34 // must never be done outside of a new major release.
35
36 // Export serializes and transmits metric data to a receiver.
37 //
38 // This is called synchronously, there is no concurrency safety
39 // requirement. Because of this, it is critical that all timeouts and
40 // cancellations of the passed context be honored.
41 //
42 // All retry logic must be contained in this function. The SDK does not
43 // implement any retry logic. All errors returned by this function are
44 // considered unrecoverable and will be reported to a configured error
45 // Handler.
46 //
47 // The passed ResourceMetrics may be reused when the call completes. If an
48 // exporter needs to hold this data after it returns, it needs to make a
49 // copy.
50 Export(context.Context, *metricdata.ResourceMetrics) error
51 // DO NOT CHANGE: any modification will not be backwards compatible and
52 // must never be done outside of a new major release.
53
54 // ForceFlush flushes any metric data held by an exporter.
55 //
56 // The deadline or cancellation of the passed context must be honored. An
57 // appropriate error should be returned in these situations.
58 //
59 // This method needs to be concurrent safe.
60 ForceFlush(context.Context) error
61 // DO NOT CHANGE: any modification will not be backwards compatible and
62 // must never be done outside of a new major release.
63
64 // Shutdown flushes all metric data held by an exporter and releases any
65 // held computational resources.
66 //
67 // The deadline or cancellation of the passed context must be honored. An
68 // appropriate error should be returned in these situations.
69 //
70 // After Shutdown is called, calls to Export will perform no operation and
71 // instead will return an error indicating the shutdown state.
72 //
73 // This method needs to be concurrent safe.
74 Shutdown(context.Context) error
75 // DO NOT CHANGE: any modification will not be backwards compatible and
76 // must never be done outside of a new major release.
77 }