Skip to content

Fix OTEL_EXPORTER_OTLP_*_PROTOCOL handling#4601

Closed
RassK wants to merge 5 commits into
open-telemetry:mainfrom
RassK:fix-otlp-priority-env
Closed

Fix OTEL_EXPORTER_OTLP_*_PROTOCOL handling#4601
RassK wants to merge 5 commits into
open-telemetry:mainfrom
RassK:fix-otlp-priority-env

Conversation

@RassK
Copy link
Copy Markdown
Contributor

@RassK RassK commented Nov 13, 2025

Why

Fixes #4593
Follow up #3527

What

GetExporterOtlpProtocol ignores the more specific (priority) environment variable and does not pass the value to SDK.

Tests

  • Added tests to verify that all priority envs are picked up to manually pass to SDK.

Checklist

  • CHANGELOG.md is updated.
  • Documentation is updated.
  • New features are covered by tests.

@RassK RassK requested a review from a team as a code owner November 13, 2025 14:45
@RassK RassK changed the title Fix GetExporterOtlpProtocol not to ignore OTEL_EXPORTER_OTLP_*_PROTOCOL Fix OTEL_EXPORTER_OTLP_*_PROTOCOL handling Nov 13, 2025
var endpoint = "http://example.org/traces/v1";
var endpointValue = new Uri(endpoint);
var protocol = "http/protobuf";
var protocolValue = OtlpExportProtocol.HttpProtobuf;
Copy link
Copy Markdown
Contributor

@xiang17 xiang17 Nov 14, 2025

Choose a reason for hiding this comment

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

What about other values like "grpc", "invalidProtocol" or "" (empty string)?

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.

*Applies to the line above.

{
switch (exporterOtlpProtocol)
{
case "grpc":
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.

Do we support mixed case like "gRPC"?

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.

At the moment, I think we should keep it as it is (case sensitive), since all our enum values are currently case sensitive. However, in the latest release of the specification, this behavior was changed, and we should start making all enum values as case insensitive.

It should be a separate issue.

open-telemetry/opentelemetry-specification#4576

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.

Makes sense. Thanks for the reference!

var exporterOtlpProtocol = configuration.GetString(priorityVar);

// SDK handles only general environment variables.
// In case priority env is set, the value must be maually passed.
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.

Suggested change
// In case priority env is set, the value must be maually passed.
// In case priority env is set, the value must be manually passed.

}
}

exporterOtlpProtocol = configuration.GetString(OtlpSpecConfigDefinitions.DefaultProtocolEnvVarName);
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.

The logic above should also be applied to this? (DefaultProtocolEnvVarName is OTEL_EXPORTER_OTLP_PROTOCOL.)

Comment on lines +177 to +180
{
// null value here means that it will be handled by OTEL .NET SDK
return null;
}
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.

I think we can stop relying on the Otel .NET SDK to handle this and manage the protocol ourselves instead. That way, there will be less confusion about when it’s handled by us and when it’s handled by the SDK.

@Kielek
Copy link
Copy Markdown
Member

Kielek commented Nov 24, 2025

Changes included in #4627

@Kielek Kielek closed this Nov 24, 2025
@RassK RassK deleted the fix-otlp-priority-env branch December 5, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot set to http/protobuf with OTEL_EXPORTER_OTLP_METRICS_PROTOCOL

4 participants