Skip to content
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

Disable optional rules by default on the NuGet package scripts #2958

Merged
merged 8 commits into from
Sep 15, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set DOTNET_STARTUP_HOOKS=%BASE_PATH%OpenTelemetry.AutoInstrumentation.StartupHoo

:: Settings for OpenTelemetry
set OTEL_DOTNET_AUTO_HOME=%BASE_PATH%
set OTEL_DOTNET_AUTO_RULE_ENGINE_ENABLED=false

@echo on
%*
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export DOTNET_STARTUP_HOOKS=${BASE_PATH}/OpenTelemetry.AutoInstrumentation.Start

# Settings for OpenTelemetry
export OTEL_DOTNET_AUTO_HOME=${BASE_PATH}
export OTEL_DOTNET_AUTO_RULE_ENGINE_ENABLED=false

$@
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,16 @@ internal class RuleEngine
new MinSupportedFrameworkRule()
};

private readonly List<Rule> _otherRules = new()
{
new OpenTelemetrySdkMinimumVersionRule(),
new DiagnosticSourceRule(),
new InstrumentationAssemblyRule(),
new NativeProfilerDiagnosticsRule()
};
private readonly List<Rule>? _optionalRules;

internal RuleEngine()
{
}

// This constructor is used for test purpose.
internal RuleEngine(List<Rule> rules)
internal RuleEngine(List<Rule> optionalRules)
{
_otherRules = rules;
_optionalRules = optionalRules;
}

internal bool ValidateRules()
Expand All @@ -65,8 +59,16 @@ internal bool ValidateRules()
return result;
}

var optionalRules = _optionalRules ?? new()
{
new OpenTelemetrySdkMinimumVersionRule(),
new DiagnosticSourceRule(),
new InstrumentationAssemblyRule(),
new NativeProfilerDiagnosticsRule()
pjanotti marked this conversation as resolved.
Show resolved Hide resolved
};

// All the rules are validated here.
foreach (var rule in _otherRules)
foreach (var rule in optionalRules)
{
if (!EvaluateRule(rule))
{
Expand Down
Loading