diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 58bef43b4a41..b6c824aa5d5a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -226,3 +226,12 @@ dsm_throughput: trigger: include: .gitlab/benchmarks/dsm-throughput.yml allow_failure: true + + +validate_supported_configurations_local_file: + stage: build + rules: + - when: on_success + extends: .validate_supported_configurations_local_file + variables: + LOCAL_JSON_PATH: "tracer/src/Datadog.Trace/Configuration/supported-configurations.json" \ No newline at end of file diff --git a/.gitlab/one-pipeline.locked.yaml b/.gitlab/one-pipeline.locked.yaml index a9d444d49e1c..bdb07057d963 100644 --- a/.gitlab/one-pipeline.locked.yaml +++ b/.gitlab/one-pipeline.locked.yaml @@ -1,4 +1,4 @@ # DO NOT EDIT THIS FILE MANUALLY # This file is auto-generated by automation. include: - - remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/5ad4e568659a0e385e3cd429b7845ad8e2171cfe0e27ee5b9eeb4cd4b67825f5/one-pipeline.yml + - remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/b8fc1b7f45e49ddd65623f217f03c38def169aff6f2518380e5b415514e4cb81/one-pipeline.yml diff --git a/tracer/build/_build/Build.Steps.cs b/tracer/build/_build/Build.Steps.cs index 4c0fe5172bcb..f50c4416d934 100644 --- a/tracer/build/_build/Build.Steps.cs +++ b/tracer/build/_build/Build.Steps.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Net.Http; +using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Text.Json; @@ -2574,6 +2575,172 @@ string NormalizedPath(AbsolutePath ap) await LogParser.ReportNativeMetrics(logDirectory); }); + public Target CheckConfigurationKeysAgainstJsonValidations => _ => _ + .Description("Validates that all ConfigurationKeys constants are present in supported-configurations.json") + .After(CompileManagedSrc) + .Executes(() => + { + var jsonPath = TracerDirectory / "src" / "Datadog.Trace" / "Configuration" / "supported-configurations.json"; + if (!File.Exists(jsonPath)) + { + Logger.Error("supported-configurations.json file not found at {JsonPath}", jsonPath); + return; + } + + // Parse JSON to get supported configuration keys + var jsonContent = File.ReadAllText(jsonPath); + var jsonDoc = JsonDocument.Parse(jsonContent); + var canonicalKeysInJson = new HashSet(); + var aliasesInJson = new HashSet(); + var deprecationsInJson = new HashSet(); + + // Add keys from supportedConfigurations section + if (jsonDoc.RootElement.TryGetProperty("supportedConfigurations", out var supportedConfigs)) + { + foreach (var property in supportedConfigs.EnumerateObject()) + { + canonicalKeysInJson.Add(property.Name); + deprecationsInJson.Add(property.Name); + } + } + + // Add keys from aliases section (add elements in the arrays) + if (jsonDoc.RootElement.TryGetProperty("aliases", out var aliases)) + { + foreach (var property in aliases.EnumerateObject()) + { + // Add all alias keys from the array + if (property.Value.ValueKind == JsonValueKind.Array) + { + foreach (var aliasElement in property.Value.EnumerateArray()) + { + if (aliasElement.ValueKind == JsonValueKind.String) + { + aliasesInJson.Add(aliasElement.GetString()); + } + } + } + } + } + + // Add keys from deprecations section (add the deprecated keys themselves) + if (jsonDoc.RootElement.TryGetProperty("deprecations", out var deprecations)) + { + foreach (var property in deprecations.EnumerateObject()) + { + deprecationsInJson.Add(property.Name); + } + } + + // Load the net6.0 assembly for configuration key analysis + // Configuration keys are the same across all frameworks, so we only need one + const string targetFramework = "net6.0"; + var assemblyPath = TracerDirectory / "src" / "Datadog.Trace" / "bin" / BuildConfiguration / targetFramework / "Datadog.Trace.dll"; + + if (!File.Exists(assemblyPath)) + { + throw new InvalidOperationException($"Assembly not found at {assemblyPath} for framework {targetFramework}. Make sure CompileManagedSrc has run."); + } + + Assembly tracerAssembly; + try + { + // Load the assembly directly - no complex resolution needed + tracerAssembly = Assembly.LoadFrom(assemblyPath); + Logger.Information("Using {Framework} assembly for configuration key analysis", targetFramework); + } + catch (Exception ex) + { + throw new InvalidOperationException($"Failed to load assembly for {targetFramework}: {ex.Message}", ex); + } + + // Use reflection to get all configuration keys from the ConfigurationKeys class + var configurationKeysInCode = new HashSet(); + var keyToFieldMap = new Dictionary(); + + const string configKeysClassName = "Datadog.Trace.Configuration.ConfigurationKeys"; + // Get the ConfigurationKeys type (includes all partial classes) + var configKeysType = tracerAssembly.GetType(configKeysClassName); + if (configKeysType == null) + { + throw new InvalidOperationException($"Could not find {configKeysClassName} type in assembly for framework {targetFramework}"); + } + + // Get all public const string fields from the type and all nested types (one level deep) + var allTypes = new List { configKeysType }; + allTypes.AddRange(configKeysType.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)); + + Logger.Information("Found {TypeCount} types to analyze (including nested classes)", allTypes.Count); + + foreach (var type in allTypes) + { + var fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy) + .Where(f => f.IsLiteral && !f.IsInitOnly && f.FieldType == typeof(string)); + + Logger.Information(" Type {TypeName} has {FieldCount} const string fields", type.Name, fields.Count()); + + foreach (var field in fields) + { + var value = (string)field.GetValue(null)!; + configurationKeysInCode.Add(value); + + // Build a more descriptive path for nested classes + var typeName = type.DeclaringType != null ? $"ConfigurationKeys.{type.Name}" : "ConfigurationKeys"; + keyToFieldMap[value] = $"{typeName}.{field.Name}"; + } + } + + Logger.Information("Found {KeyCount} configuration keys in {Framework}", configurationKeysInCode.Count, targetFramework); + + if (!configurationKeysInCode.Any()) + { + throw new InvalidOperationException($"Could not extract any configuration keys from {targetFramework} framework"); + } + + var canonicalAndDeprecationsInJson = canonicalKeysInJson.Concat(deprecationsInJson); + // Find keys that are in JSON but not defined in ConfigurationKeys + var missingFromCode = canonicalKeysInJson.Except(configurationKeysInCode).ToList(); + + var allKeysInJson = canonicalAndDeprecationsInJson.Concat(aliasesInJson); + // Find keys that are defined in ConfigurationKeys but missing from JSON + var missingFromJson = configurationKeysInCode.Except(allKeysInJson).ToList(); + // Report results + if (missingFromJson.Any()) + { + Logger.Error("Configuration keys defined in ConfigurationKeys but missing from supported-configurations.json:"); + foreach (var key in missingFromJson.OrderBy(k => k)) + { + var fieldInfo = keyToFieldMap.GetValueOrDefault(key, "Unknown"); + Logger.Error(" - {Key} (defined as {FieldInfo})", key, fieldInfo); + } + } + + if (missingFromCode.Any()) + { + Logger.Warning("Configuration keys in supported-configurations.json but not defined in ConfigurationKeys:"); + foreach (var key in missingFromCode.OrderBy(k => k)) + { + Logger.Warning(" - {Key}", key); + } + } + + if (!missingFromJson.Any() && !missingFromCode.Any()) + { + Logger.Information("✅ All configuration keys are properly synchronized between ConfigurationKeys and supported-configurations.json"); + Logger.Information("Total unique configuration keys found across all frameworks: {TotalKeys}", configurationKeysInCode.Count); + } + else + { + var totalIssues = missingFromJson.Count + missingFromCode.Count; + Logger.Error("❌ Found {TotalIssues} configuration key synchronization issues", totalIssues); + + if (missingFromJson.Any()) + { + throw new InvalidOperationException($"Found {missingFromJson.Count} configuration keys defined in ConfigurationKeys but missing from supported-configurations.json. Please add them to the JSON file."); + } + } + }); + private async Task CheckLogsForErrors(List knownPatterns, bool allFilesMustExist, LogLevel minLogLevel, List<(string IgnoreReasonTag, Regex Regex)> reportablePatterns) { var logDirectory = BuildDataDirectory / "logs"; diff --git a/tracer/build/_build/Build.cs b/tracer/build/_build/Build.cs index b20c07c52508..1ae53e631028 100644 --- a/tracer/build/_build/Build.cs +++ b/tracer/build/_build/Build.cs @@ -210,6 +210,7 @@ void DeleteReparsePoints(string path) .DependsOn(CreateRequiredDirectories) .DependsOn(Restore) .DependsOn(CompileManagedSrc) + .DependsOn(CheckConfigurationKeysAgainstJsonValidations) .DependsOn(PublishManagedTracer) .DependsOn(DownloadLibDdwaf) .DependsOn(CopyLibDdwaf) diff --git a/tracer/missing-nullability-files.csv b/tracer/missing-nullability-files.csv index 5aa540291a4f..0e16a61fbc1e 100644 --- a/tracer/missing-nullability-files.csv +++ b/tracer/missing-nullability-files.csv @@ -84,7 +84,6 @@ src/Datadog.Trace/Configuration/ConfigurationKeys.AzureAppService.cs src/Datadog.Trace/Configuration/ConfigurationKeys.Debugger.cs src/Datadog.Trace/Configuration/ConfigurationKeys.DirectLogSubmission.cs src/Datadog.Trace/Configuration/ConfigurationKeys.Exporter.cs -src/Datadog.Trace/Configuration/ConfigurationKeys.GCPFunction.cs src/Datadog.Trace/Configuration/ConfigurationKeys.Iast.cs src/Datadog.Trace/Configuration/ConfigurationKeys.Logging.cs src/Datadog.Trace/Configuration/ConfigurationKeys.Rcm.cs @@ -93,7 +92,6 @@ src/Datadog.Trace/Configuration/DeprecationMessages.cs src/Datadog.Trace/Configuration/IDynamicConfigurationManager.cs src/Datadog.Trace/Configuration/IntegrationRegistry.cs src/Datadog.Trace/Configuration/TracerSettingsConstants.cs -src/Datadog.Trace/ContinuousProfiler/ConfigurationKeys.cs src/Datadog.Trace/ContinuousProfiler/ContextTracker.cs src/Datadog.Trace/ContinuousProfiler/IContextTracker.cs src/Datadog.Trace/ContinuousProfiler/IProfilerStatus.cs diff --git a/tracer/src/Datadog.Trace.BenchmarkDotNet/DatadogExtensions.cs b/tracer/src/Datadog.Trace.BenchmarkDotNet/DatadogExtensions.cs index 0cba9b68d9d1..9aba34f7fb69 100644 --- a/tracer/src/Datadog.Trace.BenchmarkDotNet/DatadogExtensions.cs +++ b/tracer/src/Datadog.Trace.BenchmarkDotNet/DatadogExtensions.cs @@ -4,6 +4,7 @@ // using BenchmarkDotNet.Configs; +using Datadog.Trace.Configuration; using Datadog.Trace.ContinuousProfiler; using Datadog.Trace.ExtensionMethods; using Datadog.Trace.Util; @@ -33,14 +34,14 @@ internal static IConfig WithDatadog(this IConfig config, bool? enableProfiler) { var cfg = config.AddLogger(DatadogSessionLogger.Default); - enableProfiler ??= (EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.ProfilingEnabled) ?? string.Empty).ToBoolean() ?? false; + enableProfiler ??= (EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.Profiler.ProfilingEnabled) ?? string.Empty).ToBoolean() ?? false; switch (enableProfiler) { case true: cfg = cfg.WithOption(ConfigOptions.KeepBenchmarkFiles, true); break; case false: - EnvironmentHelpers.SetEnvironmentVariable(ConfigurationKeys.ProfilingEnabled, null); + EnvironmentHelpers.SetEnvironmentVariable(ConfigurationKeys.Profiler.ProfilingEnabled, null); break; } diff --git a/tracer/src/Datadog.Trace/ClrProfiler/Instrumentation.cs b/tracer/src/Datadog.Trace/ClrProfiler/Instrumentation.cs index 2040e2b25c25..af32086b6306 100644 --- a/tracer/src/Datadog.Trace/ClrProfiler/Instrumentation.cs +++ b/tracer/src/Datadog.Trace/ClrProfiler/Instrumentation.cs @@ -466,8 +466,8 @@ private static void StartDiagnosticManager() var observers = new List(); // get environment variables directly so we don't access Trace.Instance yet - var functionsExtensionVersion = EnvironmentHelpers.GetEnvironmentVariable(Datadog.Trace.Configuration.ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion); - var functionsWorkerRuntime = EnvironmentHelpers.GetEnvironmentVariable(Datadog.Trace.Configuration.ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime); + var functionsExtensionVersion = EnvironmentHelpers.GetEnvironmentVariable(PlatformKeys.AzureFunctions.FunctionsExtensionVersion); + var functionsWorkerRuntime = EnvironmentHelpers.GetEnvironmentVariable(PlatformKeys.AzureFunctions.FunctionsWorkerRuntime); if (!string.IsNullOrEmpty(functionsExtensionVersion) && !string.IsNullOrEmpty(functionsWorkerRuntime)) { diff --git a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.AzureAppService.cs b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.AzureAppService.cs index 8979539abd0f..b973d1b93974 100644 --- a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.AzureAppService.cs +++ b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.AzureAppService.cs @@ -21,38 +21,6 @@ internal class AzureAppService /// internal const string SiteExtensionVersionKey = "DD_AAS_DOTNET_EXTENSION_VERSION"; - /// - /// Example: 8c500027-5f00-400e-8f00-60000000000f+apm-dotnet-EastUSwebspace - /// Format: {subscriptionId}+{planResourceGroup}-{hostedInRegion} - /// - internal const string WebsiteOwnerNameKey = "WEBSITE_OWNER_NAME"; - - /// - /// This is the name of the resource group the site instance is assigned to. - /// - internal const string ResourceGroupKey = "WEBSITE_RESOURCE_GROUP"; - - /// - /// This is the unique name of the website instance within Azure App Services. - /// Its presence is used to determine if we are running in Azure App Services. - /// - internal const string SiteNameKey = "WEBSITE_SITE_NAME"; - - /// - /// The instance name in Azure where the traced application is running. - /// - internal const string InstanceNameKey = "COMPUTERNAME"; - - /// - /// The instance ID in Azure where the traced application is running. - /// - internal const string InstanceIdKey = "WEBSITE_INSTANCE_ID"; - - /// - /// The operating system in Azure where the traced application is running. - /// - internal const string OperatingSystemKey = "WEBSITE_OS"; - /// /// Used to force the loader to start the trace agent (in case automatic instrumentation is disabled) /// @@ -62,12 +30,6 @@ internal class AzureAppService /// Used to force the loader to start dogstatsd (in case automatic instrumentation is disabled) /// public const string AasEnableCustomMetrics = "DD_AAS_ENABLE_CUSTOM_METRICS"; - - /// - /// Used to identify consumption plan functions. Consumption plans will either not have this variable, - /// or will have a value of "dynamic". - /// - public const string WebsiteSKU = "WEBSITE_SKU"; } } } diff --git a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.GCPFunction.cs b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.GCPFunction.cs deleted file mode 100644 index 14ad15878f7a..000000000000 --- a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.GCPFunction.cs +++ /dev/null @@ -1,36 +0,0 @@ -// -// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. -// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. -// - -namespace Datadog.Trace.Configuration -{ - internal partial class ConfigurationKeys - { - // GCP Function auto-set env var reference: https://cloud.google.com/functions/docs/configuring/env-var#runtime_environment_variables_set_automatically - internal class GCPFunction - { - /// - /// The name of functions running deprecated runtimes. - /// - internal const string DeprecatedFunctionNameKey = "FUNCTION_NAME"; - - /// - /// The name of the gcp project a deprecated function belongs to. Only set in functions running deprecated runtimes. - /// Used to tell whether or not we are in a deprecated function environment. - /// - internal const string DeprecatedProjectKey = "GCP_PROJECT"; - - /// - /// The name of functions running non-deprecated runtimes. - /// - internal const string FunctionNameKey = "K_SERVICE"; - - /// - /// The name of the function handler to be executed when the function is invoked. Only set in functions running non-deprecated runtimes. - /// Used to tell whether or not we are in a non-deprecated function environment. - /// - internal const string FunctionTargetKey = "FUNCTION_TARGET"; - } - } -} diff --git a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.Profiler.cs b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.Profiler.cs new file mode 100644 index 000000000000..68e9d0739f9b --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.Profiler.cs @@ -0,0 +1,21 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#nullable enable + +namespace Datadog.Trace.Configuration +{ + internal static partial class ConfigurationKeys + { + internal static class Profiler + { + public const string ProfilingEnabled = "DD_PROFILING_ENABLED"; + public const string CodeHotspotsEnabled = "DD_PROFILING_CODEHOTSPOTS_ENABLED"; + public const string EndpointProfilingEnabled = "DD_PROFILING_ENDPOINT_COLLECTION_ENABLED"; + public const string SsiDeployed = "DD_INJECTION_ENABLED"; + public const string ProfilerManagedActivationEnabled = "DD_PROFILING_MANAGED_ACTIVATION_ENABLED"; + } + } +} diff --git a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs index cbb60b0d32f8..8ba109b9d858 100644 --- a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs +++ b/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.cs @@ -14,6 +14,11 @@ namespace Datadog.Trace.Configuration /// internal static partial class ConfigurationKeys { + /// + /// Configuration key to enable or disable the ActivityListener. + /// + public const string ActivityListenerEnabled = "DD_TRACE_ACTIVITY_LISTENER_ENABLED"; + /// /// Configuration key to enable experimental features. /// @@ -753,29 +758,6 @@ public static class Proxy public const string ProxyNoProxy = "DD_PROXY_NO_PROXY"; } - /// - /// String format patterns used to match integration-specific configuration keys. - /// - public static class Integrations - { - /// - /// Configuration key pattern for enabling or disabling an integration. - /// - public const string Enabled = "DD_TRACE_{0}_ENABLED"; - - /// - /// Configuration key pattern for enabling or disabling Analytics in an integration. - /// - [Obsolete(DeprecationMessages.AppAnalytics)] - public const string AnalyticsEnabled = "DD_TRACE_{0}_ANALYTICS_ENABLED"; - - /// - /// Configuration key pattern for setting Analytics sampling rate in an integration. - /// - [Obsolete(DeprecationMessages.AppAnalytics)] - public const string AnalyticsSampleRate = "DD_TRACE_{0}_ANALYTICS_SAMPLE_RATE"; - } - /// /// String constants for debug configuration keys. /// @@ -984,7 +966,7 @@ internal static class DataStreamsMonitoring /// Configuration key for enabling legacy binary headers in Data Streams Monitoring. /// false by default if DSM is in default state, true otherwise /// - /// + /// public const string LegacyHeadersEnabled = "DD_DATA_STREAMS_LEGACY_HEADERS"; } } diff --git a/tracer/src/Datadog.Trace/Configuration/ImmutableAzureAppServiceSettings.cs b/tracer/src/Datadog.Trace/Configuration/ImmutableAzureAppServiceSettings.cs index b736040c0b8e..a4ada002ae72 100644 --- a/tracer/src/Datadog.Trace/Configuration/ImmutableAzureAppServiceSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/ImmutableAzureAppServiceSettings.cs @@ -61,17 +61,17 @@ public ImmutableAzureAppServiceSettings(IConfigurationSource? source, IConfigura } SubscriptionId = GetSubscriptionId(source, telemetry); - ResourceGroup = config.WithKeys(ConfigurationKeys.AzureAppService.ResourceGroupKey).AsString(); - SiteName = config.WithKeys(ConfigurationKeys.AzureAppService.SiteNameKey).AsString(); + ResourceGroup = config.WithKeys(PlatformKeys.AzureAppService.ResourceGroupKey).AsString(); + SiteName = config.WithKeys(PlatformKeys.AzureAppService.SiteNameKey).AsString(); ResourceId = CompileResourceId(subscriptionId: SubscriptionId, siteName: SiteName, resourceGroup: ResourceGroup); - InstanceId = config.WithKeys(ConfigurationKeys.AzureAppService.InstanceIdKey).AsString("unknown"); - InstanceName = config.WithKeys(ConfigurationKeys.AzureAppService.InstanceNameKey).AsString("unknown"); - OperatingSystem = config.WithKeys(ConfigurationKeys.AzureAppService.OperatingSystemKey).AsString("unknown"); + InstanceId = config.WithKeys(PlatformKeys.AzureAppService.InstanceIdKey).AsString("unknown"); + InstanceName = config.WithKeys(PlatformKeys.AzureAppService.InstanceNameKey).AsString("unknown"); + OperatingSystem = config.WithKeys(PlatformKeys.AzureAppService.OperatingSystemKey).AsString("unknown"); SiteExtensionVersion = config.WithKeys(ConfigurationKeys.AzureAppService.SiteExtensionVersionKey).AsString("unknown"); - WebsiteSKU = config.WithKeys(ConfigurationKeys.AzureAppService.WebsiteSKU).AsString(); + WebsiteSKU = config.WithKeys(PlatformKeys.AzureAppService.WebsiteSKU).AsString(); - FunctionsWorkerRuntime = config.WithKeys(ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime).AsString(); - FunctionsExtensionVersion = config.WithKeys(ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion).AsString(); + FunctionsWorkerRuntime = config.WithKeys(PlatformKeys.AzureFunctions.FunctionsWorkerRuntime).AsString(); + FunctionsExtensionVersion = config.WithKeys(PlatformKeys.AzureFunctions.FunctionsExtensionVersion).AsString(); if (FunctionsWorkerRuntime is not null && FunctionsExtensionVersion is not null) { @@ -142,19 +142,19 @@ private static bool ShouldSkipClientSpanWithinFunctions(Scope? scope) { if (subscriptionId == null) { - Log.Warning("Could not successfully retrieve the subscription ID from variable: {Variable}", ConfigurationKeys.AzureAppService.WebsiteOwnerNameKey); + Log.Warning("Could not successfully retrieve the subscription ID from variable: {Variable}", PlatformKeys.AzureAppService.WebsiteOwnerNameKey); return null; } if (siteName == null) { - Log.Warning("Could not successfully retrieve the deployment ID from variable: {Variable}", ConfigurationKeys.AzureAppService.SiteNameKey); + Log.Warning("Could not successfully retrieve the deployment ID from variable: {Variable}", PlatformKeys.AzureAppService.SiteNameKey); return null; } if (resourceGroup == null) { - Log.Warning("Could not successfully retrieve the resource group name from variable: {Variable}", ConfigurationKeys.AzureAppService.ResourceGroupKey); + Log.Warning("Could not successfully retrieve the resource group name from variable: {Variable}", PlatformKeys.AzureAppService.ResourceGroupKey); return null; } @@ -164,7 +164,7 @@ private static bool ShouldSkipClientSpanWithinFunctions(Scope? scope) private static string? GetSubscriptionId(IConfigurationSource source, IConfigurationTelemetry telemetry) { var websiteOwner = new ConfigurationBuilder(source, telemetry) - .WithKeys(ConfigurationKeys.AzureAppService.WebsiteOwnerNameKey) + .WithKeys(PlatformKeys.AzureAppService.WebsiteOwnerNameKey) .AsString(websiteOwner => !string.IsNullOrWhiteSpace(websiteOwner)); if (!string.IsNullOrWhiteSpace(websiteOwner)) @@ -186,7 +186,7 @@ private static bool ShouldSkipClientSpanWithinFunctions(Scope? scope) public static bool IsRunningInAzureAppServices(IConfigurationSource source, IConfigurationTelemetry telemetry) { var siteName = new ConfigurationBuilder(source, telemetry) - .WithKeys(ConfigurationKeys.AzureAppService.SiteNameKey) + .WithKeys(PlatformKeys.AzureAppService.SiteNameKey) .AsString(); return !string.IsNullOrEmpty(siteName); @@ -200,17 +200,17 @@ public static bool IsRunningInAzureAppServices(IConfigurationSource source, ICon public static bool IsRunningInAzureFunctions(IConfigurationSource source, IConfigurationTelemetry telemetry) { var siteName = new ConfigurationBuilder(source, telemetry) - .WithKeys(ConfigurationKeys.AzureAppService.SiteNameKey) + .WithKeys(PlatformKeys.AzureAppService.SiteNameKey) .AsString(); // "dotnet", "dotnet-isolated" var workerRuntime = new ConfigurationBuilder(source, telemetry) - .WithKeys(ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime) + .WithKeys(PlatformKeys.AzureFunctions.FunctionsWorkerRuntime) .AsString(); // "~4", "~1" var extensionVersion = new ConfigurationBuilder(source, telemetry) - .WithKeys(ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion) + .WithKeys(PlatformKeys.AzureFunctions.FunctionsExtensionVersion) .AsString(); return !string.IsNullOrEmpty(siteName) && diff --git a/tracer/src/Datadog.Trace/Configuration/ImmutableGCPFunctionSettings.cs b/tracer/src/Datadog.Trace/Configuration/ImmutableGCPFunctionSettings.cs index 8c6ac3323a07..d325ec3ab504 100644 --- a/tracer/src/Datadog.Trace/Configuration/ImmutableGCPFunctionSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/ImmutableGCPFunctionSettings.cs @@ -22,12 +22,12 @@ public ImmutableGCPFunctionSettings(IConfigurationSource? source, IConfiguration source ??= NullConfigurationSource.Instance; var config = new ConfigurationBuilder(source, telemetry); - var deprecatedFunctionKey = config.WithKeys(ConfigurationKeys.GCPFunction.DeprecatedFunctionNameKey).AsString(); - var deprecatedProjectKey = config.WithKeys(ConfigurationKeys.GCPFunction.DeprecatedProjectKey).AsString(); + var deprecatedFunctionKey = config.WithKeys(PlatformKeys.GCPFunction.DeprecatedFunctionNameKey).AsString(); + var deprecatedProjectKey = config.WithKeys(PlatformKeys.GCPFunction.DeprecatedProjectKey).AsString(); IsDeprecatedFunction = deprecatedFunctionKey != null && deprecatedProjectKey != null; - var functionNameKey = config.WithKeys(ConfigurationKeys.GCPFunction.FunctionNameKey).AsString(); - var functionTargetKey = config.WithKeys(ConfigurationKeys.GCPFunction.FunctionTargetKey).AsString(); + var functionNameKey = config.WithKeys(PlatformKeys.GCPFunction.FunctionNameKey).AsString(); + var functionTargetKey = config.WithKeys(PlatformKeys.GCPFunction.FunctionTargetKey).AsString(); IsNewerFunction = functionNameKey != null && functionTargetKey != null; IsGCPFunction = IsDeprecatedFunction || IsNewerFunction; diff --git a/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs b/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs index 31f18919ab40..91bc57339596 100644 --- a/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/IntegrationSettings.cs @@ -6,7 +6,6 @@ #nullable enable using System; -using System.Collections.Generic; using Datadog.Trace.Configuration.Telemetry; namespace Datadog.Trace.Configuration @@ -16,6 +15,23 @@ namespace Datadog.Trace.Configuration /// public class IntegrationSettings : IEquatable { + /// + /// Configuration key pattern for enabling or disabling an integration. + /// + public const string IntegrationEnabled = "DD_TRACE_{0}_ENABLED"; + + /// + /// Configuration key pattern for enabling or disabling Analytics in an integration. + /// + [Obsolete(DeprecationMessages.AppAnalytics)] + public const string AnalyticsEnabledKey = "DD_TRACE_{0}_ANALYTICS_ENABLED"; + + /// + /// Configuration key pattern for setting Analytics sampling rate in an integration. + /// + [Obsolete(DeprecationMessages.AppAnalytics)] + public const string AnalyticsSampleRateKey = "DD_TRACE_{0}_ANALYTICS_SAMPLE_RATE"; + /// /// Initializes a new instance of the class. /// @@ -23,7 +39,7 @@ public class IntegrationSettings : IEquatable /// The to use when retrieving configuration values. /// Has the integration been explicitly disabled /// The fallback values to use. Only used in manual instrumentation scenarios - internal IntegrationSettings(string integrationName, IConfigurationSource? source, bool isExplicitlyDisabled, IntegrationSettings? fallback = null) + internal IntegrationSettings(string? integrationName, IConfigurationSource? source, bool isExplicitlyDisabled, IntegrationSettings? fallback = null) { if (integrationName is null) { @@ -35,27 +51,30 @@ internal IntegrationSettings(string integrationName, IConfigurationSource? sourc // We don't record these in telemetry, because they're blocked anyway var config = new ConfigurationBuilder(source ?? NullConfigurationSource.Instance, NullConfigurationTelemetry.Instance); var upperName = integrationName.ToUpperInvariant(); - Enabled = isExplicitlyDisabled ? false : (config - .WithKeys( - string.Format(ConfigurationKeys.Integrations.Enabled, upperName), - string.Format(ConfigurationKeys.Integrations.Enabled, integrationName), - $"DD_{integrationName}_ENABLED") - .AsBool() - ?? fallback?.Enabled); + Enabled = isExplicitlyDisabled + ? false + : config + .WithKeys( + string.Format(IntegrationEnabled, upperName), + string.Format(IntegrationEnabled, integrationName), + string.Format(IntegrationEnabled, integrationName), + $"DD_{integrationName}_ENABLED") + .AsBool() + ?? fallback?.Enabled; #pragma warning disable 618 // App analytics is deprecated, but still used AnalyticsEnabled = config .WithKeys( - string.Format(ConfigurationKeys.Integrations.AnalyticsEnabled, upperName), - string.Format(ConfigurationKeys.Integrations.AnalyticsEnabled, integrationName), + string.Format(AnalyticsEnabledKey, upperName), + string.Format(AnalyticsEnabledKey, integrationName), $"DD_{integrationName}_ANALYTICS_ENABLED") .AsBool() ?? fallback?.AnalyticsEnabled; AnalyticsSampleRate = config .WithKeys( - string.Format(ConfigurationKeys.Integrations.AnalyticsSampleRate, upperName), - string.Format(ConfigurationKeys.Integrations.AnalyticsSampleRate, integrationName), + string.Format(AnalyticsSampleRateKey, upperName), + string.Format(AnalyticsSampleRateKey, integrationName), $"DD_{integrationName}_ANALYTICS_SAMPLE_RATE") .AsDouble(fallback?.AnalyticsSampleRate ?? 1.0); #pragma warning restore 618 diff --git a/tracer/src/Datadog.Trace/Configuration/PlatformKeys.Aws.cs b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.Aws.cs new file mode 100644 index 000000000000..3e74e9da1849 --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.Aws.cs @@ -0,0 +1,14 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// +#nullable enable +namespace Datadog.Trace.Configuration; + +internal static partial class PlatformKeys +{ + internal class Aws + { + public const string FunctionName = "AWS_LAMBDA_FUNCTION_NAME"; + } +} diff --git a/tracer/src/Datadog.Trace/Configuration/PlatformKeys.AzureAppService.cs b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.AzureAppService.cs new file mode 100644 index 000000000000..010a7a7e927b --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.AzureAppService.cs @@ -0,0 +1,55 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// +#nullable enable +namespace Datadog.Trace.Configuration; + +internal static partial class PlatformKeys +{ + internal class AzureAppService + { + /// + /// Example: 8c500027-5f00-400e-8f00-60000000000f+apm-dotnet-EastUSwebspace + /// Format: {subscriptionId}+{planResourceGroup}-{hostedInRegion} + /// + internal const string WebsiteOwnerNameKey = "WEBSITE_OWNER_NAME"; + + /// + /// This is the name of the resource group the site instance is assigned to. + /// + internal const string ResourceGroupKey = "WEBSITE_RESOURCE_GROUP"; + + /// + /// This is the unique name of the website instance within Azure App Services. + /// Its presence is used to determine if we are running in Azure App Services. + /// + internal const string SiteNameKey = "WEBSITE_SITE_NAME"; + + /// + /// This is the key for AzureAppServicePerformanceCounters + /// + internal const string CountersKey = "WEBSITE_COUNTERS_CLR"; + + /// + /// The instance name in Azure where the traced application is running. + /// + internal const string InstanceNameKey = "COMPUTERNAME"; + + /// + /// The instance ID in Azure where the traced application is running. + /// + internal const string InstanceIdKey = "WEBSITE_INSTANCE_ID"; + + /// + /// The operating system in Azure where the traced application is running. + /// + internal const string OperatingSystemKey = "WEBSITE_OS"; + + /// + /// Used to identify consumption plan functions. Consumption plans will either not have this variable, + /// or will have a value of "dynamic". + /// + public const string WebsiteSKU = "WEBSITE_SKU"; + } +} diff --git a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.AzureFunctions.cs b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.AzureFunctions.cs similarity index 93% rename from tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.AzureFunctions.cs rename to tracer/src/Datadog.Trace/Configuration/PlatformKeys.AzureFunctions.cs index 4b5144cadedd..70cf717b3cac 100644 --- a/tracer/src/Datadog.Trace/Configuration/ConfigurationKeys.AzureFunctions.cs +++ b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.AzureFunctions.cs @@ -1,4 +1,4 @@ -// +// // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. // @@ -7,7 +7,7 @@ namespace Datadog.Trace.Configuration; -internal partial class ConfigurationKeys +internal static partial class PlatformKeys { /// /// Reference: https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings diff --git a/tracer/src/Datadog.Trace/Configuration/PlatformKeys.GCPFunction.cs b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.GCPFunction.cs new file mode 100644 index 000000000000..c54c6b75a848 --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.GCPFunction.cs @@ -0,0 +1,34 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// +#nullable enable +namespace Datadog.Trace.Configuration; + +internal static partial class PlatformKeys +{ + internal class GCPFunction + { + /// + /// The name of functions running deprecated runtimes. + /// + internal const string DeprecatedFunctionNameKey = "FUNCTION_NAME"; + + /// + /// The name of the gcp project a deprecated function belongs to. Only set in functions running deprecated runtimes. + /// Used to tell whether or not we are in a deprecated function environment. + /// + internal const string DeprecatedProjectKey = "GCP_PROJECT"; + + /// + /// The name of functions running non-deprecated runtimes. + /// + internal const string FunctionNameKey = "K_SERVICE"; + + /// + /// The name of the function handler to be executed when the function is invoked. Only set in functions running non-deprecated runtimes. + /// Used to tell whether or not we are in a non-deprecated function environment. + /// + internal const string FunctionTargetKey = "FUNCTION_TARGET"; + } +} diff --git a/tracer/src/Datadog.Trace/Configuration/PlatformKeys.cs b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.cs new file mode 100644 index 000000000000..cde0e2ed9b89 --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/PlatformKeys.cs @@ -0,0 +1,21 @@ +// +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. +// + +#nullable enable + +namespace Datadog.Trace.Configuration; + +internal static partial class PlatformKeys +{ + /// + /// Platform key indicating the path to the .net core clr profiler + /// + public const string DotNetCoreClrProfiler = "CORECLR_PROFILER_PATH"; + + /// + /// Platform key indicating the path to the .net clr profiler + /// + public const string DotNetClrProfiler = "COR_PROFILER_PATH"; +} diff --git a/tracer/src/Datadog.Trace/Configuration/supported-configurations.json b/tracer/src/Datadog.Trace/Configuration/supported-configurations.json new file mode 100644 index 000000000000..6813a07d8c27 --- /dev/null +++ b/tracer/src/Datadog.Trace/Configuration/supported-configurations.json @@ -0,0 +1,290 @@ +{ + "supportedConfigurations": { + "DD_AAS_DOTNET_EXTENSION_VERSION": { "version": ["A"] }, + "DD_AAS_ENABLE_CUSTOM_METRICS": { "version": ["A"] }, + "DD_AAS_ENABLE_CUSTOM_TRACING": { "version": ["A"] }, + "DD_AGENT_HOST": { "version": ["A"], "description": "Test description that should not trigger regeneration" }, + "DD_API_KEY": { "version": ["A"] }, + "DD_API_SECURITY_ENABLED": { "version": ["A"] }, + "DD_API_SECURITY_ENDPOINT_COLLECTION_ENABLED": { "version": ["A"] }, + "DD_API_SECURITY_ENDPOINT_COLLECTION_MESSAGE_LIMIT": { "version": ["A"] }, + "DD_API_SECURITY_PARSE_RESPONSE_BODY": { "version": ["A"] }, + "DD_API_SECURITY_SAMPLE_DELAY": { "version": ["A"] }, + "DD_APM_ENABLE_RARE_SAMPLER": { "version": ["A"] }, + "DD_APM_RECEIVER_PORT": { "version": ["A"] }, + "DD_APM_RECEIVER_SOCKET": { "version": ["A"] }, + "DD_APM_TRACING_ENABLED": { "version": ["A"] }, + "DD_APPLICATION_MONITORING_CONFIG_FILE_ENABLED": { "version": ["A"] }, + "DD_APPSEC_AUTOMATED_USER_EVENTS_TRACKING": { "version": ["A"] }, + "DD_APPSEC_AUTO_USER_INSTRUMENTATION_MODE": { "version": ["A"] }, + "DD_APPSEC_ENABLED": { "version": ["A"] }, + "DD_APPSEC_EXTRA_HEADERS": { "version": ["A"] }, + "DD_APPSEC_HTTP_BLOCKED_TEMPLATE_HTML": { "version": ["A"] }, + "DD_APPSEC_HTTP_BLOCKED_TEMPLATE_JSON": { "version": ["A"] }, + "DD_APPSEC_IPHEADER": { "version": ["A"] }, + "DD_APPSEC_KEEP_TRACES": { "version": ["A"] }, + "DD_APPSEC_MAX_STACK_TRACE_DEPTH": { "version": ["A"] }, + "DD_APPSEC_MAX_STACK_TRACE_DEPTH_TOP_PERCENT": { "version": ["A"] }, + "DD_APPSEC_MAX_STACK_TRACES": { "version": ["A"] }, + "DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP": { "version": ["A"] }, + "DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP": { "version": ["A"] }, + "DD_APPSEC_RASP_ENABLED": { "version": ["A"] }, + "DD_APPSEC_RULES": { "version": ["A"] }, + "DD_APPSEC_SCA_ENABLED": { "version": ["A"] }, + "DD_APPSEC_STACK_TRACE_ENABLED": { "version": ["A"] }, + "DD_APPSEC_TRACE_RATE_LIMIT": { "version": ["A"] }, + "DD_APPSEC_WAF_DEBUG": { "version": ["A"] }, + "DD_APPSEC_WAF_TIMEOUT": { "version": ["A"] }, + "DD_AZURE_APP_SERVICES": { "version": ["A"] }, + "DD_CIVISIBILITY_AGENTLESS_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_AGENTLESS_URL": { "version": ["A"] }, + "DD_CIVISIBILITY_CODE_COVERAGE_COLLECTORPATH": { "version": ["A"] }, + "DD_CIVISIBILITY_CODE_COVERAGE_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_CODE_COVERAGE_ENABLE_JIT_OPTIMIZATIONS": { "version": ["A"] }, + "DD_CIVISIBILITY_CODE_COVERAGE_MODE": { "version": ["A"] }, + "DD_CIVISIBILITY_CODE_COVERAGE_PATH": { "version": ["A"] }, + "DD_CIVISIBILITY_CODE_COVERAGE_SNK_FILEPATH": { "version": ["A"] }, + "DD_CIVISIBILITY_DI_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_EARLY_FLAKE_DETECTION_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_EXTERNAL_CODE_COVERAGE_PATH": { "version": ["A"] }, + "DD_CIVISIBILITY_FLAKY_RETRY_COUNT": { "version": ["A"] }, + "DD_CIVISIBILITY_FLAKY_RETRY_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_FORCE_AGENT_EVP_PROXY": { "version": ["A"] }, + "DD_CIVISIBILITY_GAC_INSTALL_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_GIT_UPLOAD_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_IMPACTED_TESTS_DETECTION_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_ITR_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_KNOWN_TESTS_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_LOGS_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_RUM_FLUSH_WAIT_MILLIS": { "version": ["A"] }, + "DD_CIVISIBILITY_TESTSSKIPPING_ENABLED": { "version": ["A"] }, + "DD_CIVISIBILITY_TOTAL_FLAKY_RETRY_COUNT": { "version": ["A"] }, + "DD_CODE_ORIGIN_FOR_SPANS_ENABLED": { "version": ["A"] }, + "DD_CODE_ORIGIN_FOR_SPANS_MAX_USER_FRAMES": { "version": ["A"] }, + "DD_DATA_STREAMS_ENABLED": { "version": ["A"] }, + "DD_DATA_STREAMS_LEGACY_HEADERS": { "version": ["A"] }, + "DD_DBM_PROPAGATION_MODE": { "version": ["A"] }, + "DD_DIAGNOSTIC_SOURCE_ENABLED": { "version": ["A"] }, + "DD_DISABLED_INTEGRATIONS": { "version": ["A"] }, + "DD_DOGSTATSD_ARGS": { "version": ["A"] }, + "DD_DOGSTATSD_PATH": { "version": ["A"] }, + "DD_DOGSTATSD_PIPE_NAME": { "version": ["A"] }, + "DD_DOGSTATSD_PORT": { "version": ["A"] }, + "DD_DOGSTATSD_SOCKET": { "version": ["A"] }, + "DD_DOGSTATSD_URL": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_DIAGNOSTICS_INTERVAL": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_ENABLED": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_MAX_DEPTH_TO_SERIALIZE": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_MAX_TIME_TO_SERIALIZE": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_REDACTED_EXCLUDED_IDENTIFIERS": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_REDACTED_TYPES": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_UPLOAD_BATCH_SIZE": { "version": ["A"] }, + "DD_DYNAMIC_INSTRUMENTATION_UPLOAD_FLUSH_INTERVAL": { "version": ["A"] }, + "DD_ENV": { "version": ["A"] }, + "DD_EXCEPTION_DEBUGGING_ENABLED": { "version": ["A"] }, + "DD_EXCEPTION_REPLAY_CAPTURE_FULL_CALLSTACK_ENABLED": { "version": ["A"] }, + "DD_EXCEPTION_REPLAY_CAPTURE_MAX_FRAMES": { "version": ["A"] }, + "DD_EXCEPTION_REPLAY_ENABLED": { "version": ["A"] }, + "DD_EXCEPTION_REPLAY_MAX_EXCEPTION_ANALYSIS_LIMIT": { "version": ["A"] }, + "DD_EXCEPTION_REPLAY_RATE_LIMIT_SECONDS": { "version": ["A"] }, + "DD_EXPERIMENTAL_APPSEC_USE_UNSAFE_ENCODER": { "version": ["A"] }, + "DD_GIT_COMMIT_SHA": { "version": ["A"] }, + "DD_GIT_REPOSITORY_URL": { "version": ["A"] }, + "DD_HTTP_CLIENT_ERROR_STATUSES": { "version": ["A"] }, + "DD_HTTP_SERVER_ERROR_STATUSES": { "version": ["A"] }, + "DD_HTTP_SERVER_TAG_QUERY_STRING": { "version": ["A"] }, + "DD_HTTP_SERVER_TAG_QUERY_STRING_SIZE": { "version": ["A"] }, + "DD_IAST_COOKIE_FILTER_PATTERN": { "version": ["A"] }, + "DD_IAST_DB_ROWS_TO_TAINT": { "version": ["A"] }, + "DD_IAST_DEDUPLICATION_ENABLED": { "version": ["A"] }, + "DD_IAST_ENABLED": { "version": ["A"] }, + "DD_IAST_MAX_CONCURRENT_REQUESTS": { "version": ["A"] }, + "DD_IAST_MAX_RANGE_COUNT": { "version": ["A"] }, + "DD_IAST_REDACTION_ENABLED": { "version": ["A"] }, + "DD_IAST_REDACTION_NAME_PATTERN": { "version": ["A"] }, + "DD_IAST_REDACTION_VALUE_PATTERN": { "version": ["A"] }, + "DD_IAST_REGEXP_TIMEOUT": { "version": ["A"] }, + "DD_IAST_REQUEST_SAMPLING": { "version": ["A"] }, + "DD_IAST_TELEMETRY_VERBOSITY": { "version": ["A"] }, + "DD_IAST_TRUNCATION_MAX_VALUE_LENGTH": { "version": ["A"] }, + "DD_IAST_VULNERABILITIES_PER_REQUEST": { "version": ["A"] }, + "DD_IAST_WEAK_CIPHER_ALGORITHMS": { "version": ["A"] }, + "DD_IAST_WEAK_HASH_ALGORITHMS": { "version": ["A"] }, + "DD_INJECTION_ENABLED": { "version": ["A"] }, + "DD_INSTRUMENTATION_TELEMETRY_AGENTLESS_ENABLED": { "version": ["A"] }, + "DD_INSTRUMENTATION_TELEMETRY_AGENT_PROXY_ENABLED": { "version": ["A"] }, + "DD_INSTRUMENTATION_TELEMETRY_ENABLED": { "version": ["A"] }, + "DD_INSTRUMENTATION_TELEMETRY_URL": { "version": ["A"] }, + "DD_INTERNAL_RCM_POLL_INTERVAL": { "version": ["A"] }, + "DD_INTERNAL_TELEMETRY_DEBUG_ENABLED": { "version": ["A"] }, + "DD_INTERNAL_WAIT_FOR_DEBUGGER_ATTACH": { "version": ["A"] }, + "DD_INTERNAL_WAIT_FOR_NATIVE_DEBUGGER_ATTACH": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_AZURE_FUNCTIONS_HOST_ENABLED": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_BATCH_PERIOD_SECONDS": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_HOST": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_INTEGRATIONS": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_MAX_BATCH_SIZE": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_MAX_QUEUE_SIZE": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_MINIMUM_LEVEL": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_SOURCE": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_TAGS": { "version": ["A"] }, + "DD_LOGS_DIRECT_SUBMISSION_URL": { "version": ["A"] }, + "DD_LOGS_INJECTION": { "version": ["A"] }, + "DD_MAX_LOGFILE_SIZE": { "version": ["A"] }, + "DD_MAX_TRACES_PER_SECOND": { "version": ["A"] }, + "DD_METRICS_OTEL_ENABLED": { "version": ["A"] }, + "DD_METRICS_OTEL_METER_NAMES": { "version": ["A"] }, + "DD_PROXY_HTTPS": { "version": ["A"] }, + "DD_PROXY_NO_PROXY": { "version": ["A"] }, + "DD_PROFILING_CODEHOTSPOTS_ENABLED": { "version": ["A"] }, + "DD_PROFILING_ENABLED": { "version": ["A"] }, + "DD_PROFILING_ENDPOINT_COLLECTION_ENABLED": { "version": ["A"] }, + "DD_PROFILING_MANAGED_ACTIVATION_ENABLED": { "version": ["A"] }, + "DD_REMOTE_CONFIGURATION_ENABLED": { "version": ["A"] }, + "DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS": { "version": ["A"] }, + "DD_RUNTIME_METRICS_ENABLED": { "version": ["A"] }, + "DD_SERVICE": { "version": ["A"] }, + "DD_SITE": { "version": ["A"] }, + "DD_SPAN_SAMPLING_RULES": { "version": ["A"] }, + "DD_SYMBOL_DATABASE_BATCH_SIZE_BYTES": { "version": ["A"] }, + "DD_SYMBOL_DATABASE_COMPRESSION_ENABLED": { "version": ["A"] }, + "DD_SYMBOL_DATABASE_THIRD_PARTY_DETECTION_EXCLUDES": { "version": ["A"] }, + "DD_SYMBOL_DATABASE_THIRD_PARTY_DETECTION_INCLUDES": { "version": ["A"] }, + "DD_SYMBOL_DATABASE_UPLOAD_ENABLED": { "version": ["A"] }, + "DD_TAGS": { "version": ["A"] }, + "DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED": { "version": ["A"] }, + "DD_TELEMETRY_HEARTBEAT_INTERVAL": { "version": ["A"] }, + "DD_TELEMETRY_LOG_COLLECTION_ENABLED": { "version": ["A"] }, + "DD_TELEMETRY_METRICS_ENABLED": { "version": ["A"] }, + "DD_TEST_MANAGEMENT_ATTEMPT_TO_FIX_RETRIES": { "version": ["A"] }, + "DD_TEST_MANAGEMENT_ENABLED": { "version": ["A"] }, + "DD_TEST_SESSION_NAME": { "version": ["A"] }, + "DD_THIRD_PARTY_DETECTION_EXCLUDES": { "version": ["A"] }, + "DD_THIRD_PARTY_DETECTION_INCLUDES": { "version": ["A"] }, + "DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED": { "version": ["A"] }, + "DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED": { "version": ["A"] }, + "DD_TRACE_ACTIVITY_LISTENER_ENABLED": { "version": ["A"] }, + "DD_TRACE_AGENT_ARGS": { "version": ["A"] }, + "DD_TRACE_AGENT_PATH": { "version": ["A"] }, + "DD_TRACE_AGENT_PORT": { "version": ["A"] }, + "DD_TRACE_AGENT_URL": { "version": ["A"] }, + "DD_TRACE_ANALYTICS_ENABLED": { "version": ["A"] }, + "DD_TRACE_AWS_ADD_SPAN_POINTERS": { "version": ["A"] }, + "DD_TRACE_AZURE_SERVICEBUS_BATCH_LINKS_ENABLED": { "version": ["A"] }, + "DD_TRACE_BAGGAGE_MAX_BYTES": { "version": ["A"] }, + "DD_TRACE_BAGGAGE_MAX_ITEMS": { "version": ["A"] }, + "DD_TRACE_BAGGAGE_TAG_KEYS": { "version": ["A"] }, + "DD_TRACE_BATCH_INTERVAL": { "version": ["A"] }, + "DD_TRACE_BUFFER_SIZE": { "version": ["A"] }, + "DD_TRACE_BYPASS_HTTP_REQUEST_URL_CACHING_ENABLED": { "version": ["A"] }, + "DD_TRACE_CLIENT_IP_ENABLED": { "version": ["A"] }, + "DD_TRACE_CLIENT_IP_HEADER": { "version": ["A"] }, + "DD_TRACE_COMMANDS_COLLECTION_ENABLED": { "version": ["A"] }, + "DD_TRACE_CONFIG_FILE": { "version": ["A"] }, + "DD_TRACE_DATA_PIPELINE_ENABLED": { "version": ["A"] }, + "DD_TRACE_DEBUG": { "version": ["A"] }, + "DD_TRACE_DEBUG_LOOKUP_FALLBACK": { "version": ["A"] }, + "DD_TRACE_DEBUG_LOOKUP_MDTOKEN": { "version": ["A"] }, + "DD_TRACE_DELAY_WCF_INSTRUMENTATION_ENABLED": { "version": ["A"] }, + "DD_TRACE_DISABLED_ACTIVITY_SOURCES": { "version": ["A"] }, + "DD_TRACE_DISABLED_ADONET_COMMAND_TYPES": { "version": ["A"] }, + "DD_TRACE_ENABLED": { "version": ["A"] }, + "DD_TRACE_EXPAND_ROUTE_TEMPLATES_ENABLED": { "version": ["A"] }, + "DD_TRACE_EXPERIMENTAL_FEATURES_ENABLED": { "version": ["A"] }, + "DD_TRACE_GIT_METADATA_ENABLED": { "version": ["A"] }, + "DD_TRACE_GRAPHQL_ERROR_EXTENSIONS": { "version": ["A"] }, + "DD_TRACE_GRPC_TAGS": { "version": ["A"] }, + "DD_TRACE_HEADER_TAG_NORMALIZATION_FIX_ENABLED": { "version": ["A"] }, + "DD_TRACE_HEADER_TAGS": { "version": ["A"] }, + "DD_TRACE_HTTP_CLIENT_ERROR_STATUSES": { "version": ["A"] }, + "DD_TRACE_HTTP_CLIENT_EXCLUDED_URL_SUBSTRINGS": { "version": ["A"] }, + "DD_TRACE_HTTP_SERVER_ERROR_STATUSES": { "version": ["A"] }, + "DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED": { "version": ["A"] }, + "DD_TRACE_INJECT_CONTEXT_INTO_STORED_PROCEDURES_ENABLED": { "version": ["A"] }, + "DD_TRACE_KAFKA_CREATE_CONSUMER_SCOPE_ENABLED": { "version": ["A"] }, + "DD_TRACE_LOG_DIRECTORY": { "version": ["A"] }, + "DD_TRACE_LOG_SINKS": { "version": ["A"] }, + "DD_TRACE_LOGFILE_RETENTION_DAYS": { "version": ["A"] }, + "DD_TRACE_LOGGING_RATE": { "version": ["A"] }, + "DD_TRACE_METHODS": { "version": ["A"] }, + "DD_TRACE_METRICS_ENABLED": { "version": ["A"] }, + "DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP": { "version": ["A"] }, + "DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP_TIMEOUT": { "version": ["A"] }, + "DD_TRACE_OTEL_ENABLED": { "version": ["A"] }, + "DD_TRACE_PARTIAL_FLUSH_ENABLED": { "version": ["A"] }, + "DD_TRACE_PARTIAL_FLUSH_MIN_SPANS": { "version": ["A"] }, + "DD_TRACE_PEER_SERVICE_DEFAULTS_ENABLED": { "version": ["A"] }, + "DD_TRACE_PEER_SERVICE_MAPPING": { "version": ["A"] }, + "DD_TRACE_PIPE_NAME": { "version": ["A"] }, + "DD_TRACE_PIPE_TIMEOUT_MS": { "version": ["A"] }, + "DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT": { "version": ["A"] }, + "DD_TRACE_PROPAGATION_EXTRACT_FIRST": { "version": ["A"] }, + "DD_TRACE_PROPAGATION_STYLE": { "version": ["A"] }, + "DD_TRACE_PROPAGATION_STYLE_EXTRACT": { "version": ["A"] }, + "DD_TRACE_PROPAGATION_STYLE_INJECT": { "version": ["A"] }, + "DD_TRACE_RATE_LIMIT": { "version": ["A"] }, + "DD_TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED": { "version": ["A"] }, + "DD_TRACE_ROUTE_TEMPLATE_RESOURCE_NAMES_ENABLED": { "version": ["A"] }, + "DD_TRACE_SAMPLE_RATE": { "version": ["A"] }, + "DD_TRACE_SAMPLING_RULES": { "version": ["A"] }, + "DD_TRACE_SAMPLING_RULES_FORMAT": { "version": ["A"] }, + "DD_TRACE_SERVICE_MAPPING": { "version": ["A"] }, + "DD_TRACE_SPAN_ATTRIBUTE_SCHEMA": { "version": ["A"] }, + "DD_TRACE_STARTUP_LOGS": { "version": ["A"] }, + "DD_TRACE_STATS_COMPUTATION_ENABLED": { "version": ["A"] }, + "DD_TRACE_WCF_RESOURCE_OBFUSCATION_ENABLED": { "version": ["A"] }, + "DD_TRACE_WCF_WEB_HTTP_RESOURCE_NAMES_ENABLED": { "version": ["A"] }, + "DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH": { "version": ["A"] }, + "DD_VERSION": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_ENDPOINT": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_HEADERS": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_METRICS_HEADERS": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_PROTOCOL": { "version": ["A"] }, + "OTEL_EXPORTER_OTLP_TIMEOUT": { "version": ["A"] }, + "OTEL_LOG_LEVEL": { "version": ["A"] }, + "OTEL_METRIC_EXPORT_INTERVAL": { "version": ["A"] }, + "OTEL_METRIC_EXPORT_TIMEOUT": { "version": ["A"] }, + "OTEL_METRICS_EXPORTER": { "version": ["A"] }, + "OTEL_PROPAGATORS": { "version": ["A"] }, + "OTEL_RESOURCE_ATTRIBUTES": { "version": ["A"] }, + "OTEL_SDK_DISABLED": { "version": ["A"] }, + "OTEL_SERVICE_NAME": { "version": ["A"] }, + "OTEL_TRACES_EXPORTER": { "version": ["A"] }, + "OTEL_TRACES_SAMPLER": { "version": ["A"] }, + "OTEL_TRACES_SAMPLER_ARG": { "version": ["A"] }, + "_DD_INTERNAL_IS_RUNNING_IN_CIVISIBILITY": { "version": ["A"] }, + "_DD_TRACE_STATS_COMPUTATION_INTERVAL": { "version": ["A"] } + }, + "aliases": { + "DD_AGENT_HOST": ["DD_TRACE_AGENT_HOSTNAME", "DATADOG_TRACE_AGENT_HOSTNAME_OPTIMIZED"], + "DD_API_SECURITY_ENABLED": ["DD_EXPERIMENTAL_API_SECURITY_ENABLED"], + "DD_TRACE_CLIENT_IP_HEADER": ["DD_APPSEC_IPHEADER"], + "DD_SERVICE": ["DD_SERVICE_NAME"], + "DD_TAGS": ["DD_TRACE_GLOBAL_TAGS"], + "DD_TRACE_AGENT_PORT": ["DATADOG_TRACE_AGENT_PORT"], + "DD_TRACE_CONFIG_FILE": ["DD_DOTNET_TRACER_CONFIG_FILE"], + "DD_TRACE_PROPAGATION_STYLE_EXTRACT": ["DD_PROPAGATION_STYLE_EXTRACT", "DD_TRACE_PROPAGATION_STYLE"], + "DD_TRACE_PROPAGATION_STYLE_INJECT": ["DD_PROPAGATION_STYLE_INJECT", "DD_TRACE_PROPAGATION_STYLE"], + "DD_EXCEPTION_REPLAY_ENABLED": ["DD_EXCEPTION_DEBUGGING_ENABLED"], + "DD_TRACE_HTTP_CLIENT_ERROR_STATUSES": ["DD_HTTP_CLIENT_ERROR_STATUSES"], + "DD_TRACE_HTTP_SERVER_ERROR_STATUSES": ["DD_HTTP_SERVER_ERROR_STATUSES"], + "DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS": ["DD_INTERNAL_RCM_POLL_INTERVAL"], + "DD_TRACE_RATE_LIMIT": ["DD_MAX_TRACES_PER_SECOND"], + "DD_TRACE_OTEL_ENABLED": ["DD_TRACE_ACTIVITY_LISTENER_ENABLED"], + "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL": ["OTEL_EXPORTER_OTLP_PROTOCOL"], + "OTEL_EXPORTER_OTLP_METRICS_HEADERS": ["OTEL_EXPORTER_OTLP_HEADERS"], + "OTEL_EXPORTER_OTLP_METRICS_TIMEOUT": ["OTEL_EXPORTER_OTLP_TIMEOUT"] + }, + "deprecations": { + "DD_TRACE_ANALYTICS_ENABLED": "Deprecated - App Analytics is deprecated", + "DD_TRACE_LOG_PATH": "Deprecated, use DD_TRACE_LOG_DIRECTORY instead, and make sure it is a directory and not a file path", + "DD_PROPAGATION_STYLE_INJECT": "Deprecated, use DD_TRACE_PROPAGATION_STYLE_INJECT instead" + } +} diff --git a/tracer/src/Datadog.Trace/ContinuousProfiler/ConfigurationKeys.cs b/tracer/src/Datadog.Trace/ContinuousProfiler/ConfigurationKeys.cs deleted file mode 100644 index 959e833487c6..000000000000 --- a/tracer/src/Datadog.Trace/ContinuousProfiler/ConfigurationKeys.cs +++ /dev/null @@ -1,16 +0,0 @@ -// -// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. -// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. -// - -namespace Datadog.Trace.ContinuousProfiler -{ - internal static class ConfigurationKeys - { - public const string ProfilingEnabled = "DD_PROFILING_ENABLED"; - public const string CodeHotspotsEnabled = "DD_PROFILING_CODEHOTSPOTS_ENABLED"; - public const string EndpointProfilingEnabled = "DD_PROFILING_ENDPOINT_COLLECTION_ENABLED"; - public const string SsiDeployed = "DD_INJECTION_ENABLED"; - public const string ProfilerManagedActivationEnabled = "DD_PROFILING_MANAGED_ACTIVATION_ENABLED"; - } -} diff --git a/tracer/src/Datadog.Trace/ContinuousProfiler/ContextTracker.cs b/tracer/src/Datadog.Trace/ContinuousProfiler/ContextTracker.cs index a5c1f33b9f77..9ec5afe2fc7b 100644 --- a/tracer/src/Datadog.Trace/ContinuousProfiler/ContextTracker.cs +++ b/tracer/src/Datadog.Trace/ContinuousProfiler/ContextTracker.cs @@ -7,6 +7,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; +using Datadog.Trace.Configuration; using Datadog.Trace.ExtensionMethods; using Datadog.Trace.Logging; using Datadog.Trace.Util; @@ -43,8 +44,8 @@ internal class ContextTracker : IContextTracker public ContextTracker(IProfilerStatus status) { _status = status; - _isCodeHotspotsEnabled = EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.CodeHotspotsEnabled)?.ToBoolean() ?? true; - _isEndpointProfilingEnabled = EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.EndpointProfilingEnabled)?.ToBoolean() ?? true; + _isCodeHotspotsEnabled = EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.Profiler.CodeHotspotsEnabled)?.ToBoolean() ?? true; + _isEndpointProfilingEnabled = EnvironmentHelpers.GetEnvironmentVariable(ConfigurationKeys.Profiler.EndpointProfilingEnabled)?.ToBoolean() ?? true; _traceContextPtr = new ThreadLocal(); } diff --git a/tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerSettings.cs b/tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerSettings.cs index cfa4eb5fdb93..688b31ebee97 100644 --- a/tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerSettings.cs +++ b/tracer/src/Datadog.Trace/ContinuousProfiler/ProfilerSettings.cs @@ -24,7 +24,7 @@ internal ProfilerSettings(IConfigurationSource config, IConfigurationSource envC if (!IsProfilingSupported) { ProfilerState = ProfilerState.Disabled; - telemetry.Record(ConfigurationKeys.ProfilingEnabled, false, ConfigurationOrigins.Calculated); + telemetry.Record(ConfigurationKeys.Profiler.ProfilingEnabled, false, ConfigurationOrigins.Calculated); return; } @@ -32,7 +32,7 @@ internal ProfilerSettings(IConfigurationSource config, IConfigurationSource envC // as that's all that applies var envConfigBuilder = new ConfigurationBuilder(envConfig, telemetry); var managedActivationEnabled = envConfigBuilder - .WithKeys(ConfigurationKeys.ProfilerManagedActivationEnabled) + .WithKeys(ConfigurationKeys.Profiler.ProfilerManagedActivationEnabled) .AsBool(true); // If we're using managed activation, we use the "full" config source set. @@ -45,7 +45,7 @@ internal ProfilerSettings(IConfigurationSource config, IConfigurationSource envC // the profiler could be enabled via ContinuousProfiler.ConfigurationKeys.SsiDeployed. If it is non-empty, then the // profiler is "active", though won't begin profiling until 30 seconds have passed + at least 1 span has been generated. var profilingEnabled = profilingConfig - .WithKeys(ConfigurationKeys.ProfilingEnabled) + .WithKeys(ConfigurationKeys.Profiler.ProfilingEnabled) // We stick with strings here instead of using the `GetAs` method, // so that telemetry continues to store true/false/auto, instead of the enum values. .AsString( diff --git a/tracer/src/Datadog.Trace/Util/EnvironmentHelpers.cs b/tracer/src/Datadog.Trace/Util/EnvironmentHelpers.cs index ab48143ce2cf..016a395c25cf 100644 --- a/tracer/src/Datadog.Trace/Util/EnvironmentHelpers.cs +++ b/tracer/src/Datadog.Trace/Util/EnvironmentHelpers.cs @@ -104,7 +104,7 @@ public static IDictionary GetEnvironmentVariables() /// public static bool IsAzureAppServices() { - return EnvironmentVariableExists(ConfigurationKeys.AzureAppService.SiteNameKey); + return EnvironmentVariableExists(PlatformKeys.AzureAppService.SiteNameKey); } /// @@ -116,8 +116,8 @@ public static bool IsAzureAppServices() public static bool IsAzureFunctions() { return IsAzureAppServices() && - EnvironmentVariableExists(ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime) && - EnvironmentVariableExists(ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion); + EnvironmentVariableExists(PlatformKeys.AzureFunctions.FunctionsWorkerRuntime) && + EnvironmentVariableExists(PlatformKeys.AzureFunctions.FunctionsExtensionVersion); } /// @@ -152,7 +152,7 @@ public static bool IsRunningInAzureFunctionsHost() cmd.IndexOf("--workerId", StringComparison.OrdinalIgnoreCase) >= 0; return IsAzureFunctions() - && string.Equals(GetEnvironmentVariable(ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, defaultValue: string.Empty), "dotnet-isolated", StringComparison.Ordinal) + && string.Equals(GetEnvironmentVariable(PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, defaultValue: string.Empty), "dotnet-isolated", StringComparison.Ordinal) && !hasWorkerId; } @@ -174,10 +174,10 @@ public static bool IsAwsLambda() /// public static bool IsGoogleCloudFunctions() { - return (EnvironmentVariableExists(ConfigurationKeys.GCPFunction.FunctionNameKey) && - EnvironmentVariableExists(ConfigurationKeys.GCPFunction.FunctionTargetKey)) || - (EnvironmentVariableExists(ConfigurationKeys.GCPFunction.DeprecatedFunctionNameKey) && - EnvironmentVariableExists(ConfigurationKeys.GCPFunction.DeprecatedProjectKey)); + return (EnvironmentVariableExists(PlatformKeys.GCPFunction.FunctionNameKey) && + EnvironmentVariableExists(PlatformKeys.GCPFunction.FunctionTargetKey)) || + (EnvironmentVariableExists(PlatformKeys.GCPFunction.DeprecatedFunctionNameKey) && + EnvironmentVariableExists(PlatformKeys.GCPFunction.DeprecatedProjectKey)); } /// diff --git a/tracer/src/Datadog.Trace/Util/EnvironmentHelpersNoLogging.cs b/tracer/src/Datadog.Trace/Util/EnvironmentHelpersNoLogging.cs index 9d43a55df961..7c84e447105e 100644 --- a/tracer/src/Datadog.Trace/Util/EnvironmentHelpersNoLogging.cs +++ b/tracer/src/Datadog.Trace/Util/EnvironmentHelpersNoLogging.cs @@ -24,12 +24,12 @@ internal static bool IsServerlessEnvironment(out Exception? exceptionInReading) Exception? firstException = null; var isServerless = CheckEnvVar(LambdaMetadata.FunctionNameEnvVar, ref firstException) - || (CheckEnvVar(ConfigurationKeys.AzureAppService.SiteNameKey, ref firstException) + || (CheckEnvVar(PlatformKeys.AzureAppService.SiteNameKey, ref firstException) && !CheckEnvVar(ConfigurationKeys.AzureAppService.AzureAppServicesContextKey, ref firstException)) - || (CheckEnvVar(ConfigurationKeys.GCPFunction.FunctionNameKey, ref firstException) - && CheckEnvVar(ConfigurationKeys.GCPFunction.FunctionTargetKey, ref firstException)) - || (CheckEnvVar(ConfigurationKeys.GCPFunction.DeprecatedFunctionNameKey, ref firstException) - && CheckEnvVar(ConfigurationKeys.GCPFunction.DeprecatedProjectKey, ref firstException)); + || (CheckEnvVar(PlatformKeys.GCPFunction.FunctionNameKey, ref firstException) + && CheckEnvVar(PlatformKeys.GCPFunction.FunctionTargetKey, ref firstException)) + || (CheckEnvVar(PlatformKeys.GCPFunction.DeprecatedFunctionNameKey, ref firstException) + && CheckEnvVar(PlatformKeys.GCPFunction.DeprecatedProjectKey, ref firstException)); exceptionInReading = firstException; return isServerless; diff --git a/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs b/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs index 224d74354fbe..a5a3666c4fa7 100644 --- a/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs +++ b/tracer/test/Datadog.Trace.ClrProfiler.Managed.Tests/DbScopeFactoryTests.cs @@ -102,8 +102,8 @@ public async Task CreateDbCommandScope_ReturnNullForAdoNetDisabledIntegration(Ty var tracerSettings = TracerSettings.Create(new() { - { string.Format(ConfigurationKeys.Integrations.Enabled, integrationName), "true" }, - { string.Format(ConfigurationKeys.Integrations.Enabled, nameof(IntegrationId.AdoNet)), "false" }, + { string.Format(IntegrationSettings.IntegrationEnabled, integrationName), "true" }, + { string.Format(IntegrationSettings.IntegrationEnabled, nameof(IntegrationId.AdoNet)), "false" }, }); await using var tracer = TracerHelper.CreateWithFakeAgent(tracerSettings); @@ -750,7 +750,7 @@ private static ScopedTracer CreateTracerWithIntegrationEnabled(string integratio // Set up tracer var tracerSettings = TracerSettings.Create(new() { - { string.Format(ConfigurationKeys.Integrations.Enabled, integrationName), enabled }, + { string.Format(IntegrationSettings.IntegrationEnabled, integrationName), enabled }, }); return TracerHelper.Create(tracerSettings); } diff --git a/tracer/test/Datadog.Trace.IntegrationTests/Tagging/AASTagsTests.cs b/tracer/test/Datadog.Trace.IntegrationTests/Tagging/AASTagsTests.cs index 98fb0d91012d..6b73272acbc0 100644 --- a/tracer/test/Datadog.Trace.IntegrationTests/Tagging/AASTagsTests.cs +++ b/tracer/test/Datadog.Trace.IntegrationTests/Tagging/AASTagsTests.cs @@ -202,12 +202,12 @@ private IConfigurationSource GetMockVariables() // This is a needed configuration for the AAS extension { ConfigurationKeys.ApiKey, "1" }, { ConfigurationKeys.AzureAppService.AzureAppServicesContextKey, "1" }, - { ConfigurationKeys.AzureAppService.WebsiteOwnerNameKey, $"SubscriptionId+ResourceGroup-EastUSwebspace" }, - { ConfigurationKeys.AzureAppService.ResourceGroupKey, "SiteResourceGroup" }, - { ConfigurationKeys.AzureAppService.SiteNameKey, "SiteName" }, - { ConfigurationKeys.AzureAppService.OperatingSystemKey, "windows" }, - { ConfigurationKeys.AzureAppService.InstanceIdKey, "InstanceId" }, - { ConfigurationKeys.AzureAppService.InstanceNameKey, "InstanceName" }, + { PlatformKeys.AzureAppService.WebsiteOwnerNameKey, $"SubscriptionId+ResourceGroup-EastUSwebspace" }, + { PlatformKeys.AzureAppService.ResourceGroupKey, "SiteResourceGroup" }, + { PlatformKeys.AzureAppService.SiteNameKey, "SiteName" }, + { PlatformKeys.AzureAppService.OperatingSystemKey, "windows" }, + { PlatformKeys.AzureAppService.InstanceIdKey, "InstanceId" }, + { PlatformKeys.AzureAppService.InstanceNameKey, "InstanceName" }, }; return new NameValueConfigurationSource(collection); diff --git a/tracer/test/Datadog.Trace.TestHelpers/PlatformHelpers/AzureAppServiceHelper.cs b/tracer/test/Datadog.Trace.TestHelpers/PlatformHelpers/AzureAppServiceHelper.cs index 3128d0930cf6..da2553483ac6 100644 --- a/tracer/test/Datadog.Trace.TestHelpers/PlatformHelpers/AzureAppServiceHelper.cs +++ b/tracer/test/Datadog.Trace.TestHelpers/PlatformHelpers/AzureAppServiceHelper.cs @@ -50,10 +50,10 @@ public static IConfigurationSource GetRequiredAasConfigurationValues( { var vars = Environment.GetEnvironmentVariables(); - if (vars.Contains(ConfigurationKeys.AzureAppService.InstanceNameKey)) + if (vars.Contains(PlatformKeys.AzureAppService.InstanceNameKey)) { // This is the COMPUTERNAME key which we'll remove for consistent testing - vars.Remove(ConfigurationKeys.AzureAppService.InstanceNameKey); + vars.Remove(PlatformKeys.AzureAppService.InstanceNameKey); } if (vars.Contains(ConfigurationKeys.DebugEnabled)) @@ -73,22 +73,22 @@ public static IConfigurationSource GetRequiredAasConfigurationValues( vars.Add(ConfigurationKeys.AzureAppService.SiteExtensionVersionKey, "3.0.0"); } - vars.Add(ConfigurationKeys.AzureAppService.WebsiteOwnerNameKey, $"{subscriptionId}+{planResourceGroup}-EastUSwebspace"); - vars.Add(ConfigurationKeys.AzureAppService.ResourceGroupKey, siteResourceGroup); - vars.Add(ConfigurationKeys.AzureAppService.SiteNameKey, deploymentId); - vars.Add(ConfigurationKeys.AzureAppService.OperatingSystemKey, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "windows" : "linux"); - vars.Add(ConfigurationKeys.AzureAppService.InstanceIdKey, "instance_id"); - vars.Add(ConfigurationKeys.AzureAppService.InstanceNameKey, "instance_name"); + vars.Add(PlatformKeys.AzureAppService.WebsiteOwnerNameKey, $"{subscriptionId}+{planResourceGroup}-EastUSwebspace"); + vars.Add(PlatformKeys.AzureAppService.ResourceGroupKey, siteResourceGroup); + vars.Add(PlatformKeys.AzureAppService.SiteNameKey, deploymentId); + vars.Add(PlatformKeys.AzureAppService.OperatingSystemKey, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "windows" : "linux"); + vars.Add(PlatformKeys.AzureAppService.InstanceIdKey, "instance_id"); + vars.Add(PlatformKeys.AzureAppService.InstanceNameKey, "instance_name"); vars.Add(ConfigurationKeys.DebugEnabled, ddTraceDebug); if (functionsVersion != null) { - vars.Add(ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion, functionsVersion); + vars.Add(PlatformKeys.AzureFunctions.FunctionsExtensionVersion, functionsVersion); } if (functionsRuntime != null) { - vars.Add(ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, functionsRuntime); + vars.Add(PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, functionsRuntime); } vars.Add(ConfigurationKeys.AzureAppService.AasEnableCustomTracing, enableCustomTracing ?? "false"); diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableAzureAppServiceSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableAzureAppServiceSettingsTests.cs index 9f8fd9d62d4d..e01bed00230e 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableAzureAppServiceSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableAzureAppServiceSettingsTests.cs @@ -36,7 +36,7 @@ public void IsUnsafeToTrace(string value, bool expected) [InlineData("test1+test2", "test1")] public void SubscriptionId(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.WebsiteOwnerNameKey, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.WebsiteOwnerNameKey, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.SubscriptionId.Should().Be(expected); @@ -46,7 +46,7 @@ public void SubscriptionId(string value, string expected) [MemberData(nameof(StringTestCases))] public void ResourceGroup(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.ResourceGroupKey, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.ResourceGroupKey, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.ResourceGroup.Should().Be(expected); @@ -56,7 +56,7 @@ public void ResourceGroup(string value, string expected) [MemberData(nameof(StringTestCases))] public void SiteName(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.SiteNameKey, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.SiteNameKey, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.SiteName.Should().Be(expected); @@ -72,9 +72,9 @@ public void SiteName(string value, string expected) public void ResourceId(string subscriptionId, string siteName, string resourceGroup, string expected) { var source = CreateConfigurationSource( - (ConfigurationKeys.AzureAppService.SiteNameKey, siteName), - (ConfigurationKeys.AzureAppService.ResourceGroupKey, resourceGroup), - (ConfigurationKeys.AzureAppService.WebsiteOwnerNameKey, subscriptionId)); + (PlatformKeys.AzureAppService.SiteNameKey, siteName), + (PlatformKeys.AzureAppService.ResourceGroupKey, resourceGroup), + (PlatformKeys.AzureAppService.WebsiteOwnerNameKey, subscriptionId)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); @@ -85,7 +85,7 @@ public void ResourceId(string subscriptionId, string siteName, string resourceGr [MemberData(nameof(StringTestCases), "unknown", Strings.AllowEmpty)] public void InstanceId(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.InstanceIdKey, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.InstanceIdKey, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.InstanceId.Should().Be(expected); @@ -95,7 +95,7 @@ public void InstanceId(string value, string expected) [MemberData(nameof(StringTestCases), "unknown", Strings.AllowEmpty)] public void InstanceName(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.InstanceNameKey, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.InstanceNameKey, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.InstanceName.Should().Be(expected); @@ -105,7 +105,7 @@ public void InstanceName(string value, string expected) [MemberData(nameof(StringTestCases), "unknown", Strings.AllowEmpty)] public void OperatingSystem(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.OperatingSystemKey, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.OperatingSystemKey, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.OperatingSystem.Should().Be(expected); @@ -125,7 +125,7 @@ public void SiteExtensionVersion(string value, string expected) [MemberData(nameof(StringTestCases))] public void FunctionsWorkerRuntime(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.FunctionsWorkerRuntime.Should().Be(expected); @@ -135,7 +135,7 @@ public void FunctionsWorkerRuntime(string value, string expected) [MemberData(nameof(StringTestCases))] public void FunctionsExtensionVersion(string value, string expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureFunctions.FunctionsExtensionVersion, value)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.FunctionsExtensionVersion.Should().Be(expected); @@ -150,8 +150,8 @@ public void FunctionsExtensionVersion(string value, string expected) public void IsFunctionsApp(string functionsWorkerRuntime, string functionsExtensionVersion, bool expected) { var source = CreateConfigurationSource( - (ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, functionsWorkerRuntime), - (ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion, functionsExtensionVersion)); + (PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, functionsWorkerRuntime), + (PlatformKeys.AzureFunctions.FunctionsExtensionVersion, functionsExtensionVersion)); var settings = new ImmutableAzureAppServiceSettings(source, NullConfigurationTelemetry.Instance); settings.IsFunctionsApp.Should().Be(expected); diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableGCPFunctionSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableGCPFunctionSettingsTests.cs index 7ae5fe57d955..211892618c4f 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableGCPFunctionSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/ImmutableGCPFunctionSettingsTests.cs @@ -19,8 +19,8 @@ public class ImmutableGCPFunctionSettingsTests : SettingsTestsBase public void GetIsGCPFunctionTrueWhenDeprecatedFunctionsEnvVarsExist() { var source = CreateConfigurationSource( - (ConfigurationKeys.GCPFunction.DeprecatedFunctionNameKey, "value"), - (ConfigurationKeys.GCPFunction.DeprecatedProjectKey, "value")); + (PlatformKeys.GCPFunction.DeprecatedFunctionNameKey, "value"), + (PlatformKeys.GCPFunction.DeprecatedProjectKey, "value")); var settings = new ImmutableGCPFunctionSettings(source, NullConfigurationTelemetry.Instance); settings.IsDeprecatedFunction.Should().BeTrue(); @@ -32,8 +32,8 @@ public void GetIsGCPFunctionTrueWhenDeprecatedFunctionsEnvVarsExist() public void GetIsGCPFunctionTrueWhenNonDeprecatedFunctionsEnvVarsExist() { var source = CreateConfigurationSource( - (ConfigurationKeys.GCPFunction.FunctionNameKey, "value"), - (ConfigurationKeys.GCPFunction.FunctionTargetKey, "value")); + (PlatformKeys.GCPFunction.FunctionNameKey, "value"), + (PlatformKeys.GCPFunction.FunctionTargetKey, "value")); var settings = new ImmutableGCPFunctionSettings(source, NullConfigurationTelemetry.Instance); settings.IsNewerFunction.Should().BeTrue(); diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/IntegrationSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/IntegrationSettingsTests.cs index 8de1a822fde2..79074ab882d7 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/IntegrationSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/IntegrationSettingsTests.cs @@ -90,7 +90,7 @@ public void SettingsRespectsOverride(bool initiallyEnabled) var name = nameof(IntegrationId.Kafka); var source = new NameValueConfigurationSource(new() { - { string.Format(ConfigurationKeys.Integrations.Enabled, name), initiallyEnabled.ToString() }, + { string.Format(IntegrationSettings.IntegrationEnabled, name), initiallyEnabled.ToString() }, }); var settings = new IntegrationSettings(name, source: source, isExplicitlyDisabled: true); @@ -105,7 +105,7 @@ public void SettingsRespectsOriginalIfNotOverridden(bool initiallyEnabled) var name = nameof(IntegrationId.Kafka); var source = new NameValueConfigurationSource(new() { - { string.Format(ConfigurationKeys.Integrations.Enabled, name), initiallyEnabled.ToString() }, + { string.Format(IntegrationSettings.IntegrationEnabled, name), initiallyEnabled.ToString() }, }); var settings = new IntegrationSettings(name, source: source, isExplicitlyDisabled: false); diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/MutableSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/MutableSettingsTests.cs index ee790ebcf550..064f7fae571c 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/MutableSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/MutableSettingsTests.cs @@ -518,7 +518,7 @@ public void KafkaCreateConsumerScopeEnabled(string value, bool expected) [Fact] public void DisableTracerIfNoApiKeyInAas() { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.SiteNameKey, "site-name")); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.SiteNameKey, "site-name")); var settings = new TracerSettings(source); var mutable = GetMutableSettings(source, settings); diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsServerlessTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsServerlessTests.cs index baea1348429b..3b37c7d814ec 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsServerlessTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsServerlessTests.cs @@ -62,7 +62,7 @@ public void HttpClientExcludedUrlSubstrings_AzureAppServices(string value, bool if (isRunningInAppService) { - configPairs.Add((ConfigurationKeys.AzureAppService.SiteNameKey, "site-name")); + configPairs.Add((PlatformKeys.AzureAppService.SiteNameKey, "site-name")); } var settings = new TracerSettings(CreateConfigurationSource(configPairs.ToArray())); diff --git a/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs index 0967c89fc92d..516661df57df 100644 --- a/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Configuration/TracerSettingsTests.cs @@ -582,7 +582,7 @@ public void IsRareSamplerEnabled(string value, bool expected) [InlineData(null, false)] public void IsRunningInAzureAppService(string value, bool expected) { - var source = CreateConfigurationSource((ConfigurationKeys.AzureAppService.SiteNameKey, value)); + var source = CreateConfigurationSource((PlatformKeys.AzureAppService.SiteNameKey, value)); var settings = new TracerSettings(source); settings.IsRunningInAzureAppService.Should().Be(expected); @@ -595,9 +595,9 @@ public void IsRunningInAzureAppService(string value, bool expected) public void IsRunningInAzureFunctions(string value, bool expected) { var source = CreateConfigurationSource( - (ConfigurationKeys.AzureAppService.SiteNameKey, value), - (ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, value), - (ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion, value)); + (PlatformKeys.AzureAppService.SiteNameKey, value), + (PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, value), + (PlatformKeys.AzureFunctions.FunctionsExtensionVersion, value)); var settings = new TracerSettings(source); @@ -667,7 +667,7 @@ public void IsRemoteConfigurationAvailable_AzureAppService(bool? overrideValue, if (isRunningInAas) { - configPairs.Add((ConfigurationKeys.AzureAppService.SiteNameKey, "site-name")); + configPairs.Add((PlatformKeys.AzureAppService.SiteNameKey, "site-name")); } var settings = new TracerSettings(CreateConfigurationSource(configPairs.ToArray())); diff --git a/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerAvailabilityHelperTests.cs b/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerAvailabilityHelperTests.cs index 8eef3203fa29..3360a3e2c358 100644 --- a/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerAvailabilityHelperTests.cs +++ b/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerAvailabilityHelperTests.cs @@ -17,9 +17,9 @@ namespace Datadog.Trace.Tests.ContinuousProfiler; [EnvironmentRestorer( "DD_INTERNAL_PROFILING_NATIVE_ENGINE_PATH", LambdaMetadata.FunctionNameEnvVar, - ConfigurationKeys.AzureAppService.SiteNameKey, - ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, - ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion, + PlatformKeys.AzureAppService.SiteNameKey, + PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, + PlatformKeys.AzureFunctions.FunctionsExtensionVersion, ConfigurationKeys.AzureAppService.AzureAppServicesContextKey)] public class ProfilerAvailabilityHelperTests { @@ -80,9 +80,9 @@ public void IsContinuousProfilerAvailable_InLambda_IgnoresAttachment_ReturnsFals public void IsContinuousProfilerAvailable_InAzureFunctions_IgnoresAttachment_ReturnsFalse() { SkipUnsupported(); - Environment.SetEnvironmentVariable(ConfigurationKeys.AzureAppService.SiteNameKey, "MyApp"); - Environment.SetEnvironmentVariable(ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, "dotnet"); - Environment.SetEnvironmentVariable(ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion, "v6.0"); + Environment.SetEnvironmentVariable(PlatformKeys.AzureAppService.SiteNameKey, "MyApp"); + Environment.SetEnvironmentVariable(PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, "dotnet"); + Environment.SetEnvironmentVariable(PlatformKeys.AzureFunctions.FunctionsExtensionVersion, "v6.0"); ProfilerAvailabilityHelper.IsContinuousProfilerAvailable_TestingOnly(ClrProfilerIsAttached).Should().BeFalse(); } diff --git a/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerSettingsTests.cs b/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerSettingsTests.cs index 3918de37d709..008d866f9d82 100644 --- a/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerSettingsTests.cs +++ b/tracer/test/Datadog.Trace.Tests/ContinuousProfiler/ProfilerSettingsTests.cs @@ -50,12 +50,12 @@ public void ProfilerState_WhenPassedViaEnvironment(string profilingValue, string var values = new List<(string, string)>(); if (profilingValue is not null) { - values.Add((Datadog.Trace.ContinuousProfiler.ConfigurationKeys.ProfilingEnabled, profilingValue)); + values.Add((Datadog.Trace.Configuration.ConfigurationKeys.Profiler.ProfilingEnabled, profilingValue)); } if (ssiValue is not null) { - values.Add((Datadog.Trace.ContinuousProfiler.ConfigurationKeys.SsiDeployed, ssiValue)); + values.Add((Datadog.Trace.Configuration.ConfigurationKeys.Profiler.SsiDeployed, ssiValue)); } var source = CreateConfigurationSource(values.ToArray()); @@ -78,13 +78,13 @@ public void ProfilerState_WhenManagedActivationIsMissingOrOnByDefault_DontReadFr var envValues = new List<(string, string)>(); if (envProfilingEnabled is not null) { - envValues.Add((Datadog.Trace.ContinuousProfiler.ConfigurationKeys.ProfilingEnabled, envProfilingEnabled)); + envValues.Add((Datadog.Trace.Configuration.ConfigurationKeys.Profiler.ProfilingEnabled, envProfilingEnabled)); } var otherValues = new List<(string, string)>(); if (configProfilingEnabled is not null) { - otherValues.Add((Datadog.Trace.ContinuousProfiler.ConfigurationKeys.ProfilingEnabled, configProfilingEnabled)); + otherValues.Add((Datadog.Trace.Configuration.ConfigurationKeys.Profiler.ProfilingEnabled, configProfilingEnabled)); } var envConfig = CreateConfigurationSource(envValues.ToArray()); @@ -109,18 +109,18 @@ public void ProfilerState_WhenManagedActivationIsDisabled_OnlyReadsFromEnvVars(s { var envValues = new List<(string, string)> { - (Datadog.Trace.ContinuousProfiler.ConfigurationKeys.ProfilerManagedActivationEnabled, "0") + (Datadog.Trace.Configuration.ConfigurationKeys.Profiler.ProfilerManagedActivationEnabled, "0") }; if (envProfilingEnabled is not null) { - envValues.Add((Datadog.Trace.ContinuousProfiler.ConfigurationKeys.ProfilingEnabled, envProfilingEnabled)); + envValues.Add((Datadog.Trace.Configuration.ConfigurationKeys.Profiler.ProfilingEnabled, envProfilingEnabled)); } var otherValues = new List<(string, string)>(); if (configProfilingEnabled is not null) { - otherValues.Add((Datadog.Trace.ContinuousProfiler.ConfigurationKeys.ProfilingEnabled, configProfilingEnabled)); + otherValues.Add((Datadog.Trace.Configuration.ConfigurationKeys.Profiler.ProfilingEnabled, configProfilingEnabled)); } var envConfig = CreateConfigurationSource(envValues.ToArray()); diff --git a/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/ManualInstrumentationLegacyConfigurationSourceTests.cs b/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/ManualInstrumentationLegacyConfigurationSourceTests.cs index 0e714ca59648..1dec3714089e 100644 --- a/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/ManualInstrumentationLegacyConfigurationSourceTests.cs +++ b/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/ManualInstrumentationLegacyConfigurationSourceTests.cs @@ -31,7 +31,7 @@ public void GetIntegrationEnabled_SupportedValues_ReturnsExpectedValues(int id) { var integrationId = (IntegrationId)id; var name = IntegrationRegistry.GetName(integrationId).ToUpperInvariant(); - var enabledKey = string.Format(ConfigurationKeys.Integrations.Enabled, name); + var enabledKey = string.Format(IntegrationSettings.IntegrationEnabled, name); var actual = ManualInstrumentationLegacyConfigurationSource.GetIntegrationEnabled(enabledKey); @@ -44,7 +44,7 @@ public void GetIntegrationAnalyticsEnabled_SupportedValues_ReturnsExpectedValues { var integrationId = (IntegrationId)id; var name = IntegrationRegistry.GetName(integrationId).ToUpperInvariant(); - var enabledKey = string.Format(ConfigurationKeys.Integrations.AnalyticsEnabled, name); + var enabledKey = string.Format(IntegrationSettings.AnalyticsEnabledKey, name); var actual = ManualInstrumentationLegacyConfigurationSource.GetIntegrationAnalyticsEnabled(enabledKey); @@ -57,7 +57,7 @@ public void GetIntegrationEnabled_ForUnsupportedValues_ReturnsNull(int id) { var integrationId = (IntegrationId)id; var name = IntegrationRegistry.GetName(integrationId).ToUpperInvariant(); - var enabledKey = string.Format(ConfigurationKeys.Integrations.Enabled, name); + var enabledKey = string.Format(IntegrationSettings.IntegrationEnabled, name); var actual = ManualInstrumentationLegacyConfigurationSource.GetIntegrationEnabled(enabledKey); @@ -70,7 +70,7 @@ public void GetIntegrationAnalyticsEnabled_ForUnsupportedValues_ReturnsNull(int { var integrationId = (IntegrationId)id; var name = IntegrationRegistry.GetName(integrationId).ToUpperInvariant(); - var enabledKey = string.Format(ConfigurationKeys.Integrations.AnalyticsEnabled, name); + var enabledKey = string.Format(IntegrationSettings.AnalyticsEnabledKey, name); var actual = ManualInstrumentationLegacyConfigurationSource.GetIntegrationAnalyticsEnabled(enabledKey); @@ -83,7 +83,7 @@ public void GetIntegrationAnalyticsSampleRate_ForUnsupportedValues_ReturnsNull(i { var integrationId = (IntegrationId)id; var name = IntegrationRegistry.GetName(integrationId).ToUpperInvariant(); - var enabledKey = string.Format(ConfigurationKeys.Integrations.AnalyticsSampleRate, name); + var enabledKey = string.Format(IntegrationSettings.AnalyticsSampleRateKey, name); var actual = ManualInstrumentationLegacyConfigurationSource.GetIntegrationAnalyticsSampleRate(enabledKey); diff --git a/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/SettingsInstrumentationTests.cs b/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/SettingsInstrumentationTests.cs index c445c4793216..45afb8baad92 100644 --- a/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/SettingsInstrumentationTests.cs +++ b/tracer/test/Datadog.Trace.Tests/ManualInstrumentation/SettingsInstrumentationTests.cs @@ -341,9 +341,9 @@ private static TracerSettings GetAndAssertAutomaticTracerSettings() { ConfigurationKeys.TraceEnabled, false }, { ConfigurationKeys.TracerMetricsEnabled, true }, { ConfigurationKeys.AgentUri, "http://localhost:1234" }, - { string.Format(ConfigurationKeys.Integrations.Enabled, nameof(IntegrationId.Aerospike)), "false" }, - { string.Format(ConfigurationKeys.Integrations.AnalyticsEnabled, nameof(IntegrationId.Grpc)), "true" }, - { string.Format(ConfigurationKeys.Integrations.AnalyticsSampleRate, nameof(IntegrationId.Couchbase)), 0.5 }, + { string.Format(IntegrationSettings.IntegrationEnabled, nameof(IntegrationId.Aerospike)), "false" }, + { string.Format(IntegrationSettings.AnalyticsEnabledKey, nameof(IntegrationId.Grpc)), "true" }, + { string.Format(IntegrationSettings.AnalyticsSampleRateKey, nameof(IntegrationId.Couchbase)), 0.5 }, }); // verify that all the settings are as expected diff --git a/tracer/test/Datadog.Trace.Tests/Telemetry/Collectors/ConfigurationTelemetryCollectorTests.cs b/tracer/test/Datadog.Trace.Tests/Telemetry/Collectors/ConfigurationTelemetryCollectorTests.cs index d9f93d1cae77..c44b10587063 100644 --- a/tracer/test/Datadog.Trace.Tests/Telemetry/Collectors/ConfigurationTelemetryCollectorTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Telemetry/Collectors/ConfigurationTelemetryCollectorTests.cs @@ -133,9 +133,9 @@ public void ConfigurationDataShouldIncludeAzureValues(bool isSafeToTrace) var config = new NameValueCollection { { ConfigurationKeys.AzureAppService.SiteExtensionVersionKey, "1.5.0" }, - { ConfigurationKeys.AzureAppService.SiteNameKey, "site-name" }, - { ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion, "~4" }, - { ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime, "dotnet-isolated" }, + { PlatformKeys.AzureAppService.SiteNameKey, "site-name" }, + { PlatformKeys.AzureFunctions.FunctionsExtensionVersion, "~4" }, + { PlatformKeys.AzureFunctions.FunctionsWorkerRuntime, "dotnet-isolated" }, { ConfigurationKeys.ServiceName, serviceName }, { ConfigurationKeys.Environment, env }, { ConfigurationKeys.ServiceVersion, serviceVersion }, @@ -152,9 +152,9 @@ public void ConfigurationDataShouldIncludeAzureValues(bool isSafeToTrace) using var scope = new AssertionScope(); GetLatestValueFromConfig(data, ConfigurationKeys.AzureAppService.SiteExtensionVersionKey).Should().Be("1.5.0"); - GetLatestValueFromConfig(data, ConfigurationKeys.AzureAppService.SiteNameKey).Should().Be("site-name"); - GetLatestValueFromConfig(data, ConfigurationKeys.AzureFunctions.FunctionsExtensionVersion).Should().Be("~4"); - GetLatestValueFromConfig(data, ConfigurationKeys.AzureFunctions.FunctionsWorkerRuntime).Should().Be("dotnet-isolated"); + GetLatestValueFromConfig(data, PlatformKeys.AzureAppService.SiteNameKey).Should().Be("site-name"); + GetLatestValueFromConfig(data, PlatformKeys.AzureFunctions.FunctionsExtensionVersion).Should().Be("~4"); + GetLatestValueFromConfig(data, PlatformKeys.AzureFunctions.FunctionsWorkerRuntime).Should().Be("dotnet-isolated"); GetLatestValueFromConfig(data, ConfigTelemetryData.AasConfigurationError).Should().BeOfType().Subject.Should().Be(!isSafeToTrace); GetLatestValueFromConfig(data, ConfigTelemetryData.CloudHosting).Should().Be("Azure"); GetLatestValueFromConfig(data, ConfigTelemetryData.AasAppType).Should().Be("function");