From ad4d54e0f1a42330c00015fd3a64e24353e8879e Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Tue, 3 Jan 2023 08:15:07 -0800 Subject: [PATCH] Warn metric Exporters of ResourceMetrics reuse (#3556) To potentially optimize the collection code path (#3047) ResourceMetrics sent to the Exporter may be reused in the future. Warn users of this. Co-authored-by: Chester Cheung --- sdk/metric/exporter.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sdk/metric/exporter.go b/sdk/metric/exporter.go index d899b925aa9..572662a3fcf 100644 --- a/sdk/metric/exporter.go +++ b/sdk/metric/exporter.go @@ -45,6 +45,10 @@ type Exporter interface { // implement any retry logic. All errors returned by this function are // considered unrecoverable and will be reported to a configured error // Handler. + // + // The passed ResourceMetrics may be reused when the call completes. If an + // exporter needs to hold this data after it returns, it needs to make a + // copy. Export(context.Context, metricdata.ResourceMetrics) error // ForceFlush flushes any metric data held by an exporter.