예제 #1
0
        /// <inheritdoc/>
        public override TelemetrySpan StartSpan(string operationName, TelemetrySpan parent, SpanKind kind, SpanCreationOptions options)
        {
            if (parent == null)
            {
                parent = this.CurrentSpan;
            }

            return(SpanSdk.CreateFromParentSpan(operationName, parent, kind, options, this.sampler, this.tracerConfiguration,
                                                this.spanProcessor, this.LibraryResource));
        }
예제 #2
0
        public override IDisposable WithSpan(TelemetrySpan span, bool endSpanOnDispose)
        {
            if (span == null)
            {
                OpenTelemetrySdkEventSource.Log.InvalidArgument("WithSpan", nameof(span), "is null");
            }

            if (span is SpanSdk spanImpl)
            {
                return(spanImpl.BeginScope(endSpanOnDispose));
            }

            return(NoopDisposable.Instance);
        }
예제 #3
0
 public static TelemetrySpan WithSpan(TelemetrySpan span)
 {
     span?.Activate();
     return(span);
 }
예제 #4
0
 /// <summary>
 /// Starts span.
 /// </summary>
 /// <param name="operationName">Span name.</param>
 /// <param name="parent">Parent for new span.</param>
 /// <param name="kind">Kind.</param>
 /// <param name="options">Advanced span creation options.</param>
 /// <returns>Span instance.</returns>
 public abstract TelemetrySpan StartSpan(string operationName, TelemetrySpan parent, SpanKind kind, SpanCreationOptions options);
예제 #5
0
 /// <summary>
 /// Activates the span on the current context.
 /// </summary>
 /// <param name="span">Span to associate with the current context.</param>
 /// <param name="endSpanOnDispose">Flag indicating if span should end when scope is disposed.</param>
 /// <returns>Disposable object to control span to current context association.</returns>
 public abstract IDisposable WithSpan(TelemetrySpan span, bool endSpanOnDispose);
 /// <summary>
 /// Starts active span.
 /// </summary>
 /// <param name="tracer">Tracer instance.</param>
 /// <param name="operationName">Span name.</param>
 /// <param name="parent">Parent for new span.</param>
 /// <param name="span">Created span.</param>
 /// <returns>Scope.</returns>
 public static IDisposable StartActiveSpan(this Tracer tracer, string operationName, SpanContext parent, out TelemetrySpan span)
 {
     span = tracer.StartSpan(operationName, parent, SpanKind.Internal, null);
     return(tracer.WithSpan(span, true));
 }
 /// <summary>
 /// Starts active span.
 /// </summary>
 /// <param name="tracer">Tracer instance.</param>
 /// <param name="operationName">Span name.</param>
 /// <param name="kind">Kind.</param>
 /// <param name="options">Advanced span creation options.</param>
 /// <param name="span">Created span.</param>
 /// <returns>Scope.</returns>
 public static IDisposable StartActiveSpan(this Tracer tracer, string operationName, SpanKind kind, SpanCreationOptions options, out TelemetrySpan span)
 {
     span = tracer.StartSpan(operationName, kind, options);
     return(tracer.WithSpan(span, true));
 }
 /// <summary>
 /// Activates the span on the current context.
 /// </summary>
 /// <param name="tracer">Tracer instance.</param>
 /// <param name="span">Span to activate.</param>
 /// <returns>Disposable object to control span to current context association.</returns>
 public static IDisposable WithSpan(this Tracer tracer, TelemetrySpan span)
 {
     return(tracer.WithSpan(span, false));
 }
 /// <summary>
 /// Starts active span.
 /// </summary>
 /// <param name="tracer">Tracer instance.</param>
 /// <param name="operationName">Span name.</param>
 /// <param name="activity">Parent for new span.</param>
 /// <param name="kind">Kind.</param>
 /// <param name="links">Links collection.</param>
 /// <param name="span">Created span.</param>
 /// <returns>Scope.</returns>
 public static IDisposable StartActiveSpanFromActivity(this Tracer tracer, string operationName, Activity activity, SpanKind kind, IEnumerable <Link> links, out TelemetrySpan span)
 {
     span = tracer.StartSpanFromActivity(operationName, activity, kind, links);
     return(tracer.WithSpan(span, true));
 }
 /// <summary>
 /// Starts active span.
 /// </summary>
 /// <param name="tracer">Tracer instance.</param>
 /// <param name="operationName">Span name.</param>
 /// <param name="activity">Parent for new span.</param>
 /// <param name="span">Created span.</param>
 /// <returns>Scope.</returns>
 public static IDisposable StartActiveSpanFromActivity(this Tracer tracer, string operationName, Activity activity, out TelemetrySpan span)
 {
     span = tracer.StartSpanFromActivity(operationName, activity, SpanKind.Internal, null);
     return(tracer.WithSpan(span, true));
 }
예제 #11
0
 /// <summary>
 /// Starts span.
 /// </summary>
 /// <param name="tracer">Tracer instance.</param>
 /// <param name="operationName">Span name.</param>
 /// <param name="parent">Parent for new span.</param>
 /// <returns>Span instance.</returns>
 public static TelemetrySpan StartSpan(this Tracer tracer, string operationName, TelemetrySpan parent)
 {
     return(tracer.StartSpan(operationName, parent, SpanKind.Internal, null));
 }
예제 #12
0
 public override TelemetrySpan StartSpan(string operationName, TelemetrySpan parent, SpanKind kind, SpanCreationOptions options)
 {
     return(this.realTracer != null?this.realTracer.StartSpan(operationName, parent, kind, options) : BlankSpan.Instance);
 }
예제 #13
0
 /// <inheritdoc/>
 public override IDisposable WithSpan(TelemetrySpan span, bool endOnDispose)
 {
     return(this.realTracer != null?this.realTracer.WithSpan(span, endOnDispose) : NoopScope);
 }