-
Notifications
You must be signed in to change notification settings - Fork 17
/
OpenTelemetrySinkOptions.cs
86 lines (73 loc) · 3.46 KB
/
OpenTelemetrySinkOptions.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright © Serilog Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System.Diagnostics;
using System.Net.Http;
using Serilog.Core;
using Serilog.Events;
namespace Serilog.Sinks.OpenTelemetry;
/// <summary>
/// Initialization options for <see cref="OpenTelemetrySink"/>.
/// </summary>
public class OpenTelemetrySinkOptions
{
internal const string DefaultEndpoint = "http://localhost:4317";
internal const OtlpProtocol DefaultProtocol = OtlpProtocol.Grpc;
internal const IncludedData DefaultIncludedData = IncludedData.MessageTemplateTextAttribute |
IncludedData.TraceIdField | IncludedData.SpanIdField |
IncludedData.SpecRequiredResourceAttributes;
/// <summary>
/// The full URL of the OTLP exporter endpoint.
/// </summary>
public string Endpoint { get; set; } = DefaultEndpoint;
/// <summary>
/// A custom HTTP message handler. To suppress tracing of HTTP requests from the sink, set the handler to
/// a <c>SocketsHttpHandler</c> with <c>null</c> <c>ActivityHeadersPropagator</c>:
/// <code>
/// options.HttpMessageHandler = new SocketsHttpHandler { ActivityHeadersPropagator = null };
/// </code>
/// </summary>
public HttpMessageHandler? HttpMessageHandler { get; set; }
/// <summary>
/// The OTLP protocol to use.
/// </summary>
public OtlpProtocol Protocol { get; set; } = DefaultProtocol;
/// <summary>
/// A attributes of the resource attached to the logs generated by the sink. The values must be simple primitive
/// values: integers, doubles, strings, or booleans. Other values will be silently ignored.
/// </summary>
public IDictionary<string, object> ResourceAttributes { get; set; } = new Dictionary<string, object>();
/// <summary>
/// Which fields should be included in the log events generated by the sink. The default is to include <c>TraceId</c>
/// and <c>SpanId</c> when <see cref="Activity.Current"/> is not null, and <c>message_template.text</c>.
/// </summary>
public IncludedData IncludedData { get; set; } = DefaultIncludedData;
/// <summary>
/// Headers to send with network requests.
/// </summary>
public IDictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
/// <summary>
/// Supplies culture-specific formatting information, or null.
/// </summary>
public IFormatProvider? FormatProvider { get; set; }
/// <summary>
/// The minimum level for events passed through the sink. The default value is to not restrict events based on
/// level. Ignored when <see cref="LevelSwitch"/> is specified.
/// </summary>
public LogEventLevel RestrictedToMinimumLevel { get; set; } = LevelAlias.Minimum;
/// <summary>
/// A switch allowing the pass-through minimum level
/// to be changed at runtime.
/// </summary>
public LoggingLevelSwitch? LevelSwitch { get; set; }
}