Skip to content

Commit

Permalink
Read recording key in AbstractConfigurationWithEnvFallbackReader (#1252)
Browse files Browse the repository at this point in the history
This commit fixes a bug whereby the Recording configuration value was reading
from the wrong configuration/environment key.

Fixes #1250
  • Loading branch information
russcam authored Apr 7, 2021
1 parent 63df486 commit 9c1a355
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ internal AbstractConfigurationWithEnvFallbackReader(IApmLogger logger, string de
ParseMetricsInterval(Read(KeyNames.MetricsInterval, EnvVarNames.MetricsInterval));

public bool Recording =>
ParseEnabled(Read(KeyNames.Enabled, EnvVarNames.Enabled));
ParseRecording(Read(KeyNames.Recording, EnvVarNames.Recording));

public IReadOnlyList<WildcardMatcher> SanitizeFieldNames =>
ParseSanitizeFieldNames(Read(KeyNames.SanitizeFieldNames, EnvVarNames.SanitizeFieldNames));
Expand Down
13 changes: 13 additions & 0 deletions test/Elastic.Apm.Tests/ConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ public void RecordingTestWithInvalidValue()
agent.ConfigurationReader.Recording.Should().BeTrue();
}

[Theory]
[InlineData("true", true)]
[InlineData("false", false)]
[InlineData("True", true)]
[InlineData("False", false)]
[InlineData(" True ", true)]
[InlineData(" False ", false)]
public void RecordingTestWithValidValue(string value, bool expected)
{
using var agent = new ApmAgent(new TestAgentComponents(config: new MockConfigSnapshot(recording: value)));
agent.ConfigurationReader.Recording.Should().Be(expected);
}

/// <summary>
/// Makes sure that in case Enabled is set to invalid value, the agent uses true as default value
/// </summary>
Expand Down

0 comments on commit 9c1a355

Please sign in to comment.