|
1 | | -use linkerd_error::Error; |
| 1 | +use linkerd_opentelemetry::otel::trace::SpanKind; |
2 | 2 | use linkerd_stack::layer; |
3 | | -use linkerd_trace_context::{ |
4 | | - self as trace_context, |
5 | | - export::{ExportSpan, SpanKind, SpanLabels}, |
6 | | - Span, TraceContext, |
7 | | -}; |
8 | | -use std::sync::Arc; |
9 | | -use tokio::sync::mpsc; |
10 | | - |
11 | | -pub type SpanSink = mpsc::Sender<ExportSpan>; |
| 3 | +use linkerd_trace_context::{export::SpanLabels, TraceContext}; |
12 | 4 |
|
13 | 5 | pub fn server<S>( |
14 | | - _sink: Option<SpanSink>, |
15 | 6 | labels: impl Into<SpanLabels>, |
16 | 7 | ) -> impl layer::Layer<S, Service = TraceContext<S>> + Clone { |
17 | 8 | TraceContext::layer(SpanKind::Server, labels.into()) |
18 | 9 | } |
19 | 10 |
|
20 | 11 | pub fn client<S>( |
21 | | - _sink: Option<SpanSink>, |
22 | 12 | labels: impl Into<SpanLabels>, |
23 | 13 | ) -> impl layer::Layer<S, Service = TraceContext<S>> + Clone { |
24 | 14 | TraceContext::layer(SpanKind::Client, labels.into()) |
25 | 15 | } |
26 | | - |
27 | | -#[derive(Clone)] |
28 | | -pub struct SpanConverter { |
29 | | - kind: SpanKind, |
30 | | - sink: SpanSink, |
31 | | - labels: SpanLabels, |
32 | | -} |
33 | | - |
34 | | -impl trace_context::SpanSink for SpanConverter { |
35 | | - fn is_enabled(&self) -> bool { |
36 | | - true |
37 | | - } |
38 | | - |
39 | | - fn try_send(&mut self, span: Span) -> Result<(), Error> { |
40 | | - self.sink.try_send(ExportSpan { |
41 | | - span, |
42 | | - kind: self.kind, |
43 | | - labels: Arc::clone(&self.labels), |
44 | | - })?; |
45 | | - Ok(()) |
46 | | - } |
47 | | -} |
0 commit comments