StartSpan starts child span in a context.
(ctx context.Context, opName string, opts ...SpanOpt)
| 55 | |
| 56 | // StartSpan starts child span in a context. |
| 57 | func StartSpan(ctx context.Context, opName string, opts ...SpanOpt) (context.Context, *Span) { |
| 58 | config := StartConfig{} |
| 59 | for _, fn := range opts { |
| 60 | fn(&config) |
| 61 | } |
| 62 | tracer := otel.Tracer("") |
| 63 | if parent := trace.SpanFromContext(ctx); parent != nil && parent.SpanContext().IsValid() { |
| 64 | tracer = parent.TracerProvider().Tracer("") |
| 65 | } |
| 66 | ctx, span := tracer.Start(ctx, opName, config.spanOpts...) |
| 67 | return ctx, &Span{otelSpan: span} |
| 68 | } |
| 69 | |
| 70 | // SpanFromContext returns the current Span from the context. |
| 71 | func SpanFromContext(ctx context.Context) *Span { |
no test coverage detected
searching dependent graphs…