1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-07 17:03:01 +03:00

Update opentelemetry to 0.24.0

This commit is contained in:
Quentin Gliech
2024-07-24 17:39:13 +02:00
parent d6a54124c7
commit d1b9a4980c
40 changed files with 288 additions and 398 deletions

View File

@@ -47,13 +47,13 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] }
tracing-opentelemetry.workspace = true
opentelemetry.workspace = true
opentelemetry-http.workspace = true
opentelemetry-jaeger-propagator = "0.2.0"
opentelemetry-otlp = { version = "0.16.0", default-features = false, features = ["trace", "metrics", "http-proto"] }
opentelemetry-prometheus = "0.16.0"
opentelemetry-resource-detectors = "0.2.0"
opentelemetry-jaeger-propagator = "0.3.0"
opentelemetry-otlp = { version = "0.17.0", default-features = false, features = ["trace", "metrics", "http-proto"] }
opentelemetry-prometheus = "0.17.0"
opentelemetry-resource-detectors = "0.3.0"
opentelemetry-semantic-conventions.workspace = true
opentelemetry-stdout = { version = "0.4.0", features = ["trace", "metrics"] }
opentelemetry_sdk = { version = "0.23.0", features = ["trace", "metrics", "rt-tokio"] }
opentelemetry-stdout = { version = "0.5.0", features = ["trace", "metrics"] }
opentelemetry_sdk = { version = "0.24.1", features = ["trace", "metrics", "rt-tokio"] }
prometheus = "0.13.4"
sentry.workspace = true
sentry-tracing.workspace = true

View File

@@ -34,7 +34,7 @@ use mas_storage::{BoxClock, BoxRepository, BoxRng, Repository, SystemClock};
use mas_storage_pg::PgRepository;
use mas_templates::Templates;
use opentelemetry::{
metrics::{Histogram, MetricsError, Unit},
metrics::{Histogram, MetricsError},
KeyValue,
};
use rand::SeedableRng;
@@ -78,13 +78,13 @@ impl AppState {
let usage = meter
.i64_observable_up_down_counter("db.connections.usage")
.with_description("The number of connections that are currently in `state` described by the state attribute.")
.with_unit(Unit::new("{connection}"))
.with_unit("{connection}")
.init();
let max = meter
.i64_observable_up_down_counter("db.connections.max")
.with_description("The maximum number of open connections allowed.")
.with_unit(Unit::new("{connection}"))
.with_unit("{connection}")
.init();
// Observe the number of active and idle connections in the pool
@@ -101,7 +101,7 @@ impl AppState {
let histogram = meter
.u64_histogram("db.client.connections.create_time")
.with_description("The time it took to create a new connection.")
.with_unit(Unit::new("ms"))
.with_unit("ms")
.init();
self.conn_acquisition_histogram = Some(histogram);

View File

@@ -22,7 +22,6 @@ use mas_config::{
MetricsConfig, MetricsExporterKind, Propagator, TelemetryConfig, TracingConfig,
TracingExporterKind,
};
use mas_http::OtelClient;
use opentelemetry::{
global,
propagation::{TextMapCompositePropagator, TextMapPropagator},
@@ -99,7 +98,7 @@ fn propagator(propagators: &[Propagator]) -> impl TextMapPropagator {
fn http_client() -> impl opentelemetry_http::HttpClient + 'static {
let client = mas_http::make_untraced_client();
OtelClient::new(client)
opentelemetry_http::hyper::HyperClient::new_with_timeout(client, Duration::from_secs(30))
}
fn stdout_tracer_provider() -> TracerProvider {
@@ -109,7 +108,7 @@ fn stdout_tracer_provider() -> TracerProvider {
.build()
}
fn otlp_tracer(endpoint: Option<&Url>) -> anyhow::Result<Tracer> {
fn otlp_tracer_provider(endpoint: Option<&Url>) -> anyhow::Result<TracerProvider> {
use opentelemetry_otlp::WithExportConfig;
let mut exporter = opentelemetry_otlp::new_exporter()
@@ -133,10 +132,7 @@ fn tracer(config: &TracingConfig) -> anyhow::Result<Option<Tracer>> {
let tracer_provider = match config.exporter {
TracingExporterKind::None => return Ok(None),
TracingExporterKind::Stdout => stdout_tracer_provider(),
TracingExporterKind::Otlp => {
// The OTLP exporter already creates a tracer and installs it
return Ok(Some(otlp_tracer(config.endpoint.as_ref())?));
}
TracingExporterKind::Otlp => otlp_tracer_provider(config.endpoint.as_ref())?,
};
let tracer = tracer_provider
@@ -248,7 +244,7 @@ fn init_meter(config: &MetricsConfig) -> anyhow::Result<()> {
}
fn trace_config() -> opentelemetry_sdk::trace::Config {
opentelemetry_sdk::trace::config()
opentelemetry_sdk::trace::Config::default()
.with_resource(resource())
.with_sampler(Sampler::AlwaysOn)
}