-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed
opentelemetry_http
dependency and http
crate bumped to 1
- Loading branch information
1 parent
637e7e6
commit 93ab7ef
Showing
6 changed files
with
44 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//! Implementation of fields injector. | ||
|
||
use http::HeaderMap; | ||
|
||
pub struct HeaderExtractor<'a>(pub &'a HeaderMap); | ||
|
||
impl<'a> opentelemetry::propagation::Extractor for HeaderExtractor<'a> { | ||
fn get(&self, key: &str) -> Option<&str> { | ||
self.0 | ||
.get(key) | ||
.and_then(|header_value| header_value.to_str().ok()) | ||
} | ||
|
||
fn keys(&self) -> Vec<&str> { | ||
self.0 | ||
.keys() | ||
.map(|header_name| header_name.as_str()) | ||
.collect() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! Implementation of fields injector. | ||
|
||
use std::str::FromStr; | ||
|
||
use http::{HeaderMap, HeaderName, HeaderValue}; | ||
|
||
pub struct HeaderInjector<'a>(pub &'a mut HeaderMap); | ||
|
||
impl<'a> opentelemetry::propagation::Injector for HeaderInjector<'a> { | ||
fn set(&mut self, key: &str, value: String) { | ||
if let Ok(header_name) = HeaderName::from_str(key) { | ||
if let Ok(header_value) = HeaderValue::from_str(&value) { | ||
self.0.insert(header_name, header_value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,7 @@ pub use self::{ | |
http::{Http, HttpLayer}, | ||
}; | ||
|
||
mod extractor; | ||
pub mod grpc; | ||
pub mod http; | ||
mod injector; |