Skip to content

Commit 2f1cb24

Browse files
Remove remaining '#if NET6_0_OR_GREATER' directives on OTLP Trace export code paths.
Note: The OTLP Metrics export will need to be updated to be supported below net6.0 for trace metrics to be supported on all runtimes.
1 parent 20beb10 commit 2f1cb24

3 files changed

Lines changed: 4 additions & 9 deletions

File tree

tracer/src/Datadog.Trace/Agent/ApiOtlp.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
44
// </copyright>
55

6-
#if NET6_0_OR_GREATER
7-
86
using System;
97
using System.Collections.Generic;
108
using System.IO;
@@ -37,7 +35,9 @@ internal sealed class ApiOtlp : IApi
3735
private readonly Uri _statsEndpoint; // This endpoint is passed for the _sendStats callback, but otherwise unused
3836
private readonly SendCallback<SendStatsState> _sendStats;
3937
private readonly SendCallback<SendTracesState> _sendTraces;
38+
#if NET6_0_OR_GREATER
4039
private readonly Datadog.Trace.OpenTelemetry.Metrics.OtlpExporter _metricsExporter;
40+
#endif
4141

4242
public ApiOtlp(IApiRequestFactory apiRequestFactory, TracerSettings settings, ExporterSettings exporterSettings, IDatadogLogger log = null)
4343
{
@@ -54,7 +54,9 @@ public ApiOtlp(IApiRequestFactory apiRequestFactory, TracerSettings settings, Ex
5454
_statsEndpoint = exporterSettings.OtlpMetricsEndpoint;
5555
_log.Debug("Using traces endpoint {TracesEndpoint}", _tracesEndpoint.ToString());
5656

57+
#if NET6_0_OR_GREATER
5758
_metricsExporter = new Datadog.Trace.OpenTelemetry.Metrics.OtlpExporter(settings, exporterSettings);
59+
#endif
5860
}
5961

6062
private delegate Task<SendResult> SendCallback<T>(IApiRequest request, bool isFinalTry, T state);
@@ -309,4 +311,3 @@ public SendStatsState(StatsBuffer stats, long bucketDuration, int tracerObfuscat
309311
}
310312
}
311313
}
312-
#endif

tracer/src/Datadog.Trace/Agent/ManagedApiOtlp.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc.
44
// </copyright>
55

6-
#if NET6_0_OR_GREATER
7-
86
#nullable enable
97

108
using System;
@@ -50,5 +48,3 @@ public Task<bool> SendTracesAsync(ArraySegment<byte> traces, int numberOfTraces,
5048
public Task<bool> SendStatsAsync(StatsBuffer stats, long bucketDuration, int tracerObfuscationVersion)
5149
=> Volatile.Read(ref _api).SendStatsAsync(stats, bucketDuration, tracerObfuscationVersion);
5250
}
53-
54-
#endif

tracer/src/Datadog.Trace/TracerManagerFactory.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,13 @@ protected virtual ISpanSampler GetSpanSampler(TracerSettings settings)
293293

294294
protected virtual IAgentWriter GetAgentWriter(TracerSettings settings, IStatsdManager statsd, Action<Dictionary<string, float>> updateSampleRates, Action<string> updateConfigHash, IDiscoveryService discoveryService, TelemetrySettings telemetrySettings)
295295
{
296-
#if NET6_0_OR_GREATER
297296
if (settings.Manager.InitialExporterSettings.TracesEncoding is TracesEncoding.OtlpProtobuf or TracesEncoding.OtlpJson)
298297
{
299298
var otlpApi = new ManagedApiOtlp(settings);
300299
var otlpStatsAggregator = StatsAggregator.Create(otlpApi, settings, discoveryService, isOtlp: true);
301300
return new AgentWriter(otlpApi, otlpStatsAggregator, statsd, settings);
302301
}
303302

304-
#endif
305303
// Currently we assume this _can't_ toggle at runtime, may need to revisit this if that changes
306304
IApi api = settings.DataPipelineEnabled && ManagedTraceExporter.TryCreateTraceExporter(settings, updateSampleRates, telemetrySettings, out var traceExporter)
307305
? traceExporter

0 commit comments

Comments
 (0)