aboutsummaryrefslogtreecommitdiffstats
path: root/crates/router/src/processor/grpc.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/router/src/processor/grpc.rs')
-rw-r--r--crates/router/src/processor/grpc.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/router/src/processor/grpc.rs b/crates/router/src/processor/grpc.rs
new file mode 100644
index 0000000..344f2a1
--- /dev/null
+++ b/crates/router/src/processor/grpc.rs
@@ -0,0 +1,27 @@
+pub mod interceptor {
+ use opentelemetry::global;
+ use tonic::{
+ Status,
+ service::{Interceptor, interceptor::InterceptedService},
+ transport::Channel,
+ };
+ use tracing::Span;
+ use tracing_opentelemetry::OpenTelemetrySpanExt;
+ use warden_stack::tracing::telemetry::tonic::injector;
+
+ pub type Intercepted = InterceptedService<Channel, MyInterceptor>;
+
+ #[derive(Clone, Copy)]
+ pub struct MyInterceptor;
+
+ impl Interceptor for MyInterceptor {
+ fn call(&mut self, mut request: tonic::Request<()>) -> Result<tonic::Request<()>, Status> {
+ let cx = Span::current().context();
+ global::get_text_map_propagator(|propagator| {
+ propagator.inject_context(&cx, &mut injector::MetadataMap(request.metadata_mut()))
+ });
+
+ Ok(request)
+ }
+ }
+}