Distributed tracing for everyone
Distributed Tracing:
observing the internal state of a distributed system using structured data
NOTE:
Service entry point != root span!
Specification Link
Specification Link
Specification Link
Specification Link
Receivers
Receive otel data
Ex:
otlp
jaeger WP
Processors
Operate on data
Ex:
add hostname to every trace
Exporters
Send data to $LOCATION
Ex:
JSON file
Honeycomb
Local jaeger
#[instrument]
async fn greet() -> Result<(), Box<Error> {
let mut client = GreeterClient::connect(
"http://[::1]:50051")
.instrument(info_span!("client connect"))
.await?;
let mut request = tonic::Request::new(HelloRequest {
name: "Tonic".into(),
});
global::get_text_map_propagator(|propagator| {
propagator.inject_context(
&tracing::Span::current().context(),
&mut MetadataMap(request.metadata_mut()),
)
});
let response = client
.say_hello(request)
.instrument(info_span!("say_hello"))
.await?;
info!("Response received: {:?}", response);
Ok(())
}
#[tonic::async_trait]
impl Greeter for MyGreeter {
#[instrument]
async fn say_hello(
&self,
request: Request<HelloRequest>,
) -> Result<Response<HelloReply>, Status> {
let parent_cx =
global::get_text_map_propagator(
|prop| prop.extract(
&MetadataMap(request.metadata())));
tracing::Span::current().set_parent(parent_cx);
let name = request.into_inner().name;
expensive_fn(format!("Got name: {:?}", name));
// Return an instance of type HelloReply
let reply = hello_world::HelloReply {
message: format!("Hello {}!", name),
};
Ok(Response::new(reply))
}
}
Client
Server
The space is enormous