Skip to content

Commit

Permalink
Simplify tracing-grpc example (#1886)
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla committed Jun 17, 2024
1 parent 3e49f23 commit da368d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions examples/tracing-grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ pub mod hello_world {
async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
let tracer = global::tracer("example/client");
let span = tracer
.span_builder(String::from("Greeter/client"))
.span_builder("Greeter/client")
.with_kind(SpanKind::Client)
.with_attributes(vec![KeyValue::new("component", "grpc")])
.with_attributes([KeyValue::new("component", "grpc")])
.start(&tracer);
let cx = Context::current_with_span(span);
let mut client = GreeterClient::connect("http://[::1]:50051").await?;
Expand All @@ -75,10 +75,8 @@ async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static
status_code.to_string()
}
};
cx.span().add_event(
"Got response!".to_string(),
vec![KeyValue::new("status", status)],
);
cx.span()
.add_event("Got response!", vec![KeyValue::new("status", status)]);

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tracing-http-propagator/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn send_request(
.await?;

cx.span().add_event(
"Got response!".to_string(),
"Got response!",
vec![KeyValue::new("status", res.status().to_string())],
);

Expand Down

0 comments on commit da368d4

Please sign in to comment.