Skip to content

Commit ee6f41f

Browse files
committed
Support dropped counts
Signed-off-by: Caleb Schoepp <[email protected]>
1 parent cd6768a commit ee6f41f

File tree

4 files changed

+25
-24
lines changed

4 files changed

+25
-24
lines changed

crates/world/src/conversions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,10 @@ mod otel {
507507
fn from(value: wasi_otel::SpanData) -> Self {
508508
let mut span_events = SpanEvents::default();
509509
span_events.events = value.events.into_iter().map(Into::into).collect();
510+
span_events.dropped_count = value.dropped_events;
510511
let mut span_links = SpanLinks::default();
511512
span_links.links = value.links.into_iter().map(Into::into).collect();
513+
span_links.dropped_count = value.dropped_links;
512514
Self {
513515
span_context: value.span_context.into(),
514516
parent_span_id: opentelemetry::trace::SpanId::from_hex(&value.parent_span_id)
@@ -518,7 +520,7 @@ mod otel {
518520
start_time: value.start_time.into(),
519521
end_time: value.end_time.into(),
520522
attributes: value.attributes.into_iter().map(Into::into).collect(),
521-
dropped_attributes_count: 0,
523+
dropped_attributes_count: value.dropped_attributes,
522524
events: span_events,
523525
links: span_links,
524526
status: value.status.into(),
@@ -529,7 +531,6 @@ mod otel {
529531

530532
impl From<wasi_otel::SpanContext> for opentelemetry::trace::SpanContext {
531533
fn from(sc: wasi_otel::SpanContext) -> Self {
532-
// TODO(Reviewer): Should this be try_from instead an propagate this error out of the WIT?
533534
let trace_id = opentelemetry::trace::TraceId::from_hex(&sc.trace_id)
534535
.unwrap_or(opentelemetry::trace::TraceId::INVALID);
535536
let span_id = opentelemetry::trace::SpanId::from_hex(&sc.span_id)
@@ -557,7 +558,6 @@ mod otel {
557558
.trace_state()
558559
.header()
559560
.split(',')
560-
// TODO(Reviewer): Should this be try_from instead an propagate this error out of the WIT?
561561
.filter_map(|s| {
562562
if let Some((key, value)) = s.split_once('=') {
563563
Some((key.to_string(), value.to_string()))

tests/test-components/components/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test-components/components/wasi-otel-tracing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ anyhow = "1"
1111
http = "0.2"
1212
opentelemetry = "0.27.0"
1313
opentelemetry_sdk = "0.27.0"
14-
opentelemetry-wasi = { git = "https://github.com/calebschoepp/opentelemetry-wasi", rev = "78d0cf0d1e2674591ab0dfdca8443a81a1e402bd" }
14+
opentelemetry-wasi = { git = "https://github.com/calebschoepp/opentelemetry-wasi", rev = "bd0fad4dd41c07a64e02fb048b2ec56dc08d19ed" }
1515
spin-sdk = "3.1.0"
1616
wit-bindgen = "0.30.0"

wit/deps/otel/tracing.wit

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,34 @@ interface tracing {
1212

1313
/// The data associated with a span.
1414
record span-data {
15-
/// Span context
15+
/// Span context.
1616
span-context: span-context,
17-
/// Span parent id
18-
// TODO: No clue what this is for
17+
/// Span parent id.
1918
parent-span-id: string,
20-
/// Span kind
19+
/// Span kind.
2120
span-kind: span-kind,
22-
// Span name
21+
// Span name.
2322
name: string,
24-
/// Span start time
23+
/// Span start time.
2524
start-time: datetime,
26-
/// Span end time
25+
/// Span end time.
2726
end-time: datetime,
28-
/// Span attributes
27+
/// Span attributes.
2928
attributes: list<key-value>,
30-
/// Span events
29+
/// Span events.
3130
events: list<event>,
32-
/// Span Links
31+
/// Span Links.
3332
links: list<link>,
34-
/// Span status
33+
/// Span status.
3534
status: status,
36-
/// Instrumentation scope that produced this span
35+
/// Instrumentation scope that produced this span.
3736
instrumentation-scope: instrumentation-scope,
38-
39-
// TODO:
40-
// - Dropped counts
41-
// - parent span id vs parent span context
37+
/// Number of attributes dropped by the span due to limits being reached.
38+
dropped-attributes: u32,
39+
/// Number of events dropped by the span due to limits being reached.
40+
dropped-events: u32,
41+
/// Number of links dropped by the span due to limits being reached.
42+
dropped-links: u32,
4243
}
4344

4445
/// Identifying trace information about a span that can be serialized and propagated.
@@ -123,11 +124,11 @@ interface tracing {
123124

124125
/// An event describing a specific moment in time on a span and associated attributes.
125126
record event {
126-
/// Event name
127+
/// Event name.
127128
name: string,
128-
/// Event time
129+
/// Event time.
129130
time: datetime,
130-
/// Event attributes
131+
/// Event attributes.
131132
attributes: list<key-value>,
132133
}
133134

0 commit comments

Comments
 (0)