Skip to content

Commit 13b2689

Browse files
authored
Merge branch 'main' into cijothomas/metric-doc1
2 parents 5146aa6 + 4f2de12 commit 13b2689

File tree

16 files changed

+124
-39
lines changed

16 files changed

+124
-39
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
run: |
103103
cargo install [email protected]
104104
cd ${{ matrix.example }}
105-
cargo check-external-types --config allowed-external-types.toml
105+
cargo check-external-types --all-features --config allowed-external-types.toml
106106
msrv:
107107
strategy:
108108
matrix:

opentelemetry-otlp/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## vNext
44

55
- Update `tonic` dependency version to 0.13
6+
- Re-export `tonic` types under `tonic_types`
7+
[2898](https://github.com/open-telemetry/opentelemetry-rust/pull/2898)
68

79
## 0.29.0
810

opentelemetry-otlp/allowed-external-types.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33
# This is used with cargo-check-external-types to reduce the surface area of downstream crates from
44
# the public API. Ideally this can have a few exceptions as possible.
55
allowed_external_types = [
6-
"opentelemetry::*",
76
"opentelemetry_http::*",
87
"opentelemetry_sdk::*",
9-
# http is a pre 1.0 crate
10-
"http::uri::InvalidUri",
11-
"http::header::name::InvalidHeaderName",
12-
"http::header::value::InvalidHeaderValue",
13-
# prost is a pre 1.0 crate
14-
"prost::error::EncodeError",
8+
# serde
9+
"serde::de::Deserialize",
10+
"serde::ser::Serialize",
1511
# tonic is a pre 1.0 crate
16-
"tonic::status::Code",
17-
"tonic::status::Status",
1812
"tonic::metadata::map::MetadataMap",
13+
"tonic::transport::channel::tls::ClientTlsConfig",
14+
"tonic::transport::tls::Certificate",
15+
"tonic::transport::tls::Identity",
1916
"tonic::transport::channel::Channel",
20-
"tonic::transport::error::Error",
2117
"tonic::service::interceptor::Interceptor",
2218
]

opentelemetry-otlp/src/exporter/http/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use opentelemetry_sdk::metrics::data::ResourceMetrics;
99
use super::OtlpHttpClient;
1010

1111
impl MetricsClient for OtlpHttpClient {
12-
async fn export(&self, metrics: &mut ResourceMetrics) -> OTelSdkResult {
12+
async fn export(&self, metrics: &ResourceMetrics) -> OTelSdkResult {
1313
let client = self
1414
.client
1515
.lock()

opentelemetry-otlp/src/exporter/http/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ impl OtlpHttpClient {
326326
#[cfg(feature = "metrics")]
327327
fn build_metrics_export_body(
328328
&self,
329-
metrics: &mut ResourceMetrics,
329+
metrics: &ResourceMetrics,
330330
) -> Option<(Vec<u8>, &'static str)> {
331331
use opentelemetry_proto::tonic::collector::metrics::v1::ExportMetricsServiceRequest;
332332

333-
let req: ExportMetricsServiceRequest = (&*metrics).into();
333+
let req: ExportMetricsServiceRequest = metrics.into();
334334

335335
match self.protocol {
336336
#[cfg(feature = "http-json")]

opentelemetry-otlp/src/exporter/tonic/metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl TonicMetricsClient {
5252
}
5353

5454
impl MetricsClient for TonicMetricsClient {
55-
async fn export(&self, metrics: &mut ResourceMetrics) -> OTelSdkResult {
55+
async fn export(&self, metrics: &ResourceMetrics) -> OTelSdkResult {
5656
let (mut client, metadata, extensions) = self
5757
.inner
5858
.lock()
@@ -81,7 +81,7 @@ impl MetricsClient for TonicMetricsClient {
8181
.export(Request::from_parts(
8282
metadata,
8383
extensions,
84-
ExportMetricsServiceRequest::from(&*metrics),
84+
ExportMetricsServiceRequest::from(metrics),
8585
))
8686
.await
8787
.map_err(|e| OTelSdkError::InternalFailure(format!("{e:?}")))?;

opentelemetry-otlp/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,20 @@ pub enum Protocol {
450450
#[doc(hidden)]
451451
/// Placeholder type when no exporter pipeline has been configured in telemetry pipeline.
452452
pub struct NoExporterConfig(());
453+
454+
/// Re-exported types from the `tonic` crate.
455+
#[cfg(feature = "grpc-tonic")]
456+
pub mod tonic_types {
457+
/// Re-exported types from `tonic::metadata`.
458+
pub mod metadata {
459+
#[doc(no_inline)]
460+
pub use tonic::metadata::MetadataMap;
461+
}
462+
463+
/// Re-exported types from `tonic::transport`.
464+
#[cfg(feature = "tls")]
465+
pub mod transport {
466+
#[doc(no_inline)]
467+
pub use tonic::transport::{Certificate, ClientTlsConfig, Identity};
468+
}
469+
}

opentelemetry-otlp/src/metric.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl HasHttpConfig for MetricExporterBuilder<HttpExporterBuilderSet> {
123123
pub(crate) trait MetricsClient: fmt::Debug + Send + Sync + 'static {
124124
fn export(
125125
&self,
126-
metrics: &mut ResourceMetrics,
126+
metrics: &ResourceMetrics,
127127
) -> impl std::future::Future<Output = OTelSdkResult> + Send;
128128
fn shutdown(&self) -> OTelSdkResult;
129129
}
@@ -149,7 +149,7 @@ impl Debug for MetricExporter {
149149
}
150150

151151
impl PushMetricExporter for MetricExporter {
152-
async fn export(&self, metrics: &mut ResourceMetrics) -> OTelSdkResult {
152+
async fn export(&self, metrics: &ResourceMetrics) -> OTelSdkResult {
153153
match &self.client {
154154
#[cfg(feature = "grpc-tonic")]
155155
SupportedTransportClient::Tonic(client) => client.export(metrics).await,

opentelemetry-sdk/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ also modified to suppress telemetry before invoking exporters.
4343
- *Breaking* `Aggregation` enum moved behind feature flag
4444
"spec_unstable_metrics_views". This was only required when using Views.
4545
[#2928](https://github.com/open-telemetry/opentelemetry-rust/pull/2928)
46+
- *Breaking* change, affecting custom `PushMetricExporter` authors:
47+
- The `export` method on `PushMetricExporter` now accepts `&ResourceMetrics`
48+
instead of `&mut ResourceMetrics`.
4649

4750
## 0.29.0
4851

opentelemetry-sdk/src/metrics/exporter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub trait PushMetricExporter: Send + Sync + 'static {
1818
/// considered unrecoverable and will be logged.
1919
fn export(
2020
&self,
21-
metrics: &mut ResourceMetrics,
21+
metrics: &ResourceMetrics,
2222
) -> impl std::future::Future<Output = OTelSdkResult> + Send;
2323

2424
/// Flushes any metric data held by an exporter.

0 commit comments

Comments
 (0)