Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ message RpcTraceContext {

// This corresponds to Activity.Current?.Tags
map<string, string> attributes = 3;

// This is populated from OpenTelemetry.Baggage.Current
map<string, string> baggage = 4;
}

// Host sends retry context for a function invocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import com.microsoft.azure.functions.TraceContext;

final public class ExecutionTraceContext implements TraceContext {
public ExecutionTraceContext(String traceParent, String traceState, Map<String, String> attributes) {
public ExecutionTraceContext(String traceParent, String traceState, Map<String, String> attributes,
Map<String, String> baggage) {
this.Attributes = attributes;
this.Baggage = baggage;
this.Traceparent = traceParent;
this.Tracestate = traceState;
}
Expand All @@ -20,7 +22,10 @@ public ExecutionTraceContext(String traceParent, String traceState, Map<String,
@Override
public Map<String, String> getAttributes() { return this.Attributes; }

public Map<String, String> getBaggage() { return this.Baggage; }

private final String Traceparent;
private final String Tracestate;
private final Map<String, String> Attributes;
}
private final Map<String, String> Baggage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ private ExecutionContextDataSource buildExecutionContext(String id, InvocationR
dataStore.addTriggerMetadataSource(getTriggerMetadataMap(request));
dataStore.addParameterSources(request.getInputDataList());
ExecutionTraceContext traceContext = new ExecutionTraceContext(request.getTraceContext().getTraceParent(),
request.getTraceContext().getTraceState(), request.getTraceContext().getAttributesMap());
request.getTraceContext().getTraceState(), request.getTraceContext().getAttributesMap(),
request.getTraceContext().getBaggageMap());
ExecutionRetryContext retryContext = new ExecutionRetryContext(request.getRetryContext().getRetryCount(),
request.getRetryContext().getMaxRetryCount(), request.getRetryContext().getException());
ExecutionContextDataSource executionContextDataSource = new ExecutionContextDataSource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class ParameterResolverTest {
@BeforeEach
public void setup() {
String invocationId = "testInvocationId";
ExecutionTraceContext traceContext = new ExecutionTraceContext("traceParent", "traceState", new HashMap<>());
ExecutionTraceContext traceContext = new ExecutionTraceContext("traceParent", "traceState", new HashMap<>(),
new HashMap<>());
ExecutionRetryContext retryContext = new ExecutionRetryContext(1, 2, RpcException.newBuilder().build());
String functionName = "ParameterResolverTest";
BindingDataStore dataStore = new BindingDataStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,42 @@ public void TraceContext_test_getAndset_nonEmpty() {
String traceParent = "randomTraceParent";
String traceState = "randomTraceState";
HashMap<String, String> attributes = new HashMap<String, String>();
HashMap<String, String> baggage = new HashMap<String, String>();

attributes.put("key1", "value1");
attributes.put("key2", "value2");
baggage.put("baggageKey1", "baggageValue1");
baggage.put("baggageKey2", "baggageValue2");

TraceContext testTraceContext = new ExecutionTraceContext(traceParent, traceState, attributes);
ExecutionTraceContext testTraceContext = new ExecutionTraceContext(traceParent, traceState, attributes, baggage);
assertEquals(traceParent, testTraceContext.getTraceparent());
assertEquals(traceState, testTraceContext.getTracestate());
assertEquals(traceState, testTraceContext.getTracestate());
assertEquals(attributes, testTraceContext.getAttributes());
assertEquals(baggage, testTraceContext.getBaggage());
}

@Test
public void TraceContext_test_getAndset_Empty() {
String traceParent = "";
String traceState = "";
HashMap<String, String> attributes = new HashMap<String, String>();
TraceContext testTraceContext = new ExecutionTraceContext(traceParent, traceState, attributes);
HashMap<String, String> baggage = new HashMap<String, String>();
ExecutionTraceContext testTraceContext = new ExecutionTraceContext(traceParent, traceState, attributes, baggage);
assertEquals(traceParent, testTraceContext.getTraceparent());
assertEquals(traceState, testTraceContext.getTracestate());
assertEquals(traceState, testTraceContext.getTracestate());
assertEquals(attributes, testTraceContext.getAttributes());
assertEquals(baggage, testTraceContext.getBaggage());
}

@Test
public void TraceContext_test_getAndset_Null() {
TraceContext testTraceContext = new ExecutionTraceContext(null, null, null);
ExecutionTraceContext testTraceContext = new ExecutionTraceContext(null, null, null, null);
assertEquals(null, testTraceContext.getTraceparent());
assertEquals(null, testTraceContext.getTracestate());
assertEquals(null, testTraceContext.getTracestate());
assertEquals(null, testTraceContext.getAttributes());
assertEquals(null, testTraceContext.getBaggage());
}
}
}