Skip to content

Commit d2f52d4

Browse files
authored
Merge branch 'master' into augusto/update-microbenchmark-bp-branch
2 parents 938acc8 + 482a2fd commit d2f52d4

File tree

230 files changed

+1219
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+1219
-194
lines changed

profiler/build/install_timeit.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@echo off
22

3-
dotnet tool update -g timeitsharp --version 0.4.5 --allow-downgrade
3+
dotnet tool update -g timeitsharp --version 0.4.6 --allow-downgrade
44

55
rem Add %USERPROFILE%\.dotnet\tools to Path if it is not already there
66
path|find /i "%USERPROFILE%\.dotnet\tools" >nul || set path=%path%;"%USERPROFILE%\.dotnet\tools"

profiler/build/install_timeit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
dotnet tool update -g timeitsharp --version 0.4.5 --allow-downgrade
2+
dotnet tool update -g timeitsharp --version 0.4.6 --allow-downgrade

tracer/build/timeit/Samples.FakeDbCommand/run.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ set FAILED=0
2828
echo *********************
2929
echo Installing timeitsharp
3030
echo *********************
31-
dotnet tool update -g timeitsharp --version 0.4.5 --allow-downgrade
31+
dotnet tool update -g timeitsharp --version 0.4.6 --allow-downgrade
3232

3333
echo *********************
3434
echo .NET Framework 4.8

tracer/build/timeit/Samples.HttpMessageHandler/run.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ set FAILED=0
2828
echo *********************
2929
echo Installing timeitsharp
3030
echo *********************
31-
dotnet tool update -g timeitsharp --version 0.4.5 --allow-downgrade
31+
dotnet tool update -g timeitsharp --version 0.4.6 --allow-downgrade
3232

3333
echo *********************
3434
echo .NET Framework 4.8

tracer/src/Datadog.Trace/Agent/DiscoveryService/AgentConfiguration.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ internal record AgentConfiguration
1212
public AgentConfiguration(
1313
string? configurationEndpoint,
1414
string? debuggerEndpoint,
15+
string? debuggerV2Endpoint,
16+
string? diagnosticsEndpoint,
1517
string? symbolDbEndpoint,
1618
string? agentVersion,
1719
string? statsEndpoint,
@@ -20,12 +22,12 @@ public AgentConfiguration(
2022
string? telemetryProxyEndpoint,
2123
string? tracerFlareEndpoint,
2224
bool clientDropP0,
23-
string? diagnosticsEndpoint,
2425
bool spanMetaStructs,
2526
bool? spanEvents)
2627
{
2728
ConfigurationEndpoint = configurationEndpoint;
2829
DebuggerEndpoint = debuggerEndpoint;
30+
DebuggerV2Endpoint = debuggerV2Endpoint;
2931
DiagnosticsEndpoint = diagnosticsEndpoint;
3032
SymbolDbEndpoint = symbolDbEndpoint;
3133
AgentVersion = agentVersion;
@@ -43,6 +45,8 @@ public AgentConfiguration(
4345

4446
public string? DebuggerEndpoint { get; }
4547

48+
public string? DebuggerV2Endpoint { get; }
49+
4650
public string? DiagnosticsEndpoint { get; }
4751

4852
public string? SymbolDbEndpoint { get; }

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace Datadog.Trace.Agent.DiscoveryService
2020
internal class DiscoveryService : IDiscoveryService
2121
{
2222
private const string SupportedDebuggerEndpoint = "debugger/v1/input";
23+
private const string SupportedDebuggerV2Endpoint = "debugger/v2/input";
2324
private const string SupportedDiagnosticsEndpoint = "debugger/v1/diagnostics";
2425
private const string SupportedSymbolDbEndpoint = "symdb/v1/input";
2526
private const string SupportedConfigurationEndpoint = "v0.7/config";
@@ -66,6 +67,7 @@ public DiscoveryService(
6667
new[]
6768
{
6869
SupportedDebuggerEndpoint,
70+
SupportedDebuggerV2Endpoint,
6971
SupportedDiagnosticsEndpoint,
7072
SupportedSymbolDbEndpoint,
7173
SupportedConfigurationEndpoint,
@@ -223,6 +225,7 @@ private async Task ProcessDiscoveryResponse(IApiResponse response)
223225
var discoveredEndpoints = (jObject["endpoints"] as JArray)?.Values<string>().ToArray();
224226
string? configurationEndpoint = null;
225227
string? debuggerEndpoint = null;
228+
string? debuggerV2Endpoint = null;
226229
string? diagnosticsEndpoint = null;
227230
string? symbolDbEndpoint = null;
228231
string? statsEndpoint = null;
@@ -246,6 +249,10 @@ private async Task ProcessDiscoveryResponse(IApiResponse response)
246249
{
247250
debuggerEndpoint = endpoint;
248251
}
252+
else if (endpoint.Equals(SupportedDebuggerV2Endpoint, StringComparison.OrdinalIgnoreCase))
253+
{
254+
debuggerV2Endpoint = endpoint;
255+
}
249256
else if (endpoint.Equals(SupportedDiagnosticsEndpoint, StringComparison.OrdinalIgnoreCase))
250257
{
251258
diagnosticsEndpoint = endpoint;
@@ -290,7 +297,8 @@ private async Task ProcessDiscoveryResponse(IApiResponse response)
290297
var newConfig = new AgentConfiguration(
291298
configurationEndpoint: configurationEndpoint,
292299
debuggerEndpoint: debuggerEndpoint,
293-
diagnosticsEndpoint: diagnosticsEndpoint ?? debuggerEndpoint,
300+
debuggerV2Endpoint: debuggerV2Endpoint ?? diagnosticsEndpoint,
301+
diagnosticsEndpoint: diagnosticsEndpoint,
294302
symbolDbEndpoint: symbolDbEndpoint,
295303
agentVersion: agentVersion,
296304
statsEndpoint: statsEndpoint,

tracer/src/Datadog.Trace/Debugger/DebuggerFactory.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ internal class DebuggerFactory
3030
internal static DynamicInstrumentation CreateDynamicInstrumentation(IDiscoveryService discoveryService, IRcmSubscriptionManager remoteConfigurationManager, TracerSettings tracerSettings, string serviceName, DebuggerSettings debuggerSettings, IGitMetadataTagsProvider gitMetadataTagsProvider)
3131
{
3232
var snapshotSlicer = SnapshotSlicer.Create(debuggerSettings);
33-
var snapshotStatusSink = SnapshotSink.Create(debuggerSettings, snapshotSlicer);
33+
var snapshotSink = SnapshotSink.Create(debuggerSettings, snapshotSlicer);
34+
var logSink = SnapshotSink.Create(debuggerSettings, snapshotSlicer);
3435
var diagnosticsSink = DiagnosticsSink.Create(serviceName, debuggerSettings);
3536

36-
var debuggerUploader = CreateSnapshotUploader(discoveryService, debuggerSettings, gitMetadataTagsProvider, GetApiFactory(tracerSettings, false), snapshotStatusSink);
37+
var snapshotUploader = CreateSnapshotUploader(discoveryService, debuggerSettings, gitMetadataTagsProvider, GetApiFactory(tracerSettings, true), snapshotSink);
38+
var logUploader = CreateSnapshotUploader(discoveryService, debuggerSettings, gitMetadataTagsProvider, GetApiFactory(tracerSettings, false), logSink);
3739
var diagnosticsUploader = CreateDiagnosticsUploader(discoveryService, debuggerSettings, gitMetadataTagsProvider, GetApiFactory(tracerSettings, true), diagnosticsSink);
3840
var lineProbeResolver = LineProbeResolver.Create(debuggerSettings.ThirdPartyDetectionExcludes, debuggerSettings.ThirdPartyDetectionIncludes);
3941
var probeStatusPoller = ProbeStatusPoller.Create(diagnosticsSink, debuggerSettings);
@@ -46,7 +48,8 @@ internal static DynamicInstrumentation CreateDynamicInstrumentation(IDiscoverySe
4648
discoveryService: discoveryService,
4749
remoteConfigurationManager: remoteConfigurationManager,
4850
lineProbeResolver: lineProbeResolver,
49-
snapshotUploader: debuggerUploader,
51+
snapshotUploader: snapshotUploader,
52+
logUploader: logUploader,
5053
diagnosticsUploader: diagnosticsUploader,
5154
probeStatusPoller: probeStatusPoller,
5255
configurationUpdater: configurationUpdater,
@@ -70,12 +73,22 @@ private static IDogStatsd GetDogStatsd(TracerSettings tracerSettings, string ser
7073
return statsd;
7174
}
7275

73-
private static SnapshotUploader CreateSnapshotUploader(IDiscoveryService discoveryService, DebuggerSettings debuggerSettings, IGitMetadataTagsProvider gitMetadataTagsProvider, IApiRequestFactory apiFactory, SnapshotSink snapshotStatusSink)
76+
private static SnapshotUploader CreateSnapshotUploader(IDiscoveryService discoveryService, DebuggerSettings debuggerSettings, IGitMetadataTagsProvider gitMetadataTagsProvider, IApiRequestFactory apiFactory, SnapshotSink snapshotSink)
7477
{
7578
var snapshotBatchUploadApi = DebuggerUploadApiFactory.CreateSnapshotUploadApi(apiFactory, discoveryService, gitMetadataTagsProvider);
7679
var snapshotBatchUploader = BatchUploader.Create(snapshotBatchUploadApi);
7780

78-
var debuggerSink = SnapshotUploader.Create(snapshotStatusSink, snapshotBatchUploader, debuggerSettings);
81+
var debuggerSink = SnapshotUploader.Create(snapshotSink, snapshotBatchUploader, debuggerSettings);
82+
83+
return debuggerSink;
84+
}
85+
86+
private static SnapshotUploader CreateLogUploader(IDiscoveryService discoveryService, DebuggerSettings debuggerSettings, IGitMetadataTagsProvider gitMetadataTagsProvider, IApiRequestFactory apiFactory, SnapshotSink snapshotSink)
87+
{
88+
var logUploaderApi = DebuggerUploadApiFactory.CreateLogUploadApi(apiFactory, discoveryService, gitMetadataTagsProvider);
89+
var logBatchUploader = BatchUploader.Create(logUploaderApi);
90+
91+
var debuggerSink = SnapshotUploader.Create(snapshotSink, logBatchUploader, debuggerSettings);
7992

8093
return debuggerSink;
8194
}

tracer/src/Datadog.Trace/Debugger/DynamicInstrumentation.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ internal class DynamicInstrumentation : IDisposable
3838
private readonly IRcmSubscriptionManager _subscriptionManager;
3939
private readonly ISubscription _subscription;
4040
private readonly ISnapshotUploader _snapshotUploader;
41+
private readonly ISnapshotUploader _logUploader;
4142
private readonly IDebuggerUploader _diagnosticsUploader;
4243
private readonly ILineProbeResolver _lineProbeResolver;
4344
private readonly List<ProbeDefinition> _unboundProbes;
@@ -54,6 +55,7 @@ internal DynamicInstrumentation(
5455
IRcmSubscriptionManager remoteConfigurationManager,
5556
ILineProbeResolver lineProbeResolver,
5657
ISnapshotUploader snapshotUploader,
58+
ISnapshotUploader logUploader,
5759
IDebuggerUploader diagnosticsUploader,
5860
IProbeStatusPoller probeStatusPoller,
5961
ConfigurationUpdater configurationUpdater,
@@ -65,6 +67,7 @@ internal DynamicInstrumentation(
6567
_discoveryService = discoveryService;
6668
_lineProbeResolver = lineProbeResolver;
6769
_snapshotUploader = snapshotUploader;
70+
_logUploader = logUploader;
6871
_diagnosticsUploader = diagnosticsUploader;
6972
_probeStatusPoller = probeStatusPoller;
7073
_subscriptionManager = remoteConfigurationManager;
@@ -138,6 +141,13 @@ private void StartBackgroundProcess()
138141
CancellationToken.None,
139142
TaskContinuationOptions.OnlyOnFaulted,
140143
TaskScheduler.Default);
144+
145+
_ = _logUploader.StartFlushingAsync()
146+
.ContinueWith(
147+
t => Log.Error(t?.Exception, "Error in log uploader"),
148+
CancellationToken.None,
149+
TaskContinuationOptions.OnlyOnFaulted,
150+
TaskScheduler.Default);
141151
}
142152

143153
internal void UpdateAddedProbeInstrumentations(IReadOnlyList<ProbeDefinition> addedProbes)
@@ -463,10 +473,27 @@ internal void AddSnapshot(ProbeInfo probe, string snapshot)
463473
return;
464474
}
465475

476+
if (!probe.IsFullSnapshot)
477+
{
478+
AddLog(probe, snapshot);
479+
return;
480+
}
481+
466482
_snapshotUploader.Add(probe.ProbeId, snapshot);
467483
SetProbeStatusToEmitting(probe);
468484
}
469485

486+
internal void AddLog(ProbeInfo probe, string log)
487+
{
488+
if (IsDisposed)
489+
{
490+
return;
491+
}
492+
493+
_logUploader.Add(probe.ProbeId, log);
494+
SetProbeStatusToEmitting(probe);
495+
}
496+
470497
internal void SetProbeStatusToEmitting(ProbeInfo probe)
471498
{
472499
if (IsDisposed)

tracer/src/Datadog.Trace/Debugger/ExceptionAutoInstrumentation/ExceptionReplaySnapshotCreator.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
// </copyright>
55

66
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
9-
using System.Text;
10-
using System.Threading.Tasks;
117
using Datadog.Trace.Debugger.Expressions;
8+
using Datadog.Trace.Debugger.Models;
129
using Datadog.Trace.Debugger.Snapshots;
1310
using ProbeLocation = Datadog.Trace.Debugger.Expressions.ProbeLocation;
1411

@@ -33,6 +30,8 @@ public ExceptionReplaySnapshotCreator(bool isFullSnapshot, ProbeLocation locatio
3330

3431
internal static string FrameIndex { get; } = Guid.NewGuid().ToString();
3532

33+
internal override string DebuggerProduct => DebuggerTags.DebuggerProduct.ER;
34+
3635
internal override DebuggerSnapshotCreator EndSnapshot()
3736
{
3837
JsonWriter.WritePropertyName("exceptionHash");

tracer/src/Datadog.Trace/Debugger/Models/Snapshot.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,32 @@ internal record struct DebuggerSnapshot
4343
{
4444
public SnapshotProbe Snapshot { get; set; }
4545
}
46+
47+
internal static class DebuggerTags
48+
{
49+
/// <summary>
50+
/// ddsource
51+
/// </summary>
52+
internal const string DDSource = "dd_debugger";
53+
54+
/// <summary>
55+
/// Tags for debugger.type
56+
/// </summary>
57+
internal static class DebuggerType
58+
{
59+
internal const string Snapshot = "snapshot";
60+
internal const string Diagnostic = "diagnostic";
61+
internal const string SymDb = "symdb";
62+
}
63+
64+
/// <summary>
65+
/// Tags for debugger.product
66+
/// </summary>
67+
internal static class DebuggerProduct
68+
{
69+
internal const string DI = "di";
70+
internal const string ER = "er";
71+
internal const string LD = "ld";
72+
}
73+
}
4674
}

0 commit comments

Comments
 (0)