Skip to content

Commit 2bc63f6

Browse files
committed
Remove Exporter property from TracerSettings
1 parent 2ae6175 commit 2bc63f6

File tree

5 files changed

+23
-40
lines changed

5 files changed

+23
-40
lines changed

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

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry te
136136
.AsBoolResult()
137137
.OverrideWith(in otelActivityListenerEnabled, ErrorLog, defaultValue: false);
138138

139-
Exporter = new ExporterSettings(source, _telemetry);
139+
var exporter = new ExporterSettings(source, _telemetry);
140140

141141
PeerServiceTagsEnabled = config
142142
.WithKeys(ConfigurationKeys.PeerServiceDefaultsEnabled)
@@ -364,7 +364,11 @@ not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) =
364364

365365
// Windows supports UnixDomainSocket https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
366366
// but tokio hasn't added support for it yet https://github.com/tokio-rs/tokio/issues/2201
367-
if (Exporter.TracesTransport == TracesTransportType.UnixDomainSocket && FrameworkDescription.Instance.IsWindows())
367+
// There's an issue here, in that technically a user can initially be configured to send over TCP/named pipes,
368+
// and so we allow and enable the datapipeline. Later, they could configure the app in code to send over UDS.
369+
// This is a problem, as we currently don't support toggling the data pipeline at runtime, so we explicitly block
370+
// this scenario in the public API.
371+
if (exporter.TracesTransport == TracesTransportType.UnixDomainSocket && FrameworkDescription.Instance.IsWindows())
368372
{
369373
DataPipelineEnabled = false;
370374
Log.Warning(
@@ -736,7 +740,7 @@ not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) =
736740

737741
// Move the creation of these settings inside SettingsManager?
738742
var initialMutableSettings = MutableSettings.CreateInitialMutableSettings(source, telemetry, errorLog, this);
739-
Manager = new(this, initialMutableSettings, Exporter);
743+
Manager = new(this, initialMutableSettings, exporter);
740744
}
741745

742746
internal bool IsRunningInCiVisibility { get; }
@@ -894,11 +898,6 @@ not null when string.Equals(value, "otlp", StringComparison.OrdinalIgnoreCase) =
894898
/// <seealso cref="ConfigurationKeys.DisabledActivitySources"/>
895899
internal string[] DisabledActivitySources { get; }
896900

897-
/// <summary>
898-
/// Gets the transport settings that dictate how the tracer connects to the agent.
899-
/// </summary>
900-
public ExporterSettings Exporter { get; init; }
901-
902901
/// <summary>
903902
/// Gets a value indicating the format for custom trace sampling rules ("regex" or "glob").
904903
/// If the value is not recognized, trace sampling rules are disabled.
@@ -1351,19 +1350,5 @@ internal static TracerSettings Create(Dictionary<string, object?> settings)
13511350

13521351
internal static TracerSettings Create(Dictionary<string, object?> settings, LibDatadogAvailableResult isLibDatadogAvailable)
13531352
=> new(new DictionaryConfigurationSource(settings.ToDictionary(x => x.Key, x => x.Value?.ToString()!)), new ConfigurationTelemetry(), new(), isLibDatadogAvailable);
1354-
1355-
internal void CollectTelemetry(IConfigurationTelemetry destination)
1356-
{
1357-
// copy the current settings into telemetry
1358-
_telemetry.CopyTo(destination);
1359-
1360-
// If ExporterSettings has been replaced, it will have its own telemetry collector
1361-
// so we need to record those values too.
1362-
if (Exporter.Telemetry is { } exporterTelemetry
1363-
&& exporterTelemetry != _telemetry)
1364-
{
1365-
exporterTelemetry.CopyTo(destination);
1366-
}
1367-
}
13681353
}
13691354
}

tracer/test/Datadog.Trace.Tests/Configuration/ConfigurationSourceTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public ConfigurationSourceTests()
7272
public static IEnumerable<(Func<TracerSettings, object> SettingGetter, object ExpectedValue)> GetDefaultTestData()
7373
{
7474
yield return (s => s.Manager.InitialMutableSettings.TraceEnabled, true);
75-
yield return (s => s.Exporter.AgentUri, new Uri("http://127.0.0.1:8126/"));
75+
yield return (s => s.Manager.InitialExporterSettings.AgentUri, new Uri("http://127.0.0.1:8126/"));
7676
yield return (s => s.Manager.InitialMutableSettings.Environment, null);
7777
yield return (s => s.Manager.InitialMutableSettings.ServiceName, null);
7878
yield return (s => s.Manager.InitialMutableSettings.DisabledIntegrationNames.Count, 1); // The OpenTelemetry integration is disabled by default
@@ -84,7 +84,7 @@ public ConfigurationSourceTests()
8484
yield return (s => s.Manager.InitialMutableSettings.CustomSamplingRules, null);
8585
yield return (s => s.Manager.InitialMutableSettings.MaxTracesSubmittedPerSecond, 100);
8686
yield return (s => s.Manager.InitialMutableSettings.TracerMetricsEnabled, false);
87-
yield return (s => s.Exporter.DogStatsdPort, 8125);
87+
yield return (s => s.Manager.InitialExporterSettings.DogStatsdPort, 8125);
8888
yield return (s => s.PropagationStyleInject, new[] { "Datadog", "tracecontext", "baggage" });
8989
yield return (s => s.PropagationStyleExtract, new[] { "Datadog", "tracecontext", "baggage" });
9090
yield return (s => s.Manager.InitialMutableSettings.ServiceNameMappings, new string[0]);
@@ -107,8 +107,8 @@ public ConfigurationSourceTests()
107107
yield return (ConfigurationKeys.TraceEnabled, "true", s => s.Manager.InitialMutableSettings.TraceEnabled, true);
108108
yield return (ConfigurationKeys.TraceEnabled, "false", s => s.Manager.InitialMutableSettings.TraceEnabled, false);
109109

110-
yield return (ConfigurationKeys.AgentHost, "test-host", s => s.Exporter.AgentUri, new Uri("http://test-host:8126/"));
111-
yield return (ConfigurationKeys.AgentPort, "9000", s => s.Exporter.AgentUri, new Uri("http://127.0.0.1:9000/"));
110+
yield return (ConfigurationKeys.AgentHost, "test-host", s => s.Manager.InitialExporterSettings.AgentUri, new Uri("http://test-host:8126/"));
111+
yield return (ConfigurationKeys.AgentPort, "9000", s => s.Manager.InitialExporterSettings.AgentUri, new Uri("http://127.0.0.1:9000/"));
112112

113113
yield return (ConfigurationKeys.Environment, "staging", s => s.Manager.InitialMutableSettings.Environment, "staging");
114114

tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void ReplaceLocalhost(string original, string expected)
3636

3737
var tracerSettings = new TracerSettings(new NameValueConfigurationSource(settings));
3838

39-
Assert.Equal(expected, tracerSettings.Exporter.AgentUri.ToString());
39+
Assert.Equal(expected, tracerSettings.Manager.InitialExporterSettings.AgentUri.ToString());
4040
}
4141

4242
[Theory]
@@ -681,9 +681,7 @@ public void IsRemoteConfigurationAvailable_AzureAppService(bool? overrideValue,
681681
public void RecordsTelemetryAboutTfm()
682682
{
683683
var tracerSettings = new TracerSettings(NullConfigurationSource.Instance);
684-
var collector = new ConfigurationTelemetry();
685-
tracerSettings.CollectTelemetry(collector);
686-
var data = collector.GetData();
684+
var data = tracerSettings.Telemetry.GetData();
687685
var value = data
688686
.GroupBy(x => x.Name)
689687
.Should()

tracer/test/Datadog.Trace.Tests/DogStatsDTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public void CanCreateDogStatsD_UDP_FromTraceAgentSettings(string agentUri, strin
128128
{ ConfigurationKeys.DogStatsdPort, port },
129129
}));
130130

131-
settings.Exporter.MetricsTransport.Should().Be(TransportType.UDP);
132-
var expectedPort = settings.Exporter.DogStatsdPort;
131+
settings.Manager.InitialExporterSettings.MetricsTransport.Should().Be(TransportType.UDP);
132+
var expectedPort = settings.Manager.InitialExporterSettings.DogStatsdPort;
133133

134134
// Dogstatsd tries to actually contact the agent during creation, so need to have something listening
135135
// No guarantees it's actually using the _right_ config here, but it's better than nothing
@@ -160,7 +160,7 @@ public void CanCreateDogStatsD_NamedPipes_FromTraceAgentSettings()
160160
{ ConfigurationKeys.MetricsPipeName, agent.StatsWindowsPipeName },
161161
}));
162162

163-
settings.Exporter.MetricsTransport.Should().Be(TransportType.NamedPipe);
163+
settings.Manager.InitialExporterSettings.MetricsTransport.Should().Be(TransportType.NamedPipe);
164164

165165
// Dogstatsd tries to actually contact the agent during creation, so need to have something listening
166166
// No guarantees it's actually using the _right_ config here, but it's better than nothing
@@ -194,7 +194,7 @@ public void CanCreateDogStatsD_UDS_FromTraceAgentSettings()
194194
{ ConfigurationKeys.MetricsUnixDomainSocketPath, $"unix://{metricsPath}" },
195195
}));
196196

197-
settings.Exporter.MetricsTransport.Should().Be(TransportType.UDS);
197+
settings.Manager.InitialExporterSettings.MetricsTransport.Should().Be(TransportType.UDS);
198198

199199
// Dogstatsd tries to actually contact the agent during creation, so need to have something listening
200200
// No guarantees it's actually using the _right_ config here, but it's better than nothing
@@ -226,7 +226,7 @@ public void CanCreateDogStatsD_UDS_FallsBackToUdp_FromTraceAgentSettings()
226226

227227
// If we're not using the "default" UDS path, then we fallback to UDP for stats
228228
// Should fallback to the "default" stats location
229-
settings.Exporter.MetricsTransport.Should().Be(TransportType.UDP);
229+
settings.Manager.InitialExporterSettings.MetricsTransport.Should().Be(TransportType.UDP);
230230

231231
// Dogstatsd tries to actually contact the agent during creation, so need to have something listening
232232
// No guarantees it's actually using the _right_ config here, but it's better than nothing

tracer/test/Datadog.Trace.Tests/ManualInstrumentation/SettingsInstrumentationTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ public void AutomaticToManual_ImmutableSettingsAreTransferredCorrectly()
228228

229229
var manual = new ImmutableManualSettings(serializedSettings);
230230

231-
manual.AgentUri.Should().Be(automatic.Exporter.AgentUri);
232-
manual.Exporter.AgentUri.Should().Be(automatic.Exporter.AgentUri);
231+
manual.AgentUri.Should().Be(automatic.Manager.InitialExporterSettings.AgentUri);
232+
manual.Exporter.AgentUri.Should().Be(automatic.Manager.InitialExporterSettings.AgentUri);
233233
manual.AnalyticsEnabled.Should().Be(automatic.Manager.InitialMutableSettings.AnalyticsEnabled);
234234
manual.CustomSamplingRules.Should().Be(automatic.Manager.InitialMutableSettings.CustomSamplingRules);
235235
manual.Environment.Should().Be(automatic.Manager.InitialMutableSettings.Environment);
@@ -261,8 +261,8 @@ public void AutomaticToManual_ImmutableSettingsAreTransferredCorrectly()
261261
private static void AssertEquivalent(ManualSettings manual, TracerSettings automatic)
262262
{
263263
// AgentUri gets transformed in exporter settings, so hacking around that here
264-
GetTransformedAgentUri(manual.AgentUri).Should().Be(automatic.Exporter.AgentUri);
265-
GetTransformedAgentUri(manual.Exporter.AgentUri).Should().Be(automatic.Exporter.AgentUri);
264+
GetTransformedAgentUri(manual.AgentUri).Should().Be(automatic.Manager.InitialExporterSettings.AgentUri);
265+
GetTransformedAgentUri(manual.Exporter.AgentUri).Should().Be(automatic.Manager.InitialExporterSettings.AgentUri);
266266

267267
manual.AnalyticsEnabled.Should().Be(automatic.Manager.InitialMutableSettings.AnalyticsEnabled);
268268
manual.CustomSamplingRules.Should().Be(automatic.Manager.InitialMutableSettings.CustomSamplingRules);
@@ -365,7 +365,7 @@ private static TracerSettings GetAndAssertAutomaticTracerSettings()
365365
automatic.StatsComputationEnabled.Should().Be(true);
366366
automatic.Manager.InitialMutableSettings.TraceEnabled.Should().Be(false);
367367
automatic.Manager.InitialMutableSettings.TracerMetricsEnabled.Should().Be(true);
368-
automatic.Exporter.AgentUri.Should().Be(new Uri("http://127.0.0.1:1234"));
368+
automatic.Manager.InitialExporterSettings.AgentUri.Should().Be(new Uri("http://127.0.0.1:1234"));
369369
automatic.Manager.InitialMutableSettings.Integrations[nameof(IntegrationId.Aerospike)].Enabled.Should().Be(false);
370370
automatic.Manager.InitialMutableSettings.Integrations[nameof(IntegrationId.Grpc)].AnalyticsEnabled.Should().Be(true);
371371
automatic.Manager.InitialMutableSettings.Integrations[nameof(IntegrationId.Couchbase)].AnalyticsSampleRate.Should().Be(0.5);

0 commit comments

Comments
 (0)