Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions opentelemetry-otlp/src/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
data::ResourceMetrics, exporter::PushMetricExporter, Temporality,
};
use std::fmt::{Debug, Formatter};
use std::time::Duration;

/// Target to which the exporter is going to send metrics, defaults to https://localhost:4317/v1/metrics.
/// Learn about the relationship between this constant and default/spans/logs at
Expand Down Expand Up @@ -163,6 +164,10 @@
}

fn shutdown(&self) -> OTelSdkResult {
self.shutdown_with_timeout(Duration::from_secs(5))
}

Check warning on line 168 in opentelemetry-otlp/src/metric.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/metric.rs#L167-L168

Added lines #L167 - L168 were not covered by tests

fn shutdown_with_timeout(&self, _timeout: std::time::Duration) -> OTelSdkResult {

Check warning on line 170 in opentelemetry-otlp/src/metric.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-otlp/src/metric.rs#L170

Added line #L170 was not covered by tests
match &self.client {
#[cfg(feature = "grpc-tonic")]
SupportedTransportClient::Tonic(client) => client.shutdown(),
Expand Down
5 changes: 5 additions & 0 deletions opentelemetry-sdk/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Interfaces for exporting metrics

use crate::error::OTelSdkResult;
use std::time::Duration;

use crate::metrics::data::ResourceMetrics;

Expand All @@ -26,6 +28,9 @@ pub trait PushMetricExporter: Send + Sync + 'static {
///
/// After Shutdown is called, calls to Export will perform no operation and
/// instead will return an error indicating the shutdown state.
fn shutdown_with_timeout(&self, timeout: Duration) -> OTelSdkResult;

/// Shutdown with the default timeout of 5 seconds.
fn shutdown(&self) -> OTelSdkResult;

/// Access the [Temporality] of the MetricExporter.
Expand Down
5 changes: 5 additions & 0 deletions opentelemetry-sdk/src/metrics/in_memory_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::collections::VecDeque;
use std::fmt;
use std::sync::{Arc, Mutex};
use std::time::Duration;

/// An in-memory metrics exporter that stores metrics data in memory.
///
Expand Down Expand Up @@ -281,6 +282,10 @@
Ok(())
}

fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
Ok(())
}

Check warning on line 287 in opentelemetry-sdk/src/metrics/in_memory_exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/in_memory_exporter.rs#L285-L287

Added lines #L285 - L287 were not covered by tests

fn temporality(&self) -> Temporality {
self.temporality
}
Expand Down
8 changes: 8 additions & 0 deletions opentelemetry-sdk/src/metrics/periodic_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,10 @@
Ok(())
}

fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
Ok(())
}

Check warning on line 570 in opentelemetry-sdk/src/metrics/periodic_reader.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/periodic_reader.rs#L568-L570

Added lines #L568 - L570 were not covered by tests

fn temporality(&self) -> Temporality {
Temporality::Cumulative
}
Expand All @@ -585,6 +589,10 @@
}

fn shutdown(&self) -> OTelSdkResult {
self.shutdown_with_timeout(Duration::from_secs(5))
}

fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {
self.is_shutdown.store(true, Ordering::Relaxed);
Ok(())
}
Expand Down
5 changes: 5 additions & 0 deletions opentelemetry-stdout/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
};
use std::fmt::Debug;
use std::sync::atomic;
use std::time::Duration;

/// An OpenTelemetry exporter that writes to stdout on export.
pub struct MetricExporter {
Expand Down Expand Up @@ -64,6 +65,10 @@
}

fn shutdown(&self) -> OTelSdkResult {
self.shutdown_with_timeout(Duration::from_secs(5))
}

Check warning on line 69 in opentelemetry-stdout/src/metrics/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-stdout/src/metrics/exporter.rs#L68-L69

Added lines #L68 - L69 were not covered by tests

fn shutdown_with_timeout(&self, _timeout: Duration) -> OTelSdkResult {

Check warning on line 71 in opentelemetry-stdout/src/metrics/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-stdout/src/metrics/exporter.rs#L71

Added line #L71 was not covered by tests
self.is_shutdown.store(true, atomic::Ordering::SeqCst);
Ok(())
}
Expand Down