1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-09 04:22:45 +03:00

Fix traces not being created for requests

This commit is contained in:
Quentin Gliech
2022-01-25 11:46:14 +01:00
parent 4fd0c6b337
commit 46caf284cf

View File

@@ -27,6 +27,7 @@ use mas_email::{MailTransport, Mailer};
use mas_storage::MIGRATOR;
use mas_tasks::TaskQueue;
use mas_templates::Templates;
use opentelemetry::trace::TraceContextExt;
use opentelemetry_http::HeaderExtractor;
use tower::{make::Shared, ServiceBuilder};
use tower_http::{
@@ -62,6 +63,12 @@ impl<B> MakeSpan<B> for OtelMakeSpan {
propagator.extract(&extractor)
});
let cx = if cx.span().span_context().is_remote() {
cx
} else {
opentelemetry::Context::new()
};
// Attach the context so when the request span is created it gets properly
// parented
let _guard = cx.attach();