Skip to content

Commit 505a4d7

Browse files
committed
Fix telemetry reporting for mutable settings
1 parent 19797cf commit 505a4d7

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

tracer/src/Datadog.Trace/ClrProfiler/AutoInstrumentation/ManualInstrumentation/Tracer/ConfigureIntegration.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ internal static void ConfigureSettingsWithManualOverrides(Dictionary<string, obj
6464
// TODO: these will eventually live elsewhere
6565
var currentSettings = tracerSettings.MutableSettings;
6666

67+
var manualTelemetry = new ConfigurationTelemetry();
6768
var newMutableSettings = MutableSettings.CreateUpdatedMutableSettings(
6869
dynamicConfig,
6970
manualConfig,
7071
initialSettings,
7172
tracerSettings,
72-
TelemetryFactory.Config,
73+
manualTelemetry,
7374
new OverrideErrorLog()); // TODO: We'll later report these
7475

7576
var isSameMutableSettings = currentSettings.Equals(newMutableSettings);
@@ -90,6 +91,12 @@ internal static void ConfigureSettingsWithManualOverrides(Dictionary<string, obj
9091
if (isSameMutableSettings && isSameExporterSettings)
9192
{
9293
Log.Debug("No changes detected in the new configuration in code");
94+
// Even though there were no "real" changes, there may be _effective_ changes in telemetry that
95+
// need to be recorded (e.g. the customer set the value in code but it was already set via
96+
// env vars). We _should_ record exporter settings too, but that introduces a bunch of complexity
97+
// which we'll resolve later anyway, so just have that gap for now (it's very niche).
98+
// If there are changes, they're recorded automatically in ConfigureInternal
99+
manualTelemetry.CopyTo(TelemetryFactory.Config);
93100
return;
94101
}
95102

tracer/src/Datadog.Trace/Configuration/DynamicConfigurationManager.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static void OnConfigurationChanged(IConfigurationSource dynamicConfig)
8080
tracerSettings,
8181
// TODO: In the future this will 'live' elsewhere
8282
currentSettings: tracerSettings.MutableSettings,
83-
TelemetryFactory.Config,
83+
new ConfigurationTelemetry(),
8484
new OverrideErrorLog()); // TODO: We'll later report these
8585
}
8686

@@ -90,7 +90,7 @@ private static void OnConfigurationChanged(
9090
MutableSettings initialSettings,
9191
TracerSettings tracerSettings,
9292
MutableSettings currentSettings,
93-
IConfigurationTelemetry telemetry,
93+
ConfigurationTelemetry telemetry,
9494
OverrideErrorLog errorLog)
9595
{
9696
var newMutableSettings = MutableSettings.CreateUpdatedMutableSettings(
@@ -104,6 +104,12 @@ private static void OnConfigurationChanged(
104104
if (currentSettings.Equals(newMutableSettings))
105105
{
106106
Log.Debug("No changes detected in the new dynamic configuration");
107+
// Even though there were no "real" changes, there may be _effective_ changes in telemetry that
108+
// need to be recorded (e.g. the customer set the value in code but it was already set via
109+
// env vars). We _should_ record exporter settings too, but that introduces a bunch of complexity
110+
// which we'll resolve later anyway, so just have that gap for now (it's very niche).
111+
// If there are changes, they're recorded automatically in ConfigureInternal
112+
telemetry.CopyTo(TelemetryFactory.Config);
107113
return;
108114
}
109115

tracer/src/Datadog.Trace/Telemetry/TelemetryController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ public void RecordTracerSettings(TracerSettings settings, string defaultServiceN
9595
// ImmutableTracerSettings, at which point that config would become "current", so we
9696
// need to keep it around
9797
settings.Telemetry.CopyTo(_configuration);
98+
// if the mutable settings have changed since the start, re-record them
99+
// to ensure they have the correct values. This is a temporary measure before
100+
// we fully extract mutable settings
101+
if (!ReferenceEquals(settings.MutableSettings, settings.InitialMutableSettings))
102+
{
103+
settings.MutableSettings.Telemetry.CopyTo(_configuration);
104+
}
105+
98106
_application.RecordTracerSettings(settings, defaultServiceName);
99107
_namingVersion = ((int)settings.MetadataSchemaVersion).ToString();
100108
_logTagBuilder.Update(settings);

0 commit comments

Comments
 (0)