Skip to content

feat: implement an otlp http client - #2432

Open
thompson-tomo wants to merge 19 commits into
open-telemetry:mainfrom
thompson-tomo:http_common
Open

thompson-tomo wants to merge 19 commits into
open-telemetry:mainfrom
thompson-tomo:http_common

Conversation

@thompson-tomo

@thompson-tomo thompson-tomo commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Progresses #2170 (issue)

Changes

This introduces an otlp http client which all http exporters use hence centralising functionality on how the http client is created.

In the future (#2447) this client will offer a send bytes method which will provide immense code consolidation with the exporters becoming simple wrappers around the client.

Authorship

  • I, a human, wrote this pull request description myself.

@thompson-tomo
thompson-tomo marked this pull request as ready for review October 7, 2026 13:51
Comment on lines +47 to +56
if options.nil?
options = OpenTelemetry::Exporter::OTLP::HTTP::OtlpHttpExporterConfig.new(
tls: OpenTelemetry::Exporter::OTLP::HTTP::HttpTlsConfig.new(
ca_file: OpenTelemetry::Common::Utilities.config_opt("OTEL_EXPORTER_OTLP_#{service}_CERTIFICATE", 'OTEL_EXPORTER_OTLP_CERTIFICATE'),
cert_file: OpenTelemetry::Common::Utilities.config_opt("OTEL_EXPORTER_OTLP_#{service}_CLIENT_CERTIFICATE", 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE'),
key_file: OpenTelemetry::Common::Utilities.config_opt("OTEL_EXPORTER_OTLP_#{service}_CLIENT_KEY", 'OTEL_EXPORTER_OTLP_CLIENT_KEY')
),
ssl_verify_mode: ssl_verify_mode
)
@uri = OpenTelemetry::Exporter::OTLP::Common::Utilities.build_uri(nil, base_path, "OTEL_EXPORTER_OTLP_#{service}_ENDPOINT", 'OTEL_EXPORTER_OTLP_ENDPOINT', 'http://localhost:4318/')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug: if any options are passed, env variables are ignored. For example, with_env('OTEL_EXPORTER_OTLP_CERTIFICATE' => 'cert') { TraceExporter.new(endpoint: 'https://example.com') } loses certificate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually it was intended so that programatic configuration matches the behaviour of config file with a clear precedence and programatic configuration maps directly to the in-memory model. I also note The exporter is not yet stable.

def ssl_verify_mode
if ENV['OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER'] == 'true'
OpenSSL::SSL::VERIFY_PEER
elsif ENV['OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_NONE'] == 'true'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the == true behaviour was only in otlp-logs, whereas other gems used just checked for truthiness. This is a breaking change.

@thompson-tomo thompson-tomo Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Interesting it seems that none of the 4 current implementations match the feature definition in the readmes which states in the doc linked that the values are OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER. With OpenSSL::SSL::VERIFY_PEER being the default value.

And in fact as per https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#parsing-empty-value

The SDK MUST interpret an empty value of an environment variable the same way as when the variable is unset.

Hence old option is not compliant

@pitr

pitr commented Oct 15, 2026

Copy link
Copy Markdown

A separate otlp-http-common gem seems excessive. http_connection and ssl_verify_mode could just go into otlp-common.

@thompson-tomo

Copy link
Copy Markdown
Contributor Author

@pitr the reason for seperate is that this functionality only applicable to http especially given that it creates a http client which is not usable in either the grpc exporters & eventually file exporter.

Note this is only the first pr there a second pr which adds the send functionality to the http client in the client.

@thompson-tomo
thompson-tomo force-pushed the http_common branch 4 times, most recently from c4bccde to 3fe6e33 Compare November 12, 2026 03:27

This branch has not been deployed

No deployments
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.

2 participants