Skip to content

Commit

Permalink
fix tracestate propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
thjaeckle committed Jan 29, 2025
1 parent 0dc03b3 commit 028904f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import java.time.Instant;
import java.util.Map;

import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;

import org.eclipse.ditto.base.model.headers.DittoHeaderDefinition;
import org.eclipse.ditto.internal.utils.metrics.instruments.tag.Tag;
import org.eclipse.ditto.internal.utils.metrics.instruments.tag.TagSet;

Expand Down Expand Up @@ -113,11 +115,17 @@ public SpanOperationName getOperationName() {

@Override
public Map<String, String> propagateContext(final Map<String, String> headers) {
return httpContextPropagation.propagateContextToHeaders(wrapSpanInContext(), headers);
return httpContextPropagation.propagateContextToHeaders(wrapSpanInContext(
headers.get(DittoHeaderDefinition.W3C_TRACESTATE.getKey())
), headers);
}

private Context wrapSpanInContext() {
return Context.of(Span.Key(), span);
private Context wrapSpanInContext(@Nullable final String traceStateHeader) {
if (traceStateHeader != null) {
return Context.of(Span.Key(), span, Context.key("tracestate", ""), traceStateHeader);
} else {
return Context.of(Span.Key(), span);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;

import org.eclipse.ditto.base.model.entity.metadata.Metadata;
import org.eclipse.ditto.json.JsonObject;
import org.eclipse.ditto.json.JsonPointer;
import org.eclipse.ditto.json.JsonValue;
import org.eclipse.ditto.base.model.entity.metadata.Metadata;
import org.eclipse.ditto.policies.model.PolicyId;

/**
Expand Down Expand Up @@ -169,7 +169,7 @@ public FromScratch setFeature(final String featureId) {

@Override
public FromScratch setFeature(final String featureId, @Nullable final FeatureDefinition featureDefinition,
final FeatureProperties featureProperties) {
@Nullable final FeatureProperties featureProperties) {

return setFeature(ThingsModelFactory.newFeature(featureId, featureDefinition, featureProperties));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ interface FromScratch {
* @throws NullPointerException if {@code featureId} is {@code null}.
*/
FromScratch setFeature(String featureId, FeatureDefinition featureDefinition,
FeatureProperties featureProperties);
@Nullable FeatureProperties featureProperties);

/**
* Sets a Feature with the given ID and properties to this builder. A previously set Feature with the
Expand Down

0 comments on commit 028904f

Please sign in to comment.