1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-06 06:02:40 +03:00

OTEL: remove custom Header{Injector,Extractor} implementations

This commit is contained in:
Quentin Gliech
2024-07-25 11:09:01 +02:00
parent bf31c4b548
commit ee9a01ef40
2 changed files with 2 additions and 31 deletions

View File

@@ -14,25 +14,11 @@
use http::Request;
use opentelemetry::propagation::Injector;
use opentelemetry_http::HeaderInjector;
use tower::{Layer, Service};
use tracing::Span;
use tracing_opentelemetry::OpenTelemetrySpanExt;
/// Same as the one in opentelemetry-http, but updated for the http@1 upgrade
pub struct HeaderInjector<'a>(pub &'a mut http::HeaderMap);
impl<'a> Injector for HeaderInjector<'a> {
/// Set a key and value in the [`http::HeaderMap`]. Does nothing if the key
/// or value are not valid inputs.
fn set(&mut self, key: &str, value: String) {
if let Ok(name) = http::header::HeaderName::from_bytes(key.as_bytes()) {
if let Ok(val) = http::header::HeaderValue::from_str(&value) {
self.0.insert(name, val);
}
}
}
}
/// A trait to get an [`Injector`] from a request.
trait AsInjector {
type Injector<'a>: Injector