Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
private const string ResourceAttributesVarName = "OTEL_RESOURCE_ATTRIBUTES";
private const string JwtPrefix = "eyJ";

private static readonly char[] ResourceAttributeKeyValueSeparator = ['='];

/// <summary>
/// Variables whose values are safe to persist verbatim.
/// </summary>
Expand Down Expand Up @@ -287,47 +285,66 @@
/// <returns>The value with unrecognised keys' values replaced.</returns>
private static string RedactResourceAttributes(string value)
{
var pairs = value.Split(',');
var builder = StringBuilderCache.Acquire(value.Length);
var remaining = value.AsSpan();
var index = 0;
var first = true;

for (var i = 0; i < pairs.Length; i++)
while (true)
{
if (i > 0)
var separator = remaining.IndexOf(',');
var pair = separator < 0 ? remaining : remaining[..separator];

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 296 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

if (!first)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this block adds the comma without checking whether the pair could be empty or malformed and would end up with a comma without its content.

Input                             Output
service.name=checkout,broken       service.name=checkout,[REDACTED]
service.name=checkout,             service.name=checkout,
service.name=checkout,,            service.name=checkout,,

Although this is the same behavior as before the change and not in scope of this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
builder.Append(',');
}

AppendResourceAttribute(builder, pairs[i]);
AppendResourceAttribute(builder, value, index, pair);

if (separator < 0)
{
break;
}

index += separator + 1;
remaining = remaining[(separator + 1)..];

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 311 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported
first = false;
}

return StringBuilderCache.GetStringAndRelease(builder);
}

private static void AppendResourceAttribute(StringBuilder builder, string pair)
private static void AppendResourceAttribute(StringBuilder builder, string value, int index, ReadOnlySpan<char> pair)
{
if (pair.Length == 0)
if (pair.IsEmpty)
{
return;
}

var parts = pair.Split(ResourceAttributeKeyValueSeparator, 2);
if (parts.Length != 2)
var equals = pair.IndexOf('=');
if (equals < 0)
{
// No key to classify against, so nothing can be shown safely.
builder.Append(RedactedValue);
return;
}

builder.Append(parts[0]).Append('=');
builder.Append(value, index, equals).Append('=');
builder.Append(
IsSafeResourceAttributeKey(parts[0].Trim())
? parts[1]
IsSafeResourceAttributeKey(pair[..equals].Trim())

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Api.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net10.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (stable)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / validate-packages / Validate packages (experimental)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / concurrency-tests / run-concurrency-tests (windows-2025, net11.0, OpenTelemetry.Tests)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (ubuntu-26.04-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (ubuntu-26.04)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-11-arm)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-stable / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Index' is not defined or imported

Check failure on line 335 in src/OpenTelemetry/Internal/Diagnostics/SelfDiagnosticsEnvironmentVariablePolicy.cs

View workflow job for this annotation

GitHub Actions / build-test-project-experimental / build-test (windows-2025)

Predefined type 'System.Range' is not defined or imported
? value.AsSpan(index + equals + 1, pair.Length - equals - 1)
: RedactedValue);
}

private static bool IsSafeResourceAttributeKey(string key)
private static bool IsSafeResourceAttributeKey(ReadOnlySpan<char> key)
{
if (SafeResourceAttributeKeys.Contains(key))
#if NET
var alternateLookup = SafeResourceAttributeKeys.GetAlternateLookup<ReadOnlySpan<char>>();
if (alternateLookup.Contains(key))
#else
if (SafeResourceAttributeKeys.Contains(key.ToString()))
#endif
{
return true;
}
Expand Down
Loading