1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

remove drop_link

This commit is contained in:
Luca Casonato 2025-01-19 19:18:20 +01:00
parent efc1c92f1f
commit d15b772a47
No known key found for this signature in database
GPG key ID: 01A83EB62563811F
4 changed files with 29 additions and 31 deletions

View file

@ -1326,17 +1326,6 @@ impl OtelSpan {
}
}
#[fast]
fn drop_link(&self) {
let mut state = self.0.borrow_mut();
match &mut **state {
OtelSpanState::Recording(span) => {
span.links.dropped_count += 1;
}
OtelSpanState::Done(_) => {}
}
}
#[fast]
fn end(&self, end_time: f64) {
let end_time = if end_time.is_nan() {
@ -1458,6 +1447,7 @@ fn op_otel_span_add_link<'s>(
span_id: v8::Local<'s, v8::Value>,
#[smi] trace_flags: u8,
is_remote: bool,
#[smi] dropped_attributes_count: u32,
) -> bool {
let trace_id = parse_trace_id(scope, trace_id);
if trace_id == TraceId::INVALID {
@ -1482,7 +1472,11 @@ fn op_otel_span_add_link<'s>(
};
let mut state = span.0.borrow_mut();
if let OtelSpanState::Recording(span) = &mut **state {
span.links.links.push(Link::with_context(span_context));
span.links.links.push(Link::new(
span_context,
vec![],
dropped_attributes_count,
));
}
true
}

View file

@ -187,7 +187,6 @@ interface OtelSpan {
spanContext(): SpanContext;
setStatus(status: SpanStatusCode, errorDescription: string): void;
dropEvent(): void;
dropLink(): void;
end(endTime: number): void;
}
@ -361,22 +360,17 @@ class Span {
}
addLink(link: Link): Span {
if (
link.attributes === undefined ||
ObjectKeys(link.attributes).length === 0
) {
const valid = op_otel_span_add_link(
this.#otelSpan,
link.context.traceId,
link.context.spanId,
link.context.traceFlags,
link.context.isRemote ?? false,
);
if (!valid) return this;
} else {
// We don't support link attributes yet.
this.#otelSpan?.dropLink();
}
const droppedAttributeCount = (link.droppedAttributesCount ?? 0) +
(link.attributes ? ObjectKeys(link.attributes).length : 0);
const valid = op_otel_span_add_link(
this.#otelSpan,
link.context.traceId,
link.context.spanId,
link.context.traceFlags,
link.context.isRemote ?? false,
droppedAttributeCount,
);
if (!valid) return this;
return this;
}

View file

@ -74,8 +74,17 @@
"droppedAttributesCount": 0,
"events": [],
"droppedEventsCount": 0,
"links": [],
"droppedLinksCount": 1,
"links": [
{
"traceId": "1234567890abcdef1234567890abcdef",
"spanId": "1234567890abcdef",
"traceState": "",
"attributes": [],
"droppedAttributesCount": 2,
"flags": 1
}
],
"droppedLinksCount": 0,
"status": {
"message": "",
"code": 0

View file

@ -35,5 +35,6 @@ span3.addLink({
attributes: {
key: "value",
},
droppedAttributesCount: 1,
});
span3.end();