You've already forked authentication-service
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user