Skip to content

Commit

Permalink
Fix parent handling in OpenTelemetry (helidon-io#6092)
Browse files Browse the repository at this point in the history
(cherry picked from commit e36870f)
  • Loading branch information
tomas-langer committed Feb 9, 2023
1 parent 12c000c commit e16b2d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,6 +22,7 @@

import io.opentelemetry.api.trace.SpanBuilder;
import io.opentelemetry.api.trace.SpanKind;
import io.opentelemetry.context.Context;

class OpenTelemetrySpanBuilder implements Span.Builder<OpenTelemetrySpanBuilder> {
private final SpanBuilder spanBuilder;
Expand Down Expand Up @@ -89,7 +90,10 @@ public Span start(Instant instant) {
return new OpenTelemetrySpan(span);
}

SpanBuilder openTelemetry() {
return spanBuilder;
// used to set open telemetry context as parent, to be equivalent in function to
// #parent(SpanContext)
void parent(Context context) {
this.parentSet = true;
this.spanBuilder.setParent(context);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Oracle and/or its affiliates.
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,11 +40,10 @@ public String spanId() {
@Override
public void asParent(io.helidon.tracing.Span.Builder<?> spanBuilder) {
spanBuilder.unwrap(OpenTelemetrySpanBuilder.class)
.openTelemetry()
.setParent(context);
.parent(context);
}

public Context openTelemetry() {
Context openTelemetry() {
return context;
}
}

0 comments on commit e16b2d6

Please sign in to comment.