@@ -297,15 +297,17 @@ func (h *TelemetryCommandHandler) handleEmitLog(ctx context.Context, cmd *applic
297297
298298// ===== TRACE HANDLERS =====
299299
300- func (h * TelemetryCommandHandler ) handleStartSpan (ctx context.Context , cmd * application.StartSpanCommand ) error {
300+ // StartSpanDirect starts a new span and returns its ID directly
301+ // This is the preferred method for starting spans as it returns the span ID
302+ func (h * TelemetryCommandHandler ) StartSpanDirect (ctx context.Context , name string , kind string , attributes map [string ]interface {}) (string , error ) {
301303 if ! h .initialized || h .tracer == nil {
302- return fmt .Errorf ("traces not initialized" )
304+ return "" , fmt .Errorf ("traces not initialized" )
303305 }
304306
305- attrs := convertAttributes (cmd . Attributes )
307+ attrs := convertAttributes (attributes )
306308
307309 var spanKind trace.SpanKind
308- switch cmd . Kind {
310+ switch kind {
309311 case "internal" :
310312 spanKind = trace .SpanKindInternal
311313 case "server" :
@@ -320,7 +322,7 @@ func (h *TelemetryCommandHandler) handleStartSpan(ctx context.Context, cmd *appl
320322 spanKind = trace .SpanKindInternal
321323 }
322324
323- _ , span := h .tracer .Start (ctx , cmd . Name ,
325+ _ , span := h .tracer .Start (ctx , name ,
324326 trace .WithSpanKind (spanKind ),
325327 trace .WithAttributes (attrs ... ),
326328 )
@@ -331,7 +333,12 @@ func (h *TelemetryCommandHandler) handleStartSpan(ctx context.Context, cmd *appl
331333 h .activeSpans [spanID ] = span
332334 h .spansMutex .Unlock ()
333335
334- return nil
336+ return spanID , nil
337+ }
338+
339+ func (h * TelemetryCommandHandler ) handleStartSpan (ctx context.Context , cmd * application.StartSpanCommand ) error {
340+ _ , err := h .StartSpanDirect (ctx , cmd .Name , cmd .Kind , cmd .Attributes )
341+ return err
335342}
336343
337344func (h * TelemetryCommandHandler ) handleEndSpan (ctx context.Context , cmd * application.EndSpanCommand ) error {
0 commit comments