@@ -311,9 +311,9 @@ static void endSpan(@Nullable Span span, @Nullable Throwable error) {
311311 }
312312
313313 /**
314- * Creates a synthetic Client-kind trace context for scheduling an activity or sub-orchestration .
315- * Does NOT create or export a real span — just generates a new span ID under the parent trace .
316- * The returned context is propagated as {@code parentTraceContext} on the action so the
314+ * Creates a synthetic trace context with a new span ID under the parent trace .
315+ * Does NOT create or export a real span — just generates a new span ID for propagation .
316+ * The returned context is set as {@code parentTraceContext} on the action so the
317317 * server-side span becomes a child of the synthetic client span ID.
318318 * At completion time, {@link #emitRetroactiveClientSpan} creates a real span with this
319319 * span ID (via {@link #setSpanId}) to provide proper duration and attributes.
@@ -323,13 +323,7 @@ static void endSpan(@Nullable Span span, @Nullable Throwable error) {
323323 * the parent context is invalid.
324324 */
325325 @ Nullable
326- static TraceContext createClientSpan (
327- String spanName ,
328- @ Nullable TraceContext parentContext ,
329- String type ,
330- String taskName ,
331- @ Nullable String instanceId ,
332- int taskId ) {
326+ static TraceContext createSyntheticClientContext (@ Nullable TraceContext parentContext ) {
333327 if (parentContext == null || parentContext .getTraceParent () == null
334328 || parentContext .getTraceParent ().isEmpty ()) {
335329 return null ;
@@ -454,14 +448,15 @@ static void emitTimerSpan(
454448 }
455449
456450 /**
457- * Emits a short-lived Producer span for an event raised from the orchestrator (worker side).
458- * Matches .NET SDK's {@code StartTraceActivityForEventRaisedFromWorker}.
451+ * Emits a short-lived Producer span for an event raised from orchestrator (worker) or client.
452+ * Matches .NET SDK's {@code StartTraceActivityForEventRaisedFromWorker} and
453+ * {@code StartActivityForNewEventRaisedFromClient}.
459454 *
460455 * @param eventName The name of the event being raised.
461- * @param instanceId The orchestration instance ID sending the event .
456+ * @param instanceId The orchestration instance ID (worker-side), may be {@code null} .
462457 * @param targetInstanceId The target orchestration instance ID, may be {@code null}.
463458 */
464- static void emitEventRaisedFromWorkerSpan (
459+ static void emitEventSpan (
465460 String eventName ,
466461 @ Nullable String instanceId ,
467462 @ Nullable String targetInstanceId ) {
@@ -479,32 +474,6 @@ static void emitEventRaisedFromWorkerSpan(
479474 spanBuilder .setAttribute (ATTR_EVENT_TARGET_INSTANCE_ID , targetInstanceId );
480475 }
481476
482- Span span = spanBuilder .startSpan ();
483- span .end ();
484- }
485-
486- /**
487- * Emits a short-lived Producer span for an event raised from the client.
488- * Matches .NET SDK's {@code StartActivityForNewEventRaisedFromClient}.
489- *
490- * @param eventName The name of the event being raised.
491- * @param targetInstanceId The target orchestration instance ID.
492- */
493- static void emitEventRaisedFromClientSpan (
494- String eventName ,
495- @ Nullable String targetInstanceId ) {
496- Tracer tracer = GlobalOpenTelemetry .getTracer (TRACER_NAME );
497- SpanBuilder spanBuilder = tracer .spanBuilder (
498- TYPE_ORCHESTRATION_EVENT + ":" + eventName )
499- .setSpanKind (SpanKind .PRODUCER )
500- .setAttribute (ATTR_TYPE , TYPE_EVENT )
501- .setAttribute (ATTR_TASK_NAME , eventName );
502-
503- if (targetInstanceId != null ) {
504- spanBuilder .setAttribute (ATTR_EVENT_TARGET_INSTANCE_ID , targetInstanceId );
505- }
506-
507- Span span = spanBuilder .startSpan ();
508- span .end ();
477+ spanBuilder .startSpan ().end ();
509478 }
510479}
0 commit comments