-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpTracerExtensions.cs
49 lines (43 loc) · 2.69 KB
/
HttpTracerExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using JetBrains.Annotations;
using Vostok.Tracing.Abstractions;
namespace Vostok.Tracing.Extensions.Http
{
[PublicAPI]
public static class HttpTracerExtensions
{
/// <summary>
/// <para>Begins a span of <see cref="WellKnownSpanKinds.HttpRequest.Client"/> kind and returns a specialized builder to aid in filling relevant annotations.</para>
/// <para>See <see cref="IHttpRequestClientSpanBuilder"/> for more details.</para>
/// <para>If provided <paramref name="operationName"/> is <c>null</c>, <see cref="WellKnownAnnotations.Common.Operation"/> annotation will be inferred from request properties.</para>
/// </summary>
public static IHttpRequestClientSpanBuilder BeginHttpClientSpan([NotNull] this ITracer tracer, [CanBeNull] string operationName = null)
{
if (tracer == null)
throw new ArgumentNullException(nameof(tracer));
return new HttpRequestClientSpanBuilder(tracer.BeginSpan(), operationName);
}
/// <summary>
/// <para>Begins a span of <see cref="WellKnownSpanKinds.HttpRequest.Server"/> kind and returns a specialized builder to aid in filling relevant annotations.</para>
/// <para>See <see cref="IHttpRequestServerSpanBuilder"/> for more details.</para>
/// <para>If provided <paramref name="operationName"/> is <c>null</c>, <see cref="WellKnownAnnotations.Common.Operation"/> annotation will be inferred from request properties.</para>
/// </summary>
public static IHttpRequestServerSpanBuilder BeginHttpServerSpan([NotNull] this ITracer tracer, [CanBeNull] string operationName = null)
{
if (tracer == null)
throw new ArgumentNullException(nameof(tracer));
return new HttpRequestServerSpanBuilder(tracer.BeginSpan(), operationName);
}
/// <summary>
/// <para>Begins a span of <see cref="WellKnownSpanKinds.HttpRequest.Cluster"/> kind and returns a specialized builder to aid in filling relevant annotations.</para>
/// <para>See <see cref="IHttpRequestClusterSpanBuilder"/> for more details.</para>
/// <para>If provided <paramref name="operationName"/> is <c>null</c>, <see cref="WellKnownAnnotations.Common.Operation"/> annotation will be inferred from request properties.</para>
/// </summary>
public static IHttpRequestClusterSpanBuilder BeginHttpClusterSpan([NotNull] this ITracer tracer, [CanBeNull] string operationName = null)
{
if (tracer == null)
throw new ArgumentNullException(nameof(tracer));
return new HttpRequestClusterSpanBuilder(tracer.BeginSpan(), operationName);
}
}
}