From 37a18f491e45b69b3a2ea71e9b09afa173448d8d Mon Sep 17 00:00:00 2001 From: Andrew Lock Date: Fri, 31 May 2024 18:23:28 +0100 Subject: [PATCH] Record SSI injection values in configuration --- tracer/src/Datadog.Trace/Configuration/TracerSettings.cs | 5 +++++ .../src/Datadog.Trace/Telemetry/DTOs/ConfigTelemetryData.cs | 3 +++ .../test/Datadog.Trace.Tests/Telemetry/ConfigurationTests.cs | 4 +++- .../Datadog.Trace.Tests/Telemetry/config_norm_rules.json | 4 +++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs b/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs index 702be8a4095c..5e34f182d301 100644 --- a/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs +++ b/tracer/src/Datadog.Trace/Configuration/TracerSettings.cs @@ -22,6 +22,7 @@ using Datadog.Trace.SourceGenerators; using Datadog.Trace.Telemetry; using Datadog.Trace.Telemetry.Metrics; +using Datadog.Trace.Util; namespace Datadog.Trace.Configuration { @@ -418,6 +419,10 @@ internal TracerSettings(IConfigurationSource? source, IConfigurationTelemetry te telemetry.Record(ConfigTelemetryData.FullTrustAppDomain, value: AppDomain.CurrentDomain.IsFullyTrusted, ConfigurationOrigins.Default); telemetry.Record(ConfigTelemetryData.ManagedTracerTfm, value: ConfigTelemetryData.ManagedTracerTfmValue, recordValue: true, ConfigurationOrigins.Default); + // these are SSI variables that would be useful for correlation purposes + telemetry.Record(ConfigTelemetryData.SsiInjectionEnabled, value: EnvironmentHelpers.GetEnvironmentVariable("DD_INJECTION_ENABLED"), recordValue: true, ConfigurationOrigins.EnvVars); + telemetry.Record(ConfigTelemetryData.SsiAllowUnsupportedRuntimesEnabled, value: EnvironmentHelpers.GetEnvironmentVariable("DD_INJECT_FORCE"), recordValue: true, ConfigurationOrigins.EnvVars); + if (AzureAppServiceMetadata is not null) { telemetry.Record(ConfigTelemetryData.AasConfigurationError, AzureAppServiceMetadata.IsUnsafeToTrace, ConfigurationOrigins.Default); diff --git a/tracer/src/Datadog.Trace/Telemetry/DTOs/ConfigTelemetryData.cs b/tracer/src/Datadog.Trace/Telemetry/DTOs/ConfigTelemetryData.cs index 3e0050813cc2..b83ce8c20ee6 100644 --- a/tracer/src/Datadog.Trace/Telemetry/DTOs/ConfigTelemetryData.cs +++ b/tracer/src/Datadog.Trace/Telemetry/DTOs/ConfigTelemetryData.cs @@ -21,6 +21,9 @@ internal static class ConfigTelemetryData public const string ProfilerLoaded = "profiler_loaded"; public const string CodeHotspotsEnabled = "code_hotspots_enabled"; + public const string SsiInjectionEnabled = "ssi_injection_enabled"; + public const string SsiAllowUnsupportedRuntimesEnabled = "ssi_forced_injection_enabled"; + // We intentionally are using specific values here, not OR_GREATER_THAN #if NET6_0 public const string ManagedTracerTfmValue = "net6.0"; diff --git a/tracer/test/Datadog.Trace.Tests/Telemetry/ConfigurationTests.cs b/tracer/test/Datadog.Trace.Tests/Telemetry/ConfigurationTests.cs index bddf15a699cf..9f8d57e80e9e 100644 --- a/tracer/test/Datadog.Trace.Tests/Telemetry/ConfigurationTests.cs +++ b/tracer/test/Datadog.Trace.Tests/Telemetry/ConfigurationTests.cs @@ -49,7 +49,9 @@ public class ConfigurationTests "DD_DOTNET_TRACER_HOME", "DD_INSTRUMENTATION_INSTALL_ID", "DD_INSTRUMENTATION_INSTALL_TYPE", - "DD_INSTRUMENTATION_INSTALL_TIME" + "DD_INSTRUMENTATION_INSTALL_TIME", + "DD_INJECTION_ENABLED", + "DD_INJECT_FORCE", }; [Fact] diff --git a/tracer/test/Datadog.Trace.Tests/Telemetry/config_norm_rules.json b/tracer/test/Datadog.Trace.Tests/Telemetry/config_norm_rules.json index 0b9288e0118c..28d8fdf35815 100644 --- a/tracer/test/Datadog.Trace.Tests/Telemetry/config_norm_rules.json +++ b/tracer/test/Datadog.Trace.Tests/Telemetry/config_norm_rules.json @@ -565,5 +565,7 @@ "trace.sidecar_trace_sender": "trace_sidecar_trace_sender", "trace.sampling_rules_format": "trace_sampling_rules_format", "DD_TRACE_SAMPLING_RULES_FORMAT": "trace_sampling_rules_format", - "trace.agentless": "trace_agentless" + "trace.agentless": "trace_agentless", + "ssi_injection_enabled": "ssi_injection_enabled", + "ssi_forced_injection_enabled": "ssi_forced_injection_enabled" } \ No newline at end of file