Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
c2ac121
update otel rust sdk and dependencies
meryl-c Jul 2, 2025
dcfe134
remove runtime interval type and modify `delay` function return type
meryl-c Jul 3, 2025
b26fcab
`Builder` and `TracerProvider` --> `SdkTracerProviderBuilder` and `Sd…
meryl-c Jul 3, 2025
95c3233
update temporality import
meryl-c Jul 3, 2025
8f342cb
update remaining usages of `Builder` to `SdkTracerProvderBuilder; rem…
meryl-c Jul 3, 2025
a42a3ca
use new builder for zipkin exporter (0.28.0)
meryl-c Jul 3, 2025
b17aafd
Update `new_exporter()` to new interface
meryl-c Jul 3, 2025
1eadaf8
access tracer provider directly to shutdown (?)
meryl-c Jul 3, 2025
d920798
`metrics::Result` --> `error::OtelSdkResult` (otel sdk 0.30.0 and 0.2…
meryl-c Jul 3, 2025
9e2767e
remove `GlobalMeterProvider` (otel 0.26.0)
meryl-c Jul 3, 2025
306ebc7
In the process of removing `versioned_meter` everywhere, I ran into a…
meryl-c Jul 3, 2025
e464e40
remove `AggregationSelector`, `TemporalitySelecto`, `as_any()`
meryl-c Jul 11, 2025
5205348
update `TraceResult` imports
meryl-c Jul 11, 2025
76558e3
Use `SyncInstrument` instread of sync (not sure if these counters/gau…
meryl-c Jul 11, 2025
132c9a0
`InstrumentationLibrary` --> `InstrumentationScope`
meryl-c Jul 14, 2025
0472c75
Replace `MetricsError` with `MetricError` but this does not fix the b…
meryl-c Jul 14, 2025
ce8eb73
get rid of `opentelemetry_sdk::metrics::View` and replace with `Strea…
meryl-c Jul 15, 2025
6505daa
Add `semconv_experimental` feature
meryl-c Jul 16, 2025
008737e
`SdkTracerProviderBuilder` --> `TracerProviderBuilder`
meryl-c Jul 16, 2025
155033b
`MetricError` --> `OTelSdkError`
meryl-c Jul 16, 2025
ac22b50
remove unused `Observer` import
meryl-c Jul 17, 2025
c872413
`opentelemetry_sdk::export::trace` --> `opentelemetry_sdk::trace`
meryl-c Jul 17, 2025
4862847
`ExportResult` --> `OTelSdkResult`
meryl-c Jul 17, 2025
f5bda11
fix export method signatures
meryl-c Jul 17, 2025
90b1ed9
add feature to use `Aggregation` enum
meryl-c Jul 17, 2025
6f574c7
remove usages of `NoopMeterProvider` and import
meryl-c Jul 17, 2025
965161b
Fix for non-exhaustive enums
meryl-c Jul 18, 2025
5179116
change init to build for some instruments
meryl-c Jul 18, 2025
7976a0f
various `SdkTracerProvider` fixes
meryl-c Jul 18, 2025
53b43f2
add feature to otel sdk import
meryl-c Jul 18, 2025
3903343
fix return types for `force_flush` and `shutdown`
meryl-c Jul 18, 2025
3d7a4e9
remove 2nd arg from `BatchSpanProcessor::builder`
meryl-c Jul 21, 2025
a57c217
ZipkinExporterBuilder fixes
meryl-c Jul 21, 2025
33f3bcb
`SpanExporterBuilder` API changes
meryl-c Jul 21, 2025
02e7025
fix exporter return types
meryl-c Jul 21, 2025
63696df
more otelsdkresult/error fixes
meryl-c Jul 22, 2025
d99a7c5
define resource on provider builder instead of config (because `with_…
meryl-c Jul 22, 2025
4e0d0d5
replace `instrumentation_lib` with `instrumentation_scope`
meryl-c Jul 22, 2025
a745c89
add `..` since `KeyValue` is now non-exhaustive
meryl-c Jul 22, 2025
7636ee8
Merge branch 'dev' into meryl_PULSR-1663
meryl-c Jul 23, 2025
ca869ae
MetricsExporter --> MetricExporter
meryl-c Jul 23, 2025
f2e2bb4
various `Resource` fixes
meryl-c Jul 23, 2025
734efbe
more `KeyValue` fixes
meryl-c Jul 23, 2025
5ac513c
metricexporterbuilder fix
meryl-c Jul 23, 2025
9e24da5
with_metadata fix
meryl-c Jul 24, 2025
71be73b
ran cargo update
meryl-c Jul 24, 2025
64f0ea7
MeterProvider and MetricExporterBuilder fixes
meryl-c Jul 24, 2025
e536ee0
Use `build` to create instruments instead of `init`
meryl-c Jul 24, 2025
2e960ad
`opentelemetry_sdk::trace::Config` only allows for default configurat…
meryl-c Jul 25, 2025
1c67025
have gauges/counters call `record` instead of `observe` or `measure` …
meryl-c Jul 25, 2025
fa487f5
remove unused imports
meryl-c Jul 25, 2025
f4584bb
update metadatamap import
meryl-c Jul 28, 2025
80ab12e
only pass 1 argument into `detect` implementation
meryl-c Jul 28, 2025
d89293f
fixes for function impls that have too many parameters
meryl-c Jul 28, 2025
d03bffc
more instrument/instrumentbuilder changes
meryl-c Jul 28, 2025
88a7ee6
implement missing methods for classes that extend `SpanProcessor`
meryl-c Jul 29, 2025
05575e6
remove usages of `opentelemetry::global::Error`
meryl-c Jul 29, 2025
9009ac1
misc fixes, including InstrumentBuilder fixes
meryl-c Jul 29, 2025
31f50e2
get rid of another usage of global Error
meryl-c Jul 31, 2025
63f0dcf
patch otel-prometheus so that it uses otel_sdk 0.30.0
meryl-c Jul 31, 2025
808aaeb
fix usages of Resource::builder and Resource::new, fix some type erro…
meryl-c Jul 31, 2025
3d07518
fix macros
meryl-c Aug 5, 2025
58af458
stop calling `shutdown()` on tracer provider since it does not have t…
meryl-c Aug 6, 2025
02c8253
pass closure instead of stream builder into `with_view` usages
meryl-c Aug 6, 2025
810b31f
fix lifecycle errors
meryl-c Aug 6, 2025
5db1140
fix "`T` cannot be sent between threads safely" errors
meryl-c Aug 6, 2025
0a1b842
remove unused imports
meryl-c Aug 7, 2025
3aca3ac
fix issues in aggregation.rs
meryl-c Aug 7, 2025
4164232
fix errors in datadog exporter (but it is probably getting deleted)
meryl-c Aug 7, 2025
b311df4
`SpanExporter` no longer uses a mutable in its `export` method so upd…
meryl-c Aug 11, 2025
7291f83
Remove apollo implementation of datadog-exporter and use the upstream…
meryl-c Aug 11, 2025
783825a
upgrade tonic
meryl-c Aug 12, 2025
1cf31b8
fix last warnings
meryl-c Aug 12, 2025
d365994
Merge branch 'dev' into meryl_PULSR-1663
meryl-c Aug 12, 2025
f05a6df
part 1 of fixing errors uncovered by `cargo xtask test`
meryl-c Aug 15, 2025
7d91791
Merge branch 'dev' into meryl_PULSR-1663
meryl-c Sep 4, 2025
62bb645
fixes post-merge
meryl-c Sep 9, 2025
f537e34
part one of restoring user configurations: exponential histograms
meryl-c Sep 15, 2025
61e8a0b
replace `meter` with `meter_with_scope`
meryl-c Oct 10, 2025
fe39e48
remove tests for deleted method
meryl-c Oct 13, 2025
8af6d82
fix tests in metrics/aggregation
meryl-c Oct 13, 2025
7befe00
use default SpanExporter in test
meryl-c Oct 13, 2025
3a3a5e9
Restore configuration for http exporter, add comment explaining how t…
meryl-c Oct 13, 2025
c5d401b
restore `TonicExporterBuilder` configuration
meryl-c Oct 13, 2025
6afca68
set endpoint and protocol on httpexporterbuilder
meryl-c Oct 13, 2025
dcb68be
replace `TracerProvider` methods that have been removed
meryl-c Oct 13, 2025
bd374dd
build resource instead of using `Default::default()`
meryl-c Oct 13, 2025
5352b72
remove unused `error_map`(s)
meryl-c Oct 13, 2025
eb4e26a
Fix `versioned_meter` calls in tests, fix all tests in `apollo-router…
meryl-c Oct 13, 2025
afc0c97
add error handling, following instructions: https://github.com/open-t…
meryl-c Oct 14, 2025
2c26646
annotate flatmaps with types
meryl-c Oct 14, 2025
78cffb8
Fix remaining test build errors
rregitsky Oct 22, 2025
99efe16
lint fixes
rregitsky Oct 22, 2025
472ac79
more lint
rregitsky Oct 23, 2025
a23bdcb
Merge remote-tracking branch 'origin/dev' into meryl_PULSR-1663
rregitsky Oct 23, 2025
b3b18ba
Fix error_handler merge
rregitsky Oct 23, 2025
0e729ed
fix up the rest of the merge conflicts
rregitsky Oct 23, 2025
c87b07d
test build fixes
rregitsky Oct 24, 2025
d720436
fix some linting
rregitsky Oct 24, 2025
8e153fa
fix most remaining lint issues
rregitsky Oct 24, 2025
53b1f2d
Merge remote-tracking branch 'origin/dev' into meryl_PULSR-1663
rregitsky Oct 24, 2025
493d046
WIP attempt to fix observable instruments
rregitsky Oct 27, 2025
a115214
wip continued
rregitsky Oct 27, 2025
d6cac60
Use delegate for filter meter provider meter_with_scope
rregitsky Oct 28, 2025
1a35e00
remove unnecessary keep-alive stuff
rregitsky Oct 28, 2025
1abb387
lint
rregitsky Oct 28, 2025
2d55b39
Merge remote-tracking branch 'origin/dev' into meryl_PULSR-1663
rregitsky Nov 13, 2025
2a81a33
Fix generic array build warnings
rregitsky Nov 13, 2025
9ddfa1a
Fix equal_attributes now that input is not sorted
rregitsky Nov 13, 2025
81e8c0d
Fix filtered meter provider tests
rregitsky Nov 13, 2025
0dd2b6f
Fix test_metrics() loop metric overlap
rregitsky Nov 14, 2025
1fafa50
Use with_metrics() for test_job_watcher()
rregitsky Nov 14, 2025
6498150
Re-add global to aggregate and filter. Fix global test
rregitsky Nov 14, 2025
9f6be11
update snapshot after rename config removal
rregitsky Nov 17, 2025
61cc1cf
Make single-threaded tests use global meter provider with leaked memory
rregitsky Nov 18, 2025
4499b56
Remove observable gauge drop tests
rregitsky Nov 18, 2025
0847e87
Better explanation about sdkmeterproviderinner drop comment
rregitsky Nov 18, 2025
660bcc9
Go back to thread_local, but keep leaking meter provider
rregitsky Nov 18, 2025
f668a7d
Revert changes to rename. Allow rename to change instrument name with…
rregitsky Nov 19, 2025
77eecf2
fed query typenames snapshot update. Adds otel info logs
rregitsky Nov 19, 2025
820c9a8
Move error_handler replacement, new logging layer, from telemetry plu…
rregitsky Nov 21, 2025
6ac40db
lint
rregitsky Nov 21, 2025
ba5af7f
Merge remote-tracking branch 'origin/dev' into meryl_PULSR-1663
rregitsky Nov 21, 2025
5cfa9a3
Fix cache metric merge conflict. Simpify MetricView TryInto.
rregitsky Nov 24, 2025
2dda8e2
Re-add accidentally deleted response cache metric
rregitsky Nov 24, 2025
6591a54
Recreate error_handler logic as tracing layer
rregitsky Nov 25, 2025
fdfbd08
lint fixes
rregitsky Nov 25, 2025
f159d95
Recreate prometheus aggregations + test snapshots
rregitsky Dec 1, 2025
2cf9717
Only apply global hist buckets to instr w/ no custom view configured
rregitsky Dec 1, 2025
eda25cf
Remove globals from aggregation tests
rregitsky Dec 1, 2025
5e67607
remove duplicate attr in test_custom_router_instruments_with_requirem…
rregitsky Dec 1, 2025
48563e5
Loosen equal_attributes to account for dupe attrs from response events
rregitsky Dec 2, 2025
8b5ea18
Filter fed_query_w_typnames logs to WARN
rregitsky Dec 4, 2025
bb53a91
Remove noisy OTel logs from testing trace subscriber
rregitsky Dec 4, 2025
18ed926
Readd runtime for batch processor. Move span/metric exporters back to…
rregitsky Dec 5, 2025
1461d1d
remove debug log
rregitsky Dec 5, 2025
742198b
Update snapshots with new resource attrs
rregitsky Dec 8, 2025
6a2f5c1
lint fixes
rregitsky Dec 8, 2025
9fe8d63
Merge remote-tracking branch 'origin/dev' into meryl_PULSR-1663
rregitsky Dec 8, 2025
9343d9e
only apply aggregations to histograms
rregitsky Dec 9, 2025
abb808b
enable otlp for integration tests which need no error logs
rregitsky Dec 10, 2025
bb7966a
Re-add router DD tracing common conversion to OTEL tracing common
rregitsky Dec 10, 2025
cdd87e5
Fix missing parent_based sampler set
rregitsky Dec 10, 2025
4287518
Add noop reader to default aggregate meter provider inners. Revert ad…
rregitsky Dec 11, 2025
a2c1dee
process_endpoint default/empty to None to account for bug
rregitsky Dec 11, 2025
b79123e
Merge remote-tracking branch 'origin/dev' into meryl_PULSR-1663
rregitsky Dec 12, 2025
b841504
Filter prometheus histogram aggregation to only histogram instruments
rregitsky Dec 12, 2025
9065e5e
Add tracing layer for otel reemit. Move otel layers to separate mod.
rregitsky Dec 15, 2025
80912cf
replace remaining perodic reader builders with runtime
rregitsky Dec 16, 2025
fb03cc0
Accept meterprovider drop logs for lifecycle clie tests
rregitsky Dec 17, 2025
49d7f6d
Parity for otel error layer and reemit layer fields
rregitsky Dec 17, 2025
ee093ec
strip otel shutdown logs from lifecycle tests. Fix otel_layers error …
rregitsky Dec 17, 2025
83bc041
Remove unnecessary otlp config from test
rregitsky Dec 17, 2025
8a88469
Move common buckets view into reload/metrics.rs::configure_views()
rregitsky Dec 18, 2025
7c4aca9
Wrap configure_views in exporter enabled check. Rename to configure_p…
rregitsky Dec 19, 2025
d61ce0d
Re-add and fix DD agent sampler (WIP)
rregitsky Dec 19, 2025
d4cde2d
Fix client PSR default for Datadog tests
rregitsky Jan 6, 2026
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
609 changes: 133 additions & 476 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ sha1 = "0.10.6"
tempfile = "3.10.1"
tokio = { version = "1.36.0", features = ["full"] }
tower = { version = "0.5.1", features = ["full"] }


[patch.crates-io]
opentelemetry-prometheus = { git = "https://github.com/sandhose/opentelemetry-rust.git", branch = "otel-prometheus-0.30"}
49 changes: 26 additions & 23 deletions apollo-router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,23 @@ once_cell = "1.19.0"
# groups `^tracing` and `^opentelemetry*` dependencies together as of
# https://github.com/apollographql/router/pull/1509. A comment which exists
# there (and on `tracing` packages below) should be updated should this change.
opentelemetry = { version = "0.24.0", features = ["trace", "metrics"] }
opentelemetry_sdk = { version = "0.24.1", default-features = false, features = [
opentelemetry = { version = "0.30.0", features = ["trace", "metrics"] }
opentelemetry_sdk = { version = "0.30.0", default-features = false, features = [
"rt-tokio",
"trace",
"spec_unstable_metrics_views",
"experimental_trace_batch_span_processor_with_async_runtime",
"metrics",
"experimental_metrics_custom_reader",
"experimental_metrics_periodicreader_with_async_runtime",
] }
opentelemetry-aws = "0.12.0"
# START TEMP DATADOG Temporarily remove until we upgrade otel to the latest version
# This means including the rmp library
# opentelemetry-datadog = { version = "0.12.0", features = ["reqwest-client"] }
opentelemetry-appender-tracing = "0.27.0"
opentelemetry-aws = "0.18.0"
opentelemetry-datadog = { version = "0.18.0", features = ["agent-sampling", "reqwest-client"] }
rmp = "0.8"
# END TEMP DATADOG
opentelemetry-http = "0.13.0"
opentelemetry-jaeger-propagator = "0.3.0"
opentelemetry-otlp = { version = "0.17.0", default-features = false, features = [
opentelemetry-http = "0.30.0"
opentelemetry-jaeger-propagator = "0.30.0"
opentelemetry-otlp = { version = "0.30.0", default-features = false, features = [
Copy link
Copy Markdown
Member

@goto-bus-stop goto-bus-stop Jul 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tonic dependency in apollo-router is just to create instances of structures for use with opentelemetry-otlp. In new versions of opentelemetry-otlp, everything we need is reexported here: https://docs.rs/opentelemetry-otlp/0.30.0/opentelemetry_otlp/tonic_types/index.html

So we can remove our tonic dependency and replace our tonic imports with use opentelemetry_otlp::tonic_types::{etc}.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, will do!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goto-bus-stop @BrynCooke it doesn't export MetadataValue, which we do use:

metadata.insert("apollo.api.key", MetadataValue::try_from(apollo_key)?);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up upgrading tonic to 0.13.1 to fix another issue. if there's a workaround to using MetadataValue, I'm happy to do that instead and remove tonic

"grpc-tonic",
"gzip-tonic",
"tonic",
Expand All @@ -183,16 +186,17 @@ opentelemetry-otlp = { version = "0.17.0", default-features = false, features =
"metrics",
"reqwest-client",
"trace",
"tls"
] }
opentelemetry-semantic-conventions = "0.16.0"
opentelemetry-zipkin = { version = "0.22.0", default-features = false, features = [
opentelemetry-semantic-conventions = { version = "0.30.0", features = ["semconv_experimental"]}
opentelemetry-zipkin = { version = "0.30.0", default-features = false, features = [
"reqwest-client",
"reqwest-rustls",
] }
opentelemetry-prometheus = "0.17.0"
opentelemetry-prometheus = "0.29.1"
paste = "1.0.15"
pin-project-lite = "0.2.14"
prometheus = "0.13"
prometheus = "0.14"
prost = "0.13.0"
prost-types = "0.13.0"
proteus = "0.5.0"
Expand Down Expand Up @@ -233,11 +237,10 @@ thiserror = "2.0.0"
tokio.workspace = true
tokio-stream = { version = "0.1.15", features = ["sync", "net", "fs"] }
tokio-util = { version = "0.7.11", features = ["net", "codec", "time", "compat"] }
tonic = { version = "0.12.3", features = [
tonic = { version = "0.13.1", features = [
"transport",
"tls",
"tls-roots",
"gzip",
"tls-native-roots",
] }
tower.workspace = true
tower-http = { version = "0.6.2", features = ["full"] }
Expand Down Expand Up @@ -319,16 +322,16 @@ memchr = { version = "2.7.4", default-features = false }
mockall = "0.14.0"
num-traits = "0.2.19"
once_cell.workspace = true
opentelemetry-stdout = { version = "0.5.0", features = ["trace"] }
opentelemetry = { version = "0.24.0", features = ["testing"] }
opentelemetry_sdk = { version = "0.24.1", features = ["testing"] }
opentelemetry-proto = { version = "0.7.0", features = [
opentelemetry-stdout = { version = "0.30.0", features = ["trace"] }
opentelemetry = { version = "0.30.0", features = ["testing"] }
opentelemetry_sdk = { version = "0.30.0", features = ["testing"] }
opentelemetry-proto = { version = "0.30.0", features = [
"metrics",
"trace",
"gen-tonic-messages",
"with-serde",
] }
opentelemetry-datadog = { version = "0.12.0", features = ["reqwest-client"] }
opentelemetry-datadog = { version = "0.18.0", features = ["agent-sampling", "reqwest-client"] }
p256 = "0.13.2"
pretty_assertions = "1.4.1"
reqwest = { version = "0.12.9", default-features = false, features = [
Expand All @@ -355,7 +358,7 @@ tracing-subscriber = { version = "0.3.20", default-features = false, features =
"env-filter",
"fmt",
] }
tracing-opentelemetry = "0.25.0"
tracing-opentelemetry = "0.31.0"
tracing-test = "=0.2.5"
tracing-mock = "0.1.0-beta.1"
walkdir = "2.5.0"
Expand Down
2 changes: 1 addition & 1 deletion apollo-router/src/axum_factory/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) mod jemalloc {
tracing::warn!("Failed to read jemalloc {} stats", stringify!($name));
}
})
.init()
.build()
};
}

Expand Down
8 changes: 4 additions & 4 deletions apollo-router/src/cache/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl RedisMetricsCollector {
&[KeyValue::new("kind", caller)],
);
})
.init()
.build()
}

/// Generic method to create a weighted average gauge
Expand Down Expand Up @@ -237,7 +237,7 @@ impl RedisMetricsCollector {

gauge.observe(average, &[KeyValue::new("kind", caller)]);
})
.init()
.build()
}

fn create_client_count_gauge() -> ObservableGauge<u64> {
Expand All @@ -249,7 +249,7 @@ impl RedisMetricsCollector {
.with_callback(move |gauge| {
gauge.observe(ACTIVE_CLIENT_COUNT.load(Ordering::Relaxed), &[]);
})
.init()
.build()
}

/// Spawn the metrics collection task
Expand Down Expand Up @@ -521,7 +521,7 @@ mod tests {
// Verify Redis connection metrics are emitted.
// Since this metric is based on a global AtomicU64, it's not unique across tests - so
// we can only reliably check for metric existence, rather than a specific value.
crate::metrics::collect_metrics().metric_exists::<u64>(
crate::metrics::collect_metrics().metric_exists(
"apollo.router.cache.redis.clients",
MetricType::Gauge,
&[],
Expand Down
5 changes: 3 additions & 2 deletions apollo-router/src/cache/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ where
],
)
})
.init()
.build()
}

fn create_cache_estimated_storage_size_gauge(&self) -> ObservableGauge<i64> {
Expand All @@ -153,7 +153,7 @@ where
)
}
})
.init()
.build()
}

/// `init_from_redis` is called with values newly deserialized from Redis cache
Expand Down Expand Up @@ -346,6 +346,7 @@ mod test {
cache.activate();

cache.insert("test".to_string(), Stuff {}).await;

assert_gauge!(
"apollo.router.cache.storage.estimated_size",
1,
Expand Down
55 changes: 30 additions & 25 deletions apollo-router/src/compute_job/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,36 +97,41 @@ mod tests {
use crate::compute_job::ComputeJobType;
use crate::compute_job::metrics::JobWatcher;
use crate::compute_job::metrics::Outcome;
use crate::metrics::FutureMetricsExt;

#[test]
fn test_job_watcher() {
let check_histogram_count =
|count: u64, job_type: &'static str, job_outcome: &'static str| {
assert_histogram_count!(
"apollo.router.compute_jobs.duration",
count,
"job.type" = job_type,
"job.outcome" = job_outcome
);
};
#[tokio::test(flavor = "multi_thread")]
async fn test_job_watcher() {
async {
let check_histogram_count =
|count: u64, job_type: &'static str, job_outcome: &'static str| {
assert_histogram_count!(
"apollo.router.compute_jobs.duration",
count,
"job.type" = job_type,
"job.outcome" = job_outcome
);
};

{
let _job_watcher = JobWatcher::new(ComputeJobType::Introspection);
}
check_histogram_count(1, "introspection", "abandoned");

{
let mut job_watcher = JobWatcher::new(ComputeJobType::QueryParsing);
job_watcher.outcome = Outcome::ExecutedOk;
}
check_histogram_count(1, "query_parsing", "executed_ok");
{
let _job_watcher = JobWatcher::new(ComputeJobType::Introspection);
}
check_histogram_count(1, "introspection", "abandoned");

for count in 1..5 {
{
let mut job_watcher = JobWatcher::new(ComputeJobType::QueryPlanning);
job_watcher.outcome = Outcome::RejectedQueueFull;
let mut job_watcher = JobWatcher::new(ComputeJobType::QueryParsing);
job_watcher.outcome = Outcome::ExecutedOk;
}
check_histogram_count(1, "query_parsing", "executed_ok");

for count in 1..5 {
{
let mut job_watcher = JobWatcher::new(ComputeJobType::QueryPlanning);
job_watcher.outcome = Outcome::RejectedQueueFull;
}
check_histogram_count(count, "query_planning", "rejected_queue_full");
}
check_histogram_count(count, "query_planning", "rejected_queue_full");
}
.with_metrics()
.await;
}
}
2 changes: 1 addition & 1 deletion apollo-router/src/compute_job/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ pub(crate) fn create_queue_size_gauge() -> ObservableGauge<u64> {
"Number of computation jobs (parsing, planning, …) waiting to be scheduled",
)
.with_callback(move |m| m.observe(queue().queued_count() as u64, &[]))
.init()
.build()
}

#[cfg(test)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: apollo-router/src/compute_job/mod.rs
expression: yaml
snapshot_kind: text
---
- fields: {}
level: INFO
Expand Down
31 changes: 19 additions & 12 deletions apollo-router/src/configuration/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ impl From<InstrumentData> for Metrics {
.with_callback(move |observer| {
observer.observe(value, &attributes);
})
.init()
.build()
})
.collect(),
}
Expand All @@ -615,17 +615,24 @@ mod test {
#[test]
fn test_metrics() {
for file_name in Asset::iter() {
let source = Asset::get(&file_name).expect("test file must exist");
let input = std::str::from_utf8(&source.data)
.expect("expected utf8")
.to_string();
let yaml = &serde_yaml::from_str::<serde_json::Value>(&input)
.expect("config must be valid yaml");

let mut data = InstrumentData::default();
data.populate_config_instruments(yaml);
let _metrics: Metrics = data.into();
assert_non_zero_metrics_snapshot!(file_name);
let file_name = file_name.to_string();
// Spawn a new thread (and therefore meter provider) per file so metrics don't carry
// over to next iteration.
std::thread::spawn(move || {
let source = Asset::get(&file_name).expect("test file must exist");
let input = std::str::from_utf8(&source.data)
.expect("expected utf8")
.to_string();
let yaml = &serde_yaml::from_str::<serde_json::Value>(&input)
.expect("config must be valid yaml");

let mut data = InstrumentData::default();
data.populate_config_instruments(yaml);
let _metrics: Metrics = data.into();
assert_non_zero_metrics_snapshot!(file_name);
})
.join()
.expect("metrics test thread panicked")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: apollo-router/src/configuration/tests.rs
expression: "&schema"
snapshot_kind: text
---
{
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
1 change: 0 additions & 1 deletion apollo-router/src/executable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ impl Executable {
if apollo_telemetry_initialized {
// We should be good to shutdown OpenTelemetry now as the router should have finished everything.
tokio::task::spawn_blocking(move || {
opentelemetry::global::shutdown_tracer_provider();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't have access to a tracer provider here, so I don't know how to follow these migration instructions: open-telemetry/opentelemetry-rust#2369

meter_provider_internal().shutdown();
})
.await?;
Expand Down
12 changes: 10 additions & 2 deletions apollo-router/src/logging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub(crate) mod test {
} else {
let parsed_log: Vec<Value> = log
.lines()
.map(|line| {
.filter_map(|line| {
let mut line: serde_json::Value = serde_json::from_str(line).unwrap();
// move the message field to the top level
let fields = line
Expand All @@ -78,11 +78,19 @@ pub(crate) mod test {
.unwrap()
.as_object_mut()
.unwrap();
// Remove noisy OTel logs when meter provider is dropped
if matches!(
fields.get("name").and_then(|v| v.as_str()),
Some("MeterProvider.Drop")
) {
return None;
}

let message = fields.remove("message").unwrap_or_default();
line.as_object_mut()
.unwrap()
.insert("message".to_string(), message);
line
Some(line)
})
.collect();
serde_json::json!(parsed_log)
Expand Down
Loading