Skip to content

Commit

Permalink
OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG are handled by SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Apr 5, 2024
1 parent 957b85a commit 5f672e4
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,6 @@ public static class Traces
/// </summary>
public const string AdditionalLegacySources = "OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_LEGACY_SOURCES";

/// <summary>
/// Configuration key for sampler to be used for traces.
/// </summary>
public const string TracesSampler = "OTEL_TRACES_SAMPLER";

/// <summary>
/// Configuration key for string value to be used as the sampler argument.
/// </summary>
public const string TracesSamplerArguments = "OTEL_TRACES_SAMPLER_ARG";

/// <summary>
/// Configuration keys for instrumentation options.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public static TracerProviderBuilder UseEnvironmentVariables(
}

builder
.SetSampler(settings)
// Exporters can cause dependency loads.
// Should be called later if dependency listeners are already setup.
.SetExporter(settings, pluginManager)
Expand Down Expand Up @@ -89,23 +88,6 @@ private static TracerProviderBuilder AddWcfIfNeeded(
return tracerProviderBuilder;
}

private static TracerProviderBuilder SetSampler(this TracerProviderBuilder builder, TracerSettings settings)
{
if (settings.TracesSampler == null)
{
return builder;
}

var sampler = TracerSamplerHelper.GetSampler(settings.TracesSampler, settings.TracesSamplerArguments);

if (sampler == null)
{
return builder;
}

return builder.SetSampler(sampler);
}

private static TracerProviderBuilder SetExporter(this TracerProviderBuilder builder, TracerSettings settings, PluginManager pluginManager)
{
if (settings.ConsoleExporterEnabled)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ internal class TracerSettings : Settings
/// </summary>
public InstrumentationOptions InstrumentationOptions { get; private set; } = new(new Configuration(failFast: false));

/// <summary>
/// Gets sampler to be used for traces.
/// </summary>
public string? TracesSampler { get; private set; }

/// <summary>
/// Gets a value to be used as the sampler argument.
/// </summary>
public string? TracesSamplerArguments { get; private set; }

protected override void OnLoad(Configuration configuration)
{
TracesExporter = ParseTracesExporter(configuration);
Expand Down Expand Up @@ -97,9 +87,6 @@ protected override void OnLoad(Configuration configuration)
OpenTracingEnabled = configuration.GetBool(ConfigurationKeys.Traces.OpenTracingEnabled) ?? false;

InstrumentationOptions = new InstrumentationOptions(configuration);

TracesSampler = configuration.GetString(ConfigurationKeys.Traces.TracesSampler);
TracesSamplerArguments = configuration.GetString(ConfigurationKeys.Traces.TracesSamplerArguments);
}

private static TracesExporter ParseTracesExporter(Configuration configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ internal void TracerSettings_DefaultValues()
settings.EnabledInstrumentations.Should().NotBeEmpty();
settings.ActivitySources.Should().BeEquivalentTo(new List<string> { "OpenTelemetry.AutoInstrumentation.*" });
settings.AdditionalLegacySources.Should().BeEmpty();
settings.TracesSampler.Should().BeNull();
settings.TracesSamplerArguments.Should().BeNull();

// Instrumentation options tests
settings.InstrumentationOptions.GraphQLSetDocument.Should().BeFalse();
Expand Down Expand Up @@ -252,21 +250,6 @@ internal void TracerSettings_Instrumentations_SupportedValues(string tracerInstr
settings.EnabledInstrumentations.Should().BeEquivalentTo(new List<TracerInstrumentation> { expectedTracerInstrumentation });
}

[Fact]
internal void TracerSettings_TracerSampler()
{
const string expectedTracesSampler = nameof(expectedTracesSampler);
const string expectedTracesSamplerArguments = nameof(expectedTracesSamplerArguments);

Environment.SetEnvironmentVariable(ConfigurationKeys.Traces.TracesSampler, expectedTracesSampler);
Environment.SetEnvironmentVariable(ConfigurationKeys.Traces.TracesSamplerArguments, expectedTracesSamplerArguments);

var settings = Settings.FromDefaultSources<TracerSettings>(false);

settings.TracesSampler.Should().Be(expectedTracesSampler);
settings.TracesSamplerArguments.Should().Be(expectedTracesSamplerArguments);
}

[Theory]
#if NETFRAMEWORK
[InlineData("ASPNET", MetricInstrumentation.AspNet)]
Expand Down Expand Up @@ -384,8 +367,6 @@ private static void ClearEnvVars()
}

Environment.SetEnvironmentVariable(ConfigurationKeys.Traces.Exporter, null);
Environment.SetEnvironmentVariable(ConfigurationKeys.Traces.TracesSampler, null);
Environment.SetEnvironmentVariable(ConfigurationKeys.Traces.TracesSamplerArguments, null);
Environment.SetEnvironmentVariable(ConfigurationKeys.Traces.InstrumentationOptions.GraphQLSetDocument, null);
Environment.SetEnvironmentVariable(ConfigurationKeys.ExporterOtlpProtocol, null);
Environment.SetEnvironmentVariable(ConfigurationKeys.FlushOnUnhandledException, null);
Expand Down

This file was deleted.

0 comments on commit 5f672e4

Please sign in to comment.