Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public DataCollectorLogger(DataCollectionLogger logger, DataCollectionContext co
{
_logger = logger;
_collectionContext = collectionContext;
_isDebugEnabled = GlobalSettings.Instance.DebugEnabledInternal;
_isDebugEnabled = GlobalSettings.Instance.DebugEnabled;

if (DatadogLoggingFactory.GetConfiguration(GlobalConfigurationSource.Instance, TelemetryFactory.Config).File is { } fileConfig)
{
Expand Down
1 change: 0 additions & 1 deletion tracer/src/Datadog.Trace.Manual/ITracer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public interface ITracer
/// </summary>
/// <param name="operationName">The span's operation name</param>
/// <returns>A scope wrapping the newly created span</returns>
[PublicApi]
IScope StartActive(string operationName);

/// <summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public static class OpenTracingTracerFactory
/// <param name="defaultServiceName">Default name of the service (default is the name of the executing assembly).</param>
/// <param name="isDebugEnabled">Turns on all debug logging (this may have an impact on application performance).</param>
/// <returns>A Datadog compatible ITracer implementation</returns>
[PublicApi]
[Obsolete(DeprecationMessage)]
[Instrumented]
[MethodImpl(MethodImplOptions.NoInlining)]
Expand Down Expand Up @@ -54,7 +53,6 @@ public static class OpenTracingTracerFactory
/// </summary>
/// <param name="tracer">Existing Datadog Tracer instance</param>
/// <returns>A Datadog compatible ITracer implementation</returns>
[PublicApi]
[Obsolete(DeprecationMessage)]
[Instrumented]
[MethodImpl(MethodImplOptions.NoInlining)]
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace.Tools.Runner/LegacyCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private void Execute(InvocationContext context)
}
}

if (GlobalSettings.Instance.DebugEnabledInternal)
if (GlobalSettings.Instance.DebugEnabled)
{
Console.WriteLine("Running: {0}", cmdLine);
}
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace.Tools.Runner/RunCiCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private async Task ExecuteAsync(InvocationContext context)
}

// Run child process
if (GlobalSettings.Instance.DebugEnabledInternal)
if (GlobalSettings.Instance.DebugEnabled)
{
Console.WriteLine("Running: {0}", command);
}
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace.Tools.Runner/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void Execute(InvocationContext context)
return;
}

if (GlobalSettings.Instance.DebugEnabledInternal)
if (GlobalSettings.Instance.DebugEnabled)
{
Console.WriteLine("Running: {0} {1}", program, arguments);
}
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/AppSec/Security.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ private void InitWafAndInstrumentations()
_settings.ObfuscationParameterValueRegex,
_configurationState,
_settings.UseUnsafeEncoder,
GlobalSettings.Instance.DebugEnabledInternal && _settings.WafDebugEnabled);
GlobalSettings.Instance.DebugEnabled && _settings.WafDebugEnabled);
if (_wafInitResult.Success)
{
// we don't reapply configurations to the waf here because it's all done in the subscription function, as new data might have been received at the same time as the enable command, we don't want to update twice (here and in the subscription)
Expand Down
2 changes: 1 addition & 1 deletion tracer/src/Datadog.Trace/Ci/Agent/CIWriterHttpSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal sealed class CIWriterHttpSender : ICIVisibilityProtocolWriterSender
public CIWriterHttpSender(IApiRequestFactory apiRequestFactory)
{
_apiRequestFactory = apiRequestFactory;
_isDebugEnabled = GlobalSettings.Instance.DebugEnabledInternal;
_isDebugEnabled = GlobalSettings.Instance.DebugEnabled;
Log.Information("CIWriterHttpSender Initialized.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void Add(IConfigurationSource source)
IEnumerator<IConfigurationSource> IEnumerable<IConfigurationSource>.GetEnumerator() => _sources.GetEnumerator();

/// <inheritdoc />
[PublicApi]
IEnumerator IEnumerable.GetEnumerator() => _sources.GetEnumerator();

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ internal class JsonConfigurationSource : IConfigurationSource
private static readonly IDatadogLogger Log = DatadogLogging.GetLoggerFor(typeof(JsonConfigurationSource));
private readonly JToken? _configuration;

/// <summary>
/// Initializes a new instance of the <see cref="JsonConfigurationSource"/>
/// class with the specified JSON string.
/// </summary>
/// <param name="json">A JSON string that contains configuration values.</param>
[PublicApi]
public JsonConfigurationSource(string json)
: this(json, ConfigurationOrigins.Code)
{
TelemetryFactory.Metrics.Record(PublicApiUsage.JsonConfigurationSource_Ctor_Json);
}

internal JsonConfigurationSource(string json, ConfigurationOrigins origin)
: this(json, origin, j => (JToken?)JsonConvert.DeserializeObject(j))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,10 @@ internal class NameValueConfigurationSource : StringConfigurationSource
{
private readonly NameValueCollection _nameValueCollection;

/// <summary>
/// Initializes a new instance of the <see cref="NameValueConfigurationSource"/> class
/// that wraps the specified <see cref="NameValueCollection"/>.
/// </summary>
/// <param name="nameValueCollection">The collection that will be wrapped by this configuration source.</param>
[PublicApi]
// Internal for testing only
Copy link
Member

@lucaspimentel lucaspimentel Nov 7, 2025

Choose a reason for hiding this comment

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

It's public, not internal.

public NameValueConfigurationSource(NameValueCollection nameValueCollection)
: this(nameValueCollection, ConfigurationOrigins.Code)
{
TelemetryFactory.Metrics.Record(PublicApiUsage.NameValueConfigurationSource_Ctor);
}

internal NameValueConfigurationSource(NameValueCollection nameValueCollection, ConfigurationOrigins origin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ internal abstract class StringConfigurationSource : IConfigurationSource

public abstract ConfigurationOrigins Origin { get; }

/// <summary>
/// Returns a <see cref="IDictionary{TKey, TValue}"/> from parsing
/// <paramref name="data"/>.
/// </summary>
/// <param name="data">A string containing key-value pairs which are comma-separated, and for which the key and value are colon-separated.</param>
/// <returns><see cref="IDictionary{TKey, TValue}"/> of key value pairs.</returns>
public static IDictionary<string, string>? ParseCustomKeyValues(string? data)
{
TelemetryFactory.Metrics.Record(PublicApiUsage.StringConfigurationSource_ParseCustomKeyValues);
return ParseCustomKeyValues(data, allowOptionalMappings: false);
}

/// <summary>
/// Returns a <see cref="IDictionary{TKey, TValue}"/> from parsing
/// <paramref name="data"/>.
Expand Down
23 changes: 4 additions & 19 deletions tracer/src/Datadog.Trace/Configuration/ExporterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,16 @@ public partial class ExporterSettings
internal const string DefaultMetricsUnixDomainSocket = "/var/run/datadog/dsd.socket";
internal const string UdpPrefix = "udp://";

/// <summary>
/// Initializes a new instance of the <see cref="ExporterSettings"/> class with default values.
/// </summary>
[PublicApi]
public ExporterSettings()
// Internal for testing only
internal ExporterSettings()
: this(source: null, new ConfigurationTelemetry())
{
TelemetryFactory.Metrics.Record(PublicApiUsage.ExporterSettings_Ctor);
}

/// <summary>
/// Initializes a new instance of the <see cref="ExporterSettings"/> class
/// using the specified <see cref="IConfigurationSource"/> to initialize values.
/// </summary>
/// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param>
/// <remarks>
/// We deliberately don't use the static <see cref="TelemetryFactory.Config"/> collector here
/// as we don't want to automatically record these values, only once they're "activated",
/// in <see cref="Tracer.Configure(TracerSettings)"/>
/// </remarks>
[PublicApi]
public ExporterSettings(IConfigurationSource? source)
// Internal for testing only
internal ExporterSettings(IConfigurationSource? source)
: this(source, File.Exists, new ConfigurationTelemetry())
{
TelemetryFactory.Metrics.Record(PublicApiUsage.ExporterSettings_Ctor_Source);
}

internal ExporterSettings(IConfigurationSource? source, IConfigurationTelemetry telemetry)
Expand Down
34 changes: 3 additions & 31 deletions tracer/src/Datadog.Trace/Configuration/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal GlobalSettings(
? ParsingResult<bool>.Success(result: true)
: ParsingResult<bool>.Failure());

DebugEnabledInternal = builder
DebugEnabled = builder
.WithKeys(ConfigurationKeys.DebugEnabled)
.AsBoolResult()
.OverrideWith(in otelConfig, overrideHandler, false);
Expand All @@ -59,14 +59,7 @@ internal GlobalSettings(
/// Set in code via <see cref="SetDebugEnabled"/>
/// </summary>
/// <seealso cref="ConfigurationKeys.DebugEnabled"/>
public bool DebugEnabled
{
get
{
TelemetryFactory.Metrics.Record(PublicApiUsage.GlobalSettings_DebugEnabled_Get);
return DebugEnabledInternal;
}
}
public bool DebugEnabled { get; private set; }

/// <summary>
/// Gets the global settings instance.
Expand All @@ -81,16 +74,14 @@ public bool DebugEnabled
/// </summary>
internal bool DiagnosticSourceEnabled { get; }

internal bool DebugEnabledInternal { get; private set; }

/// <summary>
/// Set whether debug mode is enabled.
/// Affects the level of logs written to file.
/// </summary>
/// <param name="enabled">Whether debug is enabled.</param>
internal static void SetDebugEnabled(bool enabled)
{
Instance.DebugEnabledInternal = enabled;
Instance.DebugEnabled = enabled;

if (enabled)
{
Expand All @@ -106,25 +97,6 @@ internal static void SetDebugEnabled(bool enabled)
TelemetryFactory.Config.Record(ConfigurationKeys.DebugEnabled, enabled, ConfigurationOrigins.Code);
}

/// <summary>
/// Used to refresh global settings when environment variables or config sources change.
/// This is not necessary if changes are set via code, only environment.
/// </summary>
[PublicApi]
public static void Reload()
{
TelemetryFactory.Metrics.Record(PublicApiUsage.GlobalSettings_Reload);
DatadogLogging.Reset();
var isLibdatadogAvailable = LibDatadogAvailabilityHelper.IsLibDatadogAvailable;
if (isLibdatadogAvailable.IsAvailable)
{
LibDatadog.Logging.Logger.Instance.SetLogLevel(debugEnabled: false);
}

GlobalConfigurationSource.Reload(isLibdatadogAvailable.IsAvailable);
Instance = CreateFromDefaultSources();
}

private static GlobalSettings CreateFromDefaultSources()
=> new(GlobalConfigurationSource.Instance, TelemetryFactory.Config, OverrideErrorLog.Instance);
}
Expand Down
23 changes: 4 additions & 19 deletions tracer/src/Datadog.Trace/Configuration/TracerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,16 @@ public record TracerSettings
private readonly IConfigurationTelemetry _telemetry;
private readonly Lazy<string> _fallbackApplicationName;

/// <summary>
/// Initializes a new instance of the <see cref="TracerSettings"/> class with default values.
/// </summary>
[PublicApi]
public TracerSettings()
// Internal for testing
internal TracerSettings()
: this(null, new ConfigurationTelemetry(), new OverrideErrorLog())
{
TelemetryFactory.Metrics.Record(PublicApiUsage.TracerSettings_Ctor);
}

/// <summary>
/// Initializes a new instance of the <see cref="TracerSettings"/> class
/// using the specified <see cref="IConfigurationSource"/> to initialize values.
/// </summary>
/// <param name="source">The <see cref="IConfigurationSource"/> to use when retrieving configuration values.</param>
/// <remarks>
/// We deliberately don't use the static <see cref="TelemetryFactory.Config"/> collector here
/// as we don't want to automatically record these values, only once they're "activated",
/// in <see cref="Tracer.Configure(TracerSettings)"/>
/// </remarks>
[PublicApi]
public TracerSettings(IConfigurationSource? source)
// Internal for testing
internal TracerSettings(IConfigurationSource? source)
: this(source, new ConfigurationTelemetry(), new OverrideErrorLog())
{
TelemetryFactory.Metrics.Record(PublicApiUsage.TracerSettings_Ctor_Source);
}

/// <summary>
Expand Down
62 changes: 0 additions & 62 deletions tracer/src/Datadog.Trace/CorrelationIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,67 +26,5 @@ public static class CorrelationIdentifier
internal const string SerilogEnvKey = "dd_env";
internal const string SerilogTraceIdKey = "dd_trace_id";
internal const string SerilogSpanIdKey = "dd_span_id";

/// <summary>
/// Gets the name of the service
/// </summary>
public static string Service
{
get
{
TelemetryFactory.Metrics.Record(PublicApiUsage.Correlation_Identifier_Service_Get);
return Tracer.Instance.DefaultServiceName ?? string.Empty;
}
}

/// <summary>
/// Gets the version of the service
/// </summary>
public static string Version
{
get
{
TelemetryFactory.Metrics.Record(PublicApiUsage.Correlation_Identifier_Version_Get);
return Tracer.Instance.CurrentTraceSettings.Settings.ServiceVersion ?? string.Empty;
}
}

/// <summary>
/// Gets the environment name of the service
/// </summary>
public static string Env
{
get
{
TelemetryFactory.Metrics.Record(PublicApiUsage.Correlation_Identifier_Env_Get);
return Tracer.Instance.CurrentTraceSettings.Settings.Environment ?? string.Empty;
}
}

/// <summary>
/// Gets the id of the active trace.
/// </summary>
/// <returns>The id of the active trace. If there is no active trace, returns zero.</returns>
public static ulong TraceId
{
get
{
TelemetryFactory.Metrics.Record(PublicApiUsage.Correlation_Identifier_TraceId_Get);
return Tracer.Instance.ActiveScope?.Span?.TraceId ?? 0;
}
}

/// <summary>
/// Gets the id of the active span.
/// </summary>
/// <returns>The id of the active span. If there is no active span, returns zero.</returns>
public static ulong SpanId
{
get
{
TelemetryFactory.Metrics.Record(PublicApiUsage.Correlation_Identifier_SpanId_Get);
return Tracer.Instance.ActiveScope?.Span?.SpanId ?? 0;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static DatadogLogging()

try
{
if (GlobalSettings.Instance.DebugEnabledInternal)
if (GlobalSettings.Instance.DebugEnabled)
{
LoggingLevelSwitch.MinimumLevel = LogEventLevel.Debug;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private async Task<ApplyDetails[]> HandleTracerFlareInitiated(List<RemoteConfigu
{
// This product means "prepare for sending a tracer flare."
// We may consider doing more than just enabling debug mode in the future
_wasDebugLogEnabled = GlobalSettings.Instance.DebugEnabledInternal;
_wasDebugLogEnabled = GlobalSettings.Instance.DebugEnabled;
GlobalSettings.SetDebugEnabled(true);

// The timer is a fallback, in case we never receive a "send flare" product
Expand Down
Loading
Loading