Skip to content

Commit c13bef9

Browse files
committed
PR feedback
1 parent 88b4db5 commit c13bef9

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

crates/apollo-mcp-server/src/runtime/telemetry.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ pub enum MetricTemporality {
5050
Delta,
5151
}
5252

53-
impl MetricTemporality {
54-
pub fn to_sdk(&self) -> Temporality {
55-
match self {
53+
impl OTLPMetricExporter {
54+
pub fn to_temporality(&self) -> Temporality {
55+
match self
56+
.temporality
57+
.as_ref()
58+
.unwrap_or(&MetricTemporality::Cumulative)
59+
{
5660
MetricTemporality::Cumulative => Temporality::Cumulative,
5761
MetricTemporality::Delta => Temporality::Delta,
5862
}
@@ -63,15 +67,15 @@ impl MetricTemporality {
6367
pub struct OTLPMetricExporter {
6468
endpoint: String,
6569
protocol: String,
66-
temporality: MetricTemporality,
70+
temporality: Option<MetricTemporality>,
6771
}
6872

6973
impl Default for OTLPMetricExporter {
7074
fn default() -> Self {
7175
Self {
7276
endpoint: "http://localhost:4317".into(),
7377
protocol: "grpc".into(),
74-
temporality: MetricTemporality::Cumulative,
78+
temporality: Some(MetricTemporality::Cumulative),
7579
}
7680
}
7781
}
@@ -139,12 +143,12 @@ fn init_meter_provider(telemetry: &Telemetry) -> Result<SdkMeterProvider, anyhow
139143
"grpc" => opentelemetry_otlp::MetricExporter::builder()
140144
.with_tonic()
141145
.with_endpoint(otlp.endpoint.clone())
142-
.with_temporality(otlp.temporality.to_sdk())
146+
.with_temporality(otlp.to_temporality())
143147
.build()?,
144148
"http/protobuf" => opentelemetry_otlp::MetricExporter::builder()
145149
.with_http()
146150
.with_endpoint(otlp.endpoint.clone())
147-
.with_temporality(otlp.temporality.to_sdk())
151+
.with_temporality(otlp.to_temporality())
148152
.build()?,
149153
other => {
150154
return Err(anyhow::anyhow!(
@@ -350,7 +354,7 @@ mod tests {
350354
otlp: Some(OTLPMetricExporter {
351355
protocol: "bogus".to_string(),
352356
endpoint: "http://localhost:4317".to_string(),
353-
temporality: MetricTemporality::Cumulative,
357+
temporality: None,
354358
}),
355359
omitted_attributes: None,
356360
}),
@@ -374,7 +378,7 @@ mod tests {
374378
otlp: Some(OTLPMetricExporter {
375379
protocol: "http/protobuf".to_string(),
376380
endpoint: "http://localhost:4318/v1/metrics".to_string(),
377-
temporality: MetricTemporality::Delta,
381+
temporality: Some(MetricTemporality::Delta),
378382
}),
379383
omitted_attributes: None,
380384
}),

docs/source/config-file.mdx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,11 @@ transport:
252252

253253
#### OTLP Metrics Exporter
254254

255-
| Option | Type | Default | Description |
256-
| :--------- | :------------ | :-------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
257-
| `endpoint` | `URL` | `http://localhost:4137` | URL to export data to. Requires full path. |
258-
| `protocol` | `string` | `grpc` | Protocol for export. Only `grpc` and `http/protobuf` are supported. |
259-
| `temporality` | `Temporality` | `Cumulative` | OTel property that refers to the way additive quantities are expressed, in relation to time, indicating whether reported values incorporate previous measurements or not. |
260-
261-
##### Temporality
262-
263-
| Option | Type | Description |
264-
| :----------- | :------ | :------------------------------------------------------------------------------------------------ |
265-
| `Cumulative` | `enum` | The metric value will be the overall value since the start of the measurement. (default behavior) |
266-
| `Delta` | `enum` | The metric will be the difference in the measurement since the last time it was reported. |
267-
255+
| Option | Type | Default | Description |
256+
| :--------- | :--------------------------------------- | :----------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
257+
| `endpoint` | `URL` | `http://localhost:4137` | URL to export data to. Requires full path. |
258+
| `protocol` | `string` | `grpc` | Protocol for export. Only `grpc` and `http/protobuf` are supported. |
259+
| `temporality` | `Optional oneOf ["Cumulative", "Delta"]` | `Cumulative` | Optional OTel property that refers to the way additive quantities are expressed, in relation to time, indicating whether reported values incorporate previous measurements (Cumulative) or not (Delta). |
268260

269261
#### Traces
270262

0 commit comments

Comments
 (0)