Skip to content

Commit 4a495e3

Browse files
committed
special case for logging factory..
1 parent fb3fafa commit 4a495e3

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

tracer/src/Datadog.Trace.Manual/Datadog.Trace.Manual.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
<Compile Include="..\Datadog.Trace\Ci\TestStatus.cs" Link="Ci\%(Filename)%(Extension)" />
2727
<Compile Include="..\Datadog.Trace\ClrProfiler\AutoInstrumentation\ManualInstrumentation\TracerSettingKeyConstants.cs" Link="Configuration\%(Filename)%(Extension)" />
2828
<Compile Include="..\Datadog.Trace\ClrProfiler\AutoInstrumentation\ManualInstrumentation\IntegrationSettingsSerializationHelper.cs" Link="Configuration\%(Filename)%(Extension)" />
29-
<Compile Include="..\Datadog.Trace\Configuration\DeprecationMessages.cs" Link="Configuration\%(Filename)%(Extension)" />
29+
<Compile Include="..\Datadog.Trace\Configuration\DeprecationMessages.cs"
30+
Link="Configuration\%(Filename)%(Extension)" />
3031
<Compile Include="..\Datadog.Trace\DuckTyping\DuckAsClassAttribute.cs" Link="DuckTyping\%(Filename)%(Extension)" />
3132
<Compile Include="..\Datadog.Trace\HttpHeaderNames.cs" />
3233
<Compile Include="..\Datadog.Trace\IDatadogOpenTracingTracer.cs" />

tracer/src/Datadog.Trace.Tools.Runner/ProcessConfiguration.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ internal static class ProcessConfiguration
5454

5555
if (logDirectory == null)
5656
{
57-
#pragma warning disable 618 // ProfilerLogPath is deprecated but still supported
58-
var nativeLogFile = config.WithKeys(ConfigurationKeys.ProfilerLogPath).AsString();
59-
#pragma warning restore 618
57+
// ProfilerLogPath is deprecated but still supported. For now, we bypass the WithKeys analyzer, but later we want to pull deprecations differently as part of centralized file
58+
#pragma warning disable DD0008, 618
59+
var nativeLogFile = config.WithKeys(ConfigurationKeys.TraceLogPath).AsString();
60+
#pragma warning restore DD0008, 618
6061
if (!string.IsNullOrEmpty(nativeLogFile))
6162
{
6263
logDirectory = Path.GetDirectoryName(nativeLogFile);

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ not null when string.Equals(x, "lowmemory", StringComparison.OrdinalIgnoreCase)
267267
validator: null);
268268

269269
OtlpLogsProtocol = config
270-
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsProtocol, ConfigurationKeys.OpenTelemetry.ExporterOtlpProtocol)
270+
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsProtocol)
271271
.GetAs(
272272
defaultValue: new(OtlpProtocol.Grpc, "grpc"),
273273
converter: x => x switch
@@ -293,14 +293,14 @@ not null when string.Equals(x, "http/protobuf", StringComparison.OrdinalIgnoreCa
293293
converter: uriString => new Uri(uriString));
294294

295295
OtlpLogsHeaders = config
296-
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsHeaders, ConfigurationKeys.OpenTelemetry.ExporterOtlpHeaders)
296+
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsHeaders)
297297
.AsDictionaryResult(separator: '=')
298298
.WithDefault(new DefaultResult<IDictionary<string, string>>(new Dictionary<string, string>(), "[]"))
299299
.Where(kvp => !string.IsNullOrWhiteSpace(kvp.Key))
300300
.ToDictionary(kvp => kvp.Key.Trim(), kvp => kvp.Value?.Trim() ?? string.Empty);
301301

302302
OtlpLogsTimeoutMs = config
303-
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsTimeoutMs, ConfigurationKeys.OpenTelemetry.ExporterOtlpTimeoutMs)
303+
.WithKeys(ConfigurationKeys.OpenTelemetry.ExporterOtlpLogsTimeoutMs)
304304
.AsInt32(defaultValue: 10_000);
305305

306306
var otelLogsExporter = config
@@ -1379,6 +1379,16 @@ internal static string[] TrimSplitString(string? textValues, char[] separators)
13791379
return list.ToArray();
13801380
}
13811381

1382+
internal bool IsErrorStatusCode(int statusCode, bool serverStatusCode)
1383+
=> MutableSettings.IsErrorStatusCode(statusCode, serverStatusCode);
1384+
1385+
internal bool IsIntegrationEnabled(IntegrationId integration, bool defaultValue = true)
1386+
=> MutableSettings.IsIntegrationEnabled(integration, defaultValue);
1387+
1388+
[Obsolete(DeprecationMessages.AppAnalytics)]
1389+
internal double? GetIntegrationAnalyticsSampleRate(IntegrationId integration, bool enabledWithGlobalSetting)
1390+
=> MutableSettings.GetIntegrationAnalyticsSampleRate(integration, enabledWithGlobalSetting);
1391+
13821392
internal string GetDefaultHttpClientExclusions()
13831393
{
13841394
if (IsRunningInAzureAppService)

tracer/src/Datadog.Trace/Logging/Internal/DatadogLoggingFactory.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,15 @@ internal static string GetLogDirectory(IConfigurationTelemetry telemetry)
171171

172172
private static string GetLogDirectory(IConfigurationSource source, IConfigurationTelemetry telemetry)
173173
{
174-
var logDirectory = new ConfigurationBuilder(source, telemetry).WithKeys(ConfigurationKeys.LogDirectory).AsString();
174+
var configurationBuilder = new ConfigurationBuilder(source, telemetry);
175+
var logDirectory = configurationBuilder.WithKeys(ConfigurationKeys.LogDirectory).AsString();
175176
if (string.IsNullOrEmpty(logDirectory))
176177
{
177-
#pragma warning disable 618 // ProfilerLogPath is deprecated but still supported
178-
var nativeLogFile = new ConfigurationBuilder(source, telemetry).WithKeys(ConfigurationKeys.ProfilerLogPath).AsString();
179-
#pragma warning restore 618
178+
// todo, handle in phase 2 with deprecations
179+
// ProfilerLogPath is deprecated but still supported. For now, we bypass the WithKeys analyzer, but later we want to pull deprecations differently as part of centralized file
180+
#pragma warning disable DD0008, 618
181+
var nativeLogFile = configurationBuilder.WithKeys(ConfigurationKeys.TraceLogPath).AsString();
182+
#pragma warning restore DD0008, 618
180183

181184
if (!string.IsNullOrEmpty(nativeLogFile))
182185
{

tracer/test/Datadog.Trace.Tests/Logging/DatadogLoggingFactoryTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void UsesLogDirectoryWhenItExists(string obsoleteLogDirectory)
3232
{
3333
{ ConfigurationKeys.LogDirectory, logDirectory },
3434
#pragma warning disable CS0618
35-
{ ConfigurationKeys.ProfilerLogPath, obsoleteLogDirectory },
35+
{ ConfigurationKeys.TraceLogPath, obsoleteLogDirectory },
3636
#pragma warning restore CS0618
3737
});
3838

@@ -55,7 +55,7 @@ public void UsesObsoleteLogDirectoryWhenAvailable(string logDirectory)
5555
{
5656
{ ConfigurationKeys.LogDirectory, logDirectory },
5757
#pragma warning disable CS0618
58-
{ ConfigurationKeys.ProfilerLogPath, obsoleteLogPath },
58+
{ ConfigurationKeys.TraceLogPath, obsoleteLogPath },
5959
#pragma warning restore CS0618
6060
});
6161

@@ -76,7 +76,7 @@ public void UsesEnvironmentFallBackWhenBothNull(string logDirectory, string obso
7676
{
7777
{ ConfigurationKeys.LogDirectory, logDirectory },
7878
#pragma warning disable CS0618
79-
{ ConfigurationKeys.ProfilerLogPath, obsoleteLogDirectory },
79+
{ ConfigurationKeys.TraceLogPath, obsoleteLogDirectory },
8080
#pragma warning restore CS0618
8181
});
8282

0 commit comments

Comments
 (0)