Skip to content

Enable runtime metrics by default #7307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tracer/src/Datadog.Trace/Configuration/TracerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,11 @@ _ when x.ToBoolean() is { } boolean => boolean,
value => string.Equals(value, "none", StringComparison.OrdinalIgnoreCase)
? ParsingResult<bool>.Success(result: false)
: ParsingResult<bool>.Failure());

_runtimeMetricsEnabled = config
.WithKeys(ConfigurationKeys.RuntimeMetricsEnabled)
.AsBoolResult()
.OverrideWith(in otelRuntimeMetricsEnabled, ErrorLog, defaultValue: false);
.OverrideWith(in otelRuntimeMetricsEnabled, ErrorLog, defaultValue: EnvironmentHelpers.ShouldActivateRuntimeMetrics(isRunningInCiVisibility));

DataPipelineEnabled = config
.WithKeys(ConfigurationKeys.TraceDataPipelineEnabled)
Expand Down
5 changes: 5 additions & 0 deletions tracer/src/Datadog.Trace/FrameworkDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public static bool IsNet5()
return Environment.Version.Major >= 5;
}

public static bool IsLowerThanNet9()
{
return Environment.Version.Major < 9;
}

public bool IsWindows()
{
return string.Equals(OSPlatform, OSPlatformName.Windows, StringComparison.OrdinalIgnoreCase);
Expand Down
18 changes: 18 additions & 0 deletions tracer/src/Datadog.Trace/Util/EnvironmentHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,24 @@ public static bool IsGoogleCloudFunctions()
EnvironmentVariableExists(ConfigurationKeys.GCPFunction.DeprecatedProjectKey));
}

/// <summary>
/// Activate runtime metrics only on >= net9 or NetFx
/// </summary>
/// <param name="isRunningInCiVisibility">isRunningInCiVisibility</param>
/// <returns>whether to activate it or not</returns>
public static bool ShouldActivateRuntimeMetrics(bool isRunningInCiVisibility)
{
// only activate runtime metrics by default from net9 or netframework
var shouldActivateRuntimeMetrics = !isRunningInCiVisibility;
#if !NETFRAMEWORK
if (shouldActivateRuntimeMetrics && FrameworkDescription.IsLowerThanNet9())
{
shouldActivateRuntimeMetrics = false;
}
#endif
return shouldActivateRuntimeMetrics;
}

/// <summary>
/// Checks if the specified environment variable exists in the current environment.
/// </summary>
Expand Down
Loading