From eabf0b0f4cb1bbc1c37481b3045852c96d63aeb2 Mon Sep 17 00:00:00 2001 From: Ganesh Jangir Date: Tue, 17 Dec 2024 13:04:21 +0100 Subject: [PATCH] add logging --- .../Datadog.Trace/LibDatadog/TraceExporter.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tracer/src/Datadog.Trace/LibDatadog/TraceExporter.cs b/tracer/src/Datadog.Trace/LibDatadog/TraceExporter.cs index 7c947519ead7..15612e9c84ce 100644 --- a/tracer/src/Datadog.Trace/LibDatadog/TraceExporter.cs +++ b/tracer/src/Datadog.Trace/LibDatadog/TraceExporter.cs @@ -7,18 +7,27 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using Datadog.Trace.Agent; +using Datadog.Trace.Logging; namespace Datadog.Trace.LibDatadog; internal class TraceExporter : SafeHandle, IApi { + private static readonly IDatadogLogger StaticLog = DatadogLogging.GetLoggerFor(); + private readonly TraceExporterConfiguration _configuration; + private readonly IDatadogLogger _log; - public TraceExporter(TraceExporterConfiguration configuration) + public TraceExporter( + TraceExporterConfiguration configuration, + IDatadogLogger log = null) : base(IntPtr.Zero, true) { + _log = log ?? StaticLog; _configuration = configuration; - var errPtr = TraceExporterNative.ddog_trace_exporter_new(out var ptr, configuration); + + _log.Debug("Creating new TraceExporter"); + var errPtr = TraceExporterNative.ddog_trace_exporter_new(out var ptr, _configuration); errPtr.ThrowIfError(); SetHandle(ptr); } @@ -27,6 +36,8 @@ public TraceExporter(TraceExporterConfiguration configuration) public Task SendTracesAsync(ArraySegment traces, int numberOfTraces, bool statsComputationEnabled, long numberOfDroppedP0Traces, long numberOfDroppedP0Spans, bool appsecStandaloneEnabled) { + _log.Debug("Sending {Count} traces to the Datadog Agent.", numberOfTraces); + // Pin the array to get a pointer to the data // This is recommended if using UnsafeAddrOfPinnedArrayElement to avoid the GC moving the array var tracesHandle = GCHandle.Alloc(traces.Array, GCHandleType.Pinned); @@ -46,6 +57,7 @@ public Task SendTracesAsync(ArraySegment traces, int numberOfTraces, public Task SendStatsAsync(StatsBuffer stats, long bucketDuration) { + _log.Debug("No-op: stats computation happens in the data pipeline."); return Task.FromResult(true); }