|
2 | 2 | // Licensed under the MIT License. |
3 | 3 | package com.microsoft.durabletask; |
4 | 4 |
|
5 | | -import com.google.protobuf.StringValue; |
6 | | -import com.google.protobuf.Timestamp; |
7 | | -import com.microsoft.durabletask.implementation.protobuf.OrchestratorService.*; |
8 | | -import com.microsoft.durabletask.implementation.protobuf.TaskHubSidecarServiceGrpc; |
9 | | -import com.microsoft.durabletask.implementation.protobuf.TaskHubSidecarServiceGrpc.*; |
10 | | - |
11 | | -import io.grpc.*; |
12 | | - |
13 | | -import javax.annotation.Nullable; |
14 | 5 | import java.time.Duration; |
15 | 6 | import java.time.Instant; |
16 | | -import java.util.*; |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.List; |
| 9 | +import java.util.Optional; |
| 10 | +import java.util.UUID; |
17 | 11 | import java.util.concurrent.TimeUnit; |
18 | 12 | import java.util.concurrent.TimeoutException; |
19 | 13 | import java.util.logging.Logger; |
20 | 14 |
|
| 15 | +import javax.annotation.Nullable; |
| 16 | + |
| 17 | +import com.google.protobuf.StringValue; |
| 18 | +import com.google.protobuf.Timestamp; |
| 19 | +import com.microsoft.durabletask.implementation.protobuf.OrchestratorService.*; |
| 20 | +import com.microsoft.durabletask.implementation.protobuf.TaskHubSidecarServiceGrpc; |
| 21 | +import com.microsoft.durabletask.implementation.protobuf.TaskHubSidecarServiceGrpc.TaskHubSidecarServiceBlockingStub; |
| 22 | + |
| 23 | +import io.grpc.Channel; |
| 24 | +import io.grpc.ManagedChannel; |
| 25 | +import io.grpc.ManagedChannelBuilder; |
| 26 | +import io.grpc.Status; |
| 27 | +import io.grpc.StatusRuntimeException; |
| 28 | + |
21 | 29 | /** |
22 | 30 | * Durable Task client implementation that uses gRPC to connect to a remote "sidecar" process. |
23 | 31 | */ |
@@ -110,6 +118,16 @@ public String scheduleNewOrchestrationInstance( |
110 | 118 | builder.setScheduledStartTimestamp(ts); |
111 | 119 | } |
112 | 120 |
|
| 121 | + String traceParent = options.getTraceParent(); |
| 122 | + String traceState = options.getTraceState(); |
| 123 | + if (traceParent != null) { |
| 124 | + TraceContext traceContext = TraceContext.newBuilder() |
| 125 | + .setTraceParent(traceParent) |
| 126 | + .setTraceState(traceState != null ? StringValue.of(traceState) : StringValue.getDefaultInstance()) |
| 127 | + .build(); |
| 128 | + builder.setParentTraceContext(traceContext); // Set the TraceContext in the CreateInstanceRequest |
| 129 | + } |
| 130 | + |
113 | 131 | CreateInstanceRequest request = builder.build(); |
114 | 132 | CreateInstanceResponse response = this.sidecarClient.startInstance(request); |
115 | 133 | return response.getInstanceId(); |
|
0 commit comments