Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9a80cbf
read container tags hash from agent
vandonr Dec 2, 2025
661e5db
[IAST] Use recursive_mutex instead of CS and mutex (#7890)
daniel-romano-DD Dec 3, 2025
d565d21
make ContainerMetadata an instance class
vandonr Dec 3, 2025
1ad4b02
use constant in tests
vandonr Dec 3, 2025
37a3ac1
adapt code to instance container metadata
vandonr Dec 4, 2025
c93c3a9
Merge remote-tracking branch 'origin/master' into vandonr/process3
vandonr Jan 5, 2026
66630ec
use local instance
vandonr Jan 5, 2026
dcb297a
nit
vandonr Jan 5, 2026
653a3a5
fix integration tests
vandonr Jan 5, 2026
4fd01fa
add container tags hash to DBM queries (if enabled)
vandonr Jan 14, 2026
d9abd75
use volatile read/write
vandonr Jan 19, 2026
a5f3f8d
use collection expression
vandonr Jan 19, 2026
c18fc65
add container ID header to MinimalAgentHeaderHelper
vandonr Jan 19, 2026
4ca4fdf
Merge remote-tracking branch 'origin/master' into vandonr/process3
vandonr Jan 19, 2026
fdaf436
Merge branch 'vandonr/process3' into vandonr/process2
vandonr Jan 21, 2026
043c8b6
add a class for basehash
vandonr Jan 21, 2026
beb1980
use base hash
vandonr Jan 21, 2026
a75fa60
rename configuration key (I missed the prefix)
vandonr Jan 28, 2026
18f4461
Merge remote-tracking branch 'origin/master' into vandonr/process2
vandonr Feb 4, 2026
7a738b7
fix merge
vandonr Feb 4, 2026
8ace897
add config to json
vandonr Feb 4, 2026
92e4c6e
Merge remote-tracking branch 'origin/master' into vandonr/process2
vandonr Mar 10, 2026
121cae0
remove files that were removed upstream
vandonr Mar 12, 2026
57d31bb
fix nullability && centralize config check
vandonr Mar 12, 2026
3d5ed34
fix test
vandonr Mar 16, 2026
2161f1f
clean imports in adonet instrumentation
vandonr Mar 16, 2026
2f0eeb2
nits
vandonr Mar 16, 2026
1d2679c
Merge remote-tracking branch 'origin/master' into vandonr/process2
vandonr Mar 16, 2026
3d04aad
replace static init with getter init
vandonr Mar 17, 2026
6af872d
rename basehash for clarity
vandonr Mar 17, 2026
d81eb71
apply the same changes to container metadata as in the DSM PR
vandonr Mar 17, 2026
335479d
exclude test that is specific to netcore
vandonr Mar 17, 2026
747be87
Merge remote-tracking branch 'origin/master' into vandonr/process2
vandonr Mar 23, 2026
a89cb3f
move tags hash to serviceremapping hash, make it non-static, feed it …
vandonr Mar 24, 2026
d3c5d7f
reduce number of modified files
vandonr Mar 24, 2026
900ac90
undo some autoformating
vandonr Mar 24, 2026
f1c304e
use url-safe b64
vandonr Mar 24, 2026
91dc0c7
allow SRH injection into tracerManagerFactory
vandonr Mar 24, 2026
44c94a7
fix itest build
vandonr Mar 24, 2026
1c23065
address comments
vandonr Mar 25, 2026
d84c674
move setting check up one call in DbScopeFactory
vandonr Mar 25, 2026
65b181a
add tests to the hash class, and change ctor param to ease testing
vandonr Mar 25, 2026
e1eac20
mini optim: cut only one =
vandonr Mar 25, 2026
e67176d
replace range with slice
vandonr Mar 25, 2026
8fed285
little fixes
vandonr Mar 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tracer/src/Datadog.Trace.Tools.Runner/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ public static async Task<AgentConfiguration> CheckAgentConnectionAsync(string ag
var discoveryService = DiscoveryService.CreateUnmanaged(
settings.Manager.InitialExporterSettings,
ContainerMetadata.Instance,
new ServiceRemappingHash(null),
tcpTimeout: TimeSpan.FromSeconds(5),
initialRetryDelayMs: 200,
maxRetryDelayMs: 1000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal sealed class DiscoveryService : IDiscoveryService
private readonly object _lock = new();
private readonly Task _discoveryTask;
private readonly IDisposable? _settingSubscription;
private readonly ContainerMetadata _containerMetadata;
private readonly ServiceRemappingHash _serviceRemappingHash;
private IApiRequestFactory _apiRequestFactory;
private AgentConfiguration? _configuration;
private string? _configurationHash;
Expand All @@ -57,11 +57,12 @@ internal sealed class DiscoveryService : IDiscoveryService
public DiscoveryService(
TracerSettings.SettingsManager settings,
ContainerMetadata containerMetadata,
ServiceRemappingHash serviceRemappingHash,
TimeSpan tcpTimeout,
int initialRetryDelayMs,
int maxRetryDelayMs,
int recheckIntervalMs)
: this(CreateApiRequestFactory(settings.InitialExporterSettings, containerMetadata.ContainerId, tcpTimeout), containerMetadata, initialRetryDelayMs, maxRetryDelayMs, recheckIntervalMs)
: this(CreateApiRequestFactory(settings.InitialExporterSettings, containerMetadata.ContainerId, tcpTimeout), serviceRemappingHash, initialRetryDelayMs, maxRetryDelayMs, recheckIntervalMs)
{
// Create as a "managed" service that can update the request factory
_settingSubscription = settings.SubscribeToChanges(changes =>
Expand All @@ -80,13 +81,13 @@ public DiscoveryService(
/// </summary>
public DiscoveryService(
IApiRequestFactory apiRequestFactory,
ContainerMetadata containerMetadata,
ServiceRemappingHash serviceRemappingHash,
int initialRetryDelayMs,
int maxRetryDelayMs,
int recheckIntervalMs)
{
_apiRequestFactory = apiRequestFactory;
_containerMetadata = containerMetadata;
_serviceRemappingHash = serviceRemappingHash;
_initialRetryDelayMs = initialRetryDelayMs;
_maxRetryDelayMs = maxRetryDelayMs;
_recheckIntervalMs = recheckIntervalMs;
Expand Down Expand Up @@ -119,10 +120,11 @@ public DiscoveryService(
/// <summary>
/// Create a <see cref="DiscoveryService"/> instance that responds to runtime changes in settings
/// </summary>
public static DiscoveryService CreateManaged(TracerSettings settings, ContainerMetadata containerMetadata)
public static DiscoveryService CreateManaged(TracerSettings settings, ContainerMetadata containerMetadata, ServiceRemappingHash serviceRemappingHash)
=> new(
settings.Manager,
containerMetadata,
serviceRemappingHash,
tcpTimeout: TimeSpan.FromSeconds(15),
initialRetryDelayMs: 500,
maxRetryDelayMs: 5_000,
Expand All @@ -131,10 +133,11 @@ public static DiscoveryService CreateManaged(TracerSettings settings, ContainerM
/// <summary>
/// Create a <see cref="DiscoveryService"/> instance that does _not_ respond to runtime changes in settings
/// </summary>
public static DiscoveryService CreateUnmanaged(ExporterSettings exporterSettings, ContainerMetadata containerMetadata)
public static DiscoveryService CreateUnmanaged(ExporterSettings exporterSettings, ContainerMetadata containerMetadata, ServiceRemappingHash serviceRemappingHash)
=> CreateUnmanaged(
exporterSettings,
containerMetadata,
serviceRemappingHash,
tcpTimeout: TimeSpan.FromSeconds(15),
initialRetryDelayMs: 500,
maxRetryDelayMs: 5_000,
Expand All @@ -146,13 +149,14 @@ public static DiscoveryService CreateUnmanaged(ExporterSettings exporterSettings
public static DiscoveryService CreateUnmanaged(
ExporterSettings exporterSettings,
ContainerMetadata containerMetadata,
ServiceRemappingHash serviceRemappingHash,
TimeSpan tcpTimeout,
int initialRetryDelayMs,
int maxRetryDelayMs,
int recheckIntervalMs)
=> new(
CreateApiRequestFactory(exporterSettings, containerMetadata.ContainerId, tcpTimeout),
containerMetadata,
serviceRemappingHash,
initialRetryDelayMs,
maxRetryDelayMs,
recheckIntervalMs);
Expand Down Expand Up @@ -310,7 +314,7 @@ private async Task ProcessDiscoveryResponse(IApiResponse response)
var containerTagsHash = response.GetHeader(AgentHttpHeaderNames.ContainerTagsHash);
if (containerTagsHash != null)
{
_containerMetadata.ContainerTagsHash = containerTagsHash;
_serviceRemappingHash.UpdateContainerTagsHash(containerTagsHash);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused about how this interacts with the ContainerMetadata? 🤔

As I understand it ContainerMetadata and "ContainerTagsHash" are essentially two completely different concepts at this point? ContainerMetadata is stuff we calculate, the container tags hash is something entirely agent-provided, right?

(This confusion is all on me, mostly due to you having to redo things repeatedly based on my gripes 🙈)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, correct. Container Metadata is something we can know from the tracer, and it's computed once and constant.
There are some container tags that we cannot know from inside the app, so the agent collects them and enriches the spans with them. What we do here is that we ask the agent for a key (hash) corresponding to our container tags (by providing our container ID), so that we can "reference" those container tags in places the agent cannot reach, like DSM checkpoints or DBM query comments.

}

// Grab the original stream
Expand Down Expand Up @@ -429,7 +433,7 @@ private async Task ProcessDiscoveryResponse(IApiResponse response)
eventPlatformProxyEndpoint: eventPlatformProxyEndpoint,
telemetryProxyEndpoint: telemetryProxyEndpoint,
tracerFlareEndpoint: tracerFlareEndpoint,
containerTagsHash: _containerMetadata.ContainerTagsHash, // either the value just received, or the one we stored before (prevents overriding with null)
containerTagsHash: _serviceRemappingHash.ContainerTagsHash, // either the value just received, or the one we stored before (prevents overriding with null)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that correct though? 🤔 If the agent starts sending us null, is that not because something changed about the instance? Should we be second guessing the values we're sent here? (I haven't checked if the RFC spells this out)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really see a practical case where we'd like to reset our container tags hash... Like, either they change or they stay the same, but they cannot really disappear, it'd mean that the app exited the container while still running ^^

At the same time, I don't see a real reason why the agent would reply with null, BUT it could happen if some code path don't request the value in the headers, which could happen for good reasons (we could, for performance reasons, say that we don't need the hash on every single request if we already have one). I feel like it's safer to write it that way, especialy considering how far in the code the code "requesting" the header is

clientDropP0: clientDropP0,
spanMetaStructs: spanMetaStructs,
spanEvents: spanEvents);
Expand Down
1 change: 1 addition & 0 deletions tracer/src/Datadog.Trace/Ci/TestOptimization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public void Initialize()
getDiscoveryServiceFunc: static s => DiscoveryService.CreateUnmanaged(
s.TracerSettings.Manager.InitialExporterSettings,
ContainerMetadata.Instance,
new ServiceRemappingHash(null),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one I'm not 100% sure, but since it's only used for DBM for now, I don't think it'd play any role in that code path, so it should be safe to hardcode a disabled instance

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this seems fine to me, I can't imagine we support DBM or DSM with CI Visibility today 🤔

tcpTimeout: TimeSpan.FromSeconds(5),
initialRetryDelayMs: 100,
maxRetryDelayMs: 1000,
Expand Down
10 changes: 7 additions & 3 deletions tracer/src/Datadog.Trace/Ci/TestOptimizationTracerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public TestOptimizationTracerManager(
IDynamicConfigurationManager dynamicConfigurationManager,
ITracerFlareManager tracerFlareManager,
ISpanEventsManager spanEventsManager,
FeatureFlagsModule featureFlags)
FeatureFlagsModule featureFlags,
ServiceRemappingHash serviceRemappingHash)
: base(
settings,
agentWriter,
Expand All @@ -66,6 +67,7 @@ public TestOptimizationTracerManager(
tracerFlareManager,
spanEventsManager,
featureFlags,
serviceRemappingHash,
GetProcessors(settings.PartialFlushEnabled, agentWriter is CIVisibilityProtocolWriter))
{
}
Expand Down Expand Up @@ -165,7 +167,8 @@ public LockedManager(
IDynamicConfigurationManager dynamicConfigurationManager,
ITracerFlareManager tracerFlareManager,
ISpanEventsManager spanEventsManager,
FeatureFlagsModule featureFlags)
FeatureFlagsModule featureFlags,
ServiceRemappingHash serviceRemappingHash)
: base(
settings,
agentWriter,
Expand All @@ -183,7 +186,8 @@ public LockedManager(
dynamicConfigurationManager,
tracerFlareManager,
spanEventsManager,
featureFlags)
featureFlags,
serviceRemappingHash)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ protected override TracerManager CreateTracerManagerFrom(
IDynamicConfigurationManager dynamicConfigurationManager,
ITracerFlareManager tracerFlareManager,
ISpanEventsManager spanEventsManager,
FeatureFlagsModule featureFlags)
FeatureFlagsModule featureFlags,
ServiceRemappingHash serviceRemappingHash)
{
telemetry.RecordTestOptimizationSettings(_settings);
if (_testOptimizationTracerManagement.UseLockedTracerManager)
{
return new TestOptimizationTracerManager.LockedManager(settings, agentWriter, scopeManager, statsd, runtimeMetrics, logSubmissionManager, telemetry, discoveryService, dataStreamsManager, gitMetadataTagsProvider, traceSampler, spanSampler, remoteConfigurationManager, dynamicConfigurationManager, tracerFlareManager, spanEventsManager, featureFlags);
return new TestOptimizationTracerManager.LockedManager(settings, agentWriter, scopeManager, statsd, runtimeMetrics, logSubmissionManager, telemetry, discoveryService, dataStreamsManager, gitMetadataTagsProvider, traceSampler, spanSampler, remoteConfigurationManager, dynamicConfigurationManager, tracerFlareManager, spanEventsManager, featureFlags, serviceRemappingHash);
}

return new TestOptimizationTracerManager(settings, agentWriter, scopeManager, statsd, runtimeMetrics, logSubmissionManager, telemetry, discoveryService, dataStreamsManager, gitMetadataTagsProvider, traceSampler, spanSampler, remoteConfigurationManager, dynamicConfigurationManager, tracerFlareManager, spanEventsManager, featureFlags);
return new TestOptimizationTracerManager(settings, agentWriter, scopeManager, statsd, runtimeMetrics, logSubmissionManager, telemetry, discoveryService, dataStreamsManager, gitMetadataTagsProvider, traceSampler, spanSampler, remoteConfigurationManager, dynamicConfigurationManager, tracerFlareManager, spanEventsManager, featureFlags, serviceRemappingHash);
}

protected override TelemetrySettings CreateTelemetrySettings(TracerSettings settings)
Expand Down Expand Up @@ -116,7 +117,7 @@ protected override IAgentWriter GetAgentWriter(TracerSettings settings, IStatsdM
return new ApmAgentWriter(settings, updateSampleRates, updateConfigHash, discoveryService, traceBufferSize);
}

internal override IDiscoveryService GetDiscoveryService(TracerSettings settings)
internal override IDiscoveryService GetDiscoveryService(TracerSettings settings, ServiceRemappingHash serviceRemappingHash)
=> _testOptimizationTracerManagement.DiscoveryService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static class DbScopeFactory
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(DbScopeFactory));
private static bool _dbCommandCachingLogged;

private static Scope? CreateDbCommandScope(Tracer tracer, IDbCommand command, IntegrationId integrationId, string dbType, string operationName, string serviceName, string? serviceNameSource, ref DbCommandCache.TagsCacheItem tagsFromConnectionString)
private static Scope? CreateDbCommandScope(Tracer tracer, IDbCommand command, IntegrationId integrationId, string dbType, string operationName, string serviceName, string? serviceNameSource, string? baseHash, ref DbCommandCache.TagsCacheItem tagsFromConnectionString)
{
var perTraceSettings = tracer.CurrentTraceSettings;
if (!perTraceSettings.Settings.IsIntegrationEnabled(integrationId) || !perTraceSettings.Settings.IsIntegrationEnabled(IntegrationId.AdoNet))
Expand Down Expand Up @@ -103,9 +103,15 @@ internal static class DbScopeFactory
}
else
{
// PropagateDataViaComment (service) - this injects varius trace information as a comment in the query
if (baseHash != null)
{
// note: it's ok that we don't write the basehash in the span if "alreadyInjected" because we only need one span to get the tag values
tags.BaseHash = baseHash;
}

// PropagateDataViaComment (service) - this injects various trace information as a comment in the query
// PropagateDataViaContext (full) - this makes a special set context_info for Microsoft SQL Server (nothing else supported)
var traceParentInjectedInComment = DatabaseMonitoringPropagator.PropagateDataViaComment(tracer.Settings.DbmPropagationMode, integrationId, command, tracer.DefaultServiceName, tagsFromConnectionString.DbName, tagsFromConnectionString.OutHost, scope.Span, tracer.Settings.InjectContextIntoStoredProceduresEnabled);
var traceParentInjectedInComment = DatabaseMonitoringPropagator.PropagateDataViaComment(tracer.Settings.DbmPropagationMode, integrationId, command, tracer.DefaultServiceName, tagsFromConnectionString.DbName, tagsFromConnectionString.OutHost, scope.Span, tracer.Settings.InjectContextIntoStoredProceduresEnabled, baseHash);
// try context injection only after comment injection, so that if it fails, we still have service level propagation
var traceParentInjectedInContext = DatabaseMonitoringPropagator.PropagateDataViaContext(tracer.Settings.DbmPropagationMode, integrationId, command, scope.Span);

Expand Down Expand Up @@ -259,6 +265,9 @@ static Cache()
public static Scope? CreateDbCommandScope(Tracer tracer, IDbCommand command)
{
var commandType = command.GetType();
var baseHash = tracer.Settings.PropagateProcessTags && tracer.Settings.DbmInjectSqlBasehash
? tracer.TracerManager.ServiceRemappingHash?.Base64Value
: null; // null if disabled

if (commandType == CommandType && DbTypeName is not null && OperationName is not null)
{
Expand All @@ -274,6 +283,7 @@ static Cache()
operationName: OperationName,
serviceName: cachedServiceName,
serviceNameSource: cachedServiceNameSource,
baseHash: baseHash,
tagsFromConnectionString: ref tagsFromConnectionString);
}

Expand All @@ -292,6 +302,7 @@ static Cache()
operationName: operationName,
serviceName: resolvedServiceName,
serviceNameSource: resolvedServiceNameSource,
baseHash: baseHash,
tagsFromConnectionString: ref tagsFromConnectionString);
}

Expand Down
10 changes: 10 additions & 0 deletions tracer/src/Datadog.Trace/Configuration/TracerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) =
converter: x => ToDbmPropagationInput(x) ?? ParsingResult<DbmPropagationLevel>.Failure(),
validator: null);

DbmInjectSqlBasehash = config
.WithKeys(ConfigurationKeys.DbmInjectSqlBasehash)
.AsBool(false);

RemoteConfigurationEnabled = config.WithKeys(ConfigurationKeys.Rcm.RemoteConfigurationEnabled).AsBool(true);

TraceId128BitGenerationEnabled = config
Expand Down Expand Up @@ -1243,6 +1247,12 @@ not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) =
/// </summary>
internal DbmPropagationLevel DbmPropagationMode { get; }

/// <summary>
/// Gets a value indicating whether the tracer should inject Base Hash in SQL Comments.
/// Default value is false (disabled).
/// </summary>
internal bool DbmInjectSqlBasehash { get; }

/// <summary>
/// Gets a value indicating whether the tracer will generate 128-bit trace ids
/// instead of 64-bits trace ids.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,15 @@ supportedConfigurations:
Configuration key for setting DBM propagation mode
Default value is disabled, expected values are either: disabled, service or full
<seealso cref="Datadog.Trace.Configuration.TracerSettings.DbmPropagationMode"/>
DD_DBM_INJECT_SQL_BASEHASH:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh this configuration key should end with _ENABLED so it should be something like DD_DBM_SQL_BASEHASH_INJECTION_ENABLED. If this ship hasn't already sailed in other languages, can we please fix it 🙏 🥺

- implementation: A
type: boolean
default: 'false'
const_name: DbmInjectSqlBasehash
documentation: |-
Configuration key for enabling or disabling the injection of Base Hash in SQL Comments.
Default value is false (disabled).
<seealso cref="Datadog.Trace.Configuration.TracerSettings.DbmInjectSqlBasehash"/>
DD_DIAGNOSTIC_SOURCE_ENABLED:
- implementation: A
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Threading;
using Datadog.Trace.Configuration;
using Datadog.Trace.Logging;
using Datadog.Trace.PlatformHelpers;
using Datadog.Trace.Propagators;
using Datadog.Trace.Tagging;
using Datadog.Trace.Util;
Expand All @@ -28,6 +29,7 @@ internal static class DatabaseMonitoringPropagator
private const string SqlCommentOuthost = "ddh";
private const string SqlCommentVersion = "ddpv";
private const string SqlCommentEnv = "dde";
private const string SqlCommentBaseHash = "ddsh";
internal const string DbmPrefix = $"/*{SqlCommentSpanService}='";
private const string ContextInfoParameterName = "@dd_trace_context";
internal const string SetContextCommand = $"set context_info {ContextInfoParameterName}";
Expand All @@ -41,7 +43,8 @@ internal static class DatabaseMonitoringPropagator
private static int _remainingDirectionErrorLogs = 100;
private static int _remainingQuoteErrorLogs = 100;

internal static bool PropagateDataViaComment(DbmPropagationLevel propagationLevel, IntegrationId integrationId, IDbCommand command, string configuredServiceName, string? dbName, string? outhost, Span span, bool injectStoredProcedure)
// baseHash should be null if hash injection is disabled, config is not checked in this method
internal static bool PropagateDataViaComment(DbmPropagationLevel propagationLevel, IntegrationId integrationId, IDbCommand command, string configuredServiceName, string? dbName, string? outhost, Span span, bool injectStoredProcedure, string? baseHash)
{
if (integrationId is not (IntegrationId.MySql or IntegrationId.Npgsql or IntegrationId.SqlClient or IntegrationId.Oracle) ||
propagationLevel is not (DbmPropagationLevel.Service or DbmPropagationLevel.Full))
Expand Down Expand Up @@ -103,6 +106,11 @@ propagationLevel is not (DbmPropagationLevel.Service or DbmPropagationLevel.Full
propagatorStringBuilder.Append(',').Append(SqlCommentVersion).Append("='").Append(Uri.EscapeDataString(versionTag)).Append('\'');
}

if (!string.IsNullOrEmpty(baseHash))
{
propagatorStringBuilder.Append(',').Append(SqlCommentBaseHash).Append("='").Append(Uri.EscapeDataString(baseHash)).Append('\'');
}

var traceParentInjected = false;
// For SqlServer & Oracle we don't inject the traceparent to avoid affecting performance, since those DBs generate a new plan for any query changes
if (propagationLevel == DbmPropagationLevel.Full
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ internal static partial class ConfigurationKeys
/// </summary>
public const string ApplicationMonitoringConfigFileEnabled = "DD_APPLICATION_MONITORING_CONFIG_FILE_ENABLED";

/// <summary>
/// Configuration key for enabling or disabling the injection of Base Hash in SQL Comments.
/// Default value is false (disabled).
/// </summary>
/// <seealso cref="Datadog.Trace.Configuration.TracerSettings.DbmInjectSqlBasehash"/>
public const string DbmInjectSqlBasehash = "DD_DBM_INJECT_SQL_BASEHASH";

/// <summary>
/// Configuration key for setting DBM propagation mode
/// Default value is disabled, expected values are either: disabled, service or full
Expand Down
Loading
Loading