@@ -517,33 +517,27 @@ export function processActionsForTracing(
517517 }
518518}
519519
520- /**
521- * Emits a span for calling an entity from an orchestration (request/response).
522- *
523- * @param orchestrationSpan - The parent orchestration span.
524- * @param operationName - The entity operation name.
525- * @param targetInstanceId - The target entity instance ID.
526- * @param taskId - The sequential task ID.
527- */
528- export function emitSpanForEntityCall (
520+ function emitSpanForEntityOperation (
529521 orchestrationSpan : Span ,
530522 operationName : string ,
523+ taskType : string ,
524+ getSpanKind : ( otel : any ) => any ,
531525 targetInstanceId ?: string ,
532526 taskId ?: number ,
533527) : void {
534528 const otel = getOtelApi ( ) ;
535529 const tracer = getTracer ( ) ;
536530 if ( ! otel || ! tracer ) return ;
537531
538- const spanName = createSpanName ( TaskType . CALL_ENTITY , operationName ) ;
532+ const spanName = createSpanName ( taskType , operationName ) ;
539533 const parentContext = otel . trace . setSpan ( otel . context . active ( ) , orchestrationSpan ) ;
540534
541535 const span = tracer . startSpan (
542536 spanName ,
543537 {
544- kind : otel . SpanKind . CLIENT ,
538+ kind : getSpanKind ( otel ) ,
545539 attributes : {
546- [ DurableTaskAttributes . TYPE ] : TaskType . CALL_ENTITY ,
540+ [ DurableTaskAttributes . TYPE ] : taskType ,
547541 [ DurableTaskAttributes . ENTITY_OPERATION ] : operationName ,
548542 ...( targetInstanceId ? { [ DurableTaskAttributes . ENTITY_INSTANCE_ID ] : targetInstanceId } : { } ) ,
549543 ...( taskId !== undefined ? { [ DurableTaskAttributes . TASK_TASK_ID ] : taskId } : { } ) ,
@@ -555,6 +549,30 @@ export function emitSpanForEntityCall(
555549 span . end ( ) ;
556550}
557551
552+ /**
553+ * Emits a span for calling an entity from an orchestration (request/response).
554+ *
555+ * @param orchestrationSpan - The parent orchestration span.
556+ * @param operationName - The entity operation name.
557+ * @param targetInstanceId - The target entity instance ID.
558+ * @param taskId - The sequential task ID.
559+ */
560+ export function emitSpanForEntityCall (
561+ orchestrationSpan : Span ,
562+ operationName : string ,
563+ targetInstanceId ?: string ,
564+ taskId ?: number ,
565+ ) : void {
566+ emitSpanForEntityOperation (
567+ orchestrationSpan ,
568+ operationName ,
569+ TaskType . CALL_ENTITY ,
570+ ( otel ) => otel . SpanKind . CLIENT ,
571+ targetInstanceId ,
572+ taskId ,
573+ ) ;
574+ }
575+
558576/**
559577 * Emits a span for signaling an entity from an orchestration (fire-and-forget).
560578 *
@@ -569,28 +587,14 @@ export function emitSpanForEntitySignal(
569587 targetInstanceId ?: string ,
570588 taskId ?: number ,
571589) : void {
572- const otel = getOtelApi ( ) ;
573- const tracer = getTracer ( ) ;
574- if ( ! otel || ! tracer ) return ;
575-
576- const spanName = createSpanName ( TaskType . SIGNAL_ENTITY , operationName ) ;
577- const parentContext = otel . trace . setSpan ( otel . context . active ( ) , orchestrationSpan ) ;
578-
579- const span = tracer . startSpan (
580- spanName ,
581- {
582- kind : otel . SpanKind . PRODUCER ,
583- attributes : {
584- [ DurableTaskAttributes . TYPE ] : TaskType . SIGNAL_ENTITY ,
585- [ DurableTaskAttributes . ENTITY_OPERATION ] : operationName ,
586- ...( targetInstanceId ? { [ DurableTaskAttributes . ENTITY_INSTANCE_ID ] : targetInstanceId } : { } ) ,
587- ...( taskId !== undefined ? { [ DurableTaskAttributes . TASK_TASK_ID ] : taskId } : { } ) ,
588- } ,
589- } ,
590- parentContext ,
590+ emitSpanForEntityOperation (
591+ orchestrationSpan ,
592+ operationName ,
593+ TaskType . SIGNAL_ENTITY ,
594+ ( otel ) => otel . SpanKind . PRODUCER ,
595+ targetInstanceId ,
596+ taskId ,
591597 ) ;
592-
593- span . end ( ) ;
594598}
595599
596600/**
0 commit comments