forked from newrelic/newrelic-telemetry-sdk-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewRelicExporterHelperExtensions.cs
47 lines (43 loc) · 1.86 KB
/
NewRelicExporterHelperExtensions.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
// Copyright 2020 New Relic, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
using System;
using System.Diagnostics;
using NewRelic.OpenTelemetry;
namespace OpenTelemetry.Trace
{
/// <summary>
/// Extension methods to help instantiate and configure the New Relic data exporter.
/// </summary>
public static class NewRelicExporterHelperExtensions
{
/// <summary>
/// Adds New Relic exporter to the TracerProvider.
/// </summary>
/// <param name="builder"><see cref="TracerProviderBuilder"/> builder to use.</param>
/// <param name="configure">A method to configure the exporter options.</param>
/// <returns>The instance of <see cref="TracerProviderBuilder"/> to chain the calls.</returns>
public static TracerProviderBuilder AddNewRelicExporter(this TracerProviderBuilder builder, Action<NewRelicExporterOptions> configure)
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
var options = new NewRelicExporterOptions();
configure?.Invoke(options);
var exporter = new NewRelicTraceExporter(options);
if (options.ExportProcessorType == ExportProcessorType.Simple)
{
return builder.AddProcessor(new SimpleExportProcessor<Activity>(exporter));
}
else
{
return builder.AddProcessor(new BatchExportProcessor<Activity>(
exporter,
options.BatchExportProcessorOptions.MaxQueueSize,
options.BatchExportProcessorOptions.ScheduledDelayMilliseconds,
options.BatchExportProcessorOptions.ExporterTimeoutMilliseconds,
options.BatchExportProcessorOptions.MaxExportBatchSize));
}
}
}
}