Skip to content

Commit a7f243c

Browse files
committed
🚨 apply clippy's advices
1 parent a86c6ec commit a7f243c

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

testing-tracing-opentelemetry/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn assert_trace(
1616
is_trace_id_constant: bool,
1717
) {
1818
let trace_id_0 = tracing_events
19-
.get(0)
19+
.first()
2020
.and_then(|v| v.as_object())
2121
.and_then(|v| v.get("span"))
2222
.and_then(|v| v.as_object())

tracing-opentelemetry-instrumentation-sdk/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Instrumentation on the callee side of a call is composed of steps:
1919
- do the processing
2020
- update attributes of the span with response (status,...)
2121

22-
The crates provide helper (or inspiration) to extract/inject context info, start & update span and retrieve context or trace_id during processing (eg to inject trace_id into log, error message,...).
22+
The crates provide helper (or inspiration) to extract/inject context info, start & update span and retrieve context or `trace_id` during processing (eg to inject `trace_id` into log, error message,...).
2323

2424
```rust
2525
let trace_id = tracing_opentelemetry_instrumentation_sdk::find_current_trace_id();
@@ -31,8 +31,8 @@ The helpers could be used as is or into middleware build on it (eg: [`axum-traci
3131
## Notes
3232

3333
- [`tracing-opentelemetry`] extends [`tracing`] to interoperate with [OpenTelemetry]. But with some constraints:
34-
- Creation of the OpenTelemetry's span is done when the tracing span is closed. So do not try to interact with OpenTelemetry Span (or SpanBuilder) from inside the tracing span.
35-
- The OpenTelemetry parent Context (and trace_id) is created on `NEW` span or inherited from parent span. The parent context can be overwritten after creation, but until then the `trace_id` is the one from `NEW`, So tracing's log could report none or not-yet set trace_id on event `NEW` and the following until update.
34+
- Creation of the OpenTelemetry's span is done when the tracing span is closed. So do not try to interact with OpenTelemetry Span (or `SpanBuilder`) from inside the tracing span.
35+
- The OpenTelemetry parent `Context` (and `trace_id`) is created on `NEW` span or inherited from parent span. The parent context can be overwritten after creation, but until then the `trace_id` is the one from `NEW`, So tracing's log could report none or not-yet set `trace_id` on event `NEW` and the following until update.
3636
- To define kind, name,... of OpenTelemetry's span from tracing's span used special record's name: `otel.name`, `otel.kind`, ...
3737
- Record in a [`tracing`]'s Span should be defined at creation time. So some field are created with value `tracing::field::Empty` to then being updated.
3838
- Create trace with target `otel::tracing` (and level `trace`), to have a common way to enable / to disable

tracing-opentelemetry-instrumentation-sdk/src/span_type.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::fmt::Display;
2+
13
// SpanType is a non official open-telemetry key, only supported by Datadog, to help categorize traces.
24
// Documentation: https://github.com/open-telemetry/opentelemetry-rust/blob/ccb510fbd6fdef9694e3b751fd01dbe33c7345c0/opentelemetry-datadog/src/lib.rs#L29-L30
35
// Usage: It should be informed as span.type span key
@@ -19,9 +21,9 @@ pub enum SpanType {
1921
Graphql,
2022
}
2123

22-
impl ToString for SpanType {
23-
fn to_string(&self) -> String {
24-
match self {
24+
impl Display for SpanType {
25+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26+
let s = match self {
2527
SpanType::Web => "web",
2628
SpanType::Http => "http",
2729
SpanType::Sql => "sql",
@@ -35,7 +37,7 @@ impl ToString for SpanType {
3537
SpanType::Queue => "queue",
3638
SpanType::Consul => "consul",
3739
SpanType::Graphql => "graphql",
38-
}
39-
.to_owned()
40+
};
41+
f.write_str(s)
4042
}
4143
}

0 commit comments

Comments
 (0)