Skip to content

Commit da368d4

Browse files
authored
Simplify tracing-grpc example (#1886)
1 parent 3e49f23 commit da368d4

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

examples/tracing-grpc/src/client.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ pub mod hello_world {
5050
async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
5151
let tracer = global::tracer("example/client");
5252
let span = tracer
53-
.span_builder(String::from("Greeter/client"))
53+
.span_builder("Greeter/client")
5454
.with_kind(SpanKind::Client)
55-
.with_attributes(vec![KeyValue::new("component", "grpc")])
55+
.with_attributes([KeyValue::new("component", "grpc")])
5656
.start(&tracer);
5757
let cx = Context::current_with_span(span);
5858
let mut client = GreeterClient::connect("http://[::1]:50051").await?;
@@ -75,10 +75,8 @@ async fn greet() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static
7575
status_code.to_string()
7676
}
7777
};
78-
cx.span().add_event(
79-
"Got response!".to_string(),
80-
vec![KeyValue::new("status", status)],
81-
);
78+
cx.span()
79+
.add_event("Got response!", vec![KeyValue::new("status", status)]);
8280

8381
Ok(())
8482
}

examples/tracing-http-propagator/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn send_request(
4141
.await?;
4242

4343
cx.span().add_event(
44-
"Got response!".to_string(),
44+
"Got response!",
4545
vec![KeyValue::new("status", res.status().to_string())],
4646
);
4747

0 commit comments

Comments
 (0)