Skip to content

feat(otlp-http): improve endpoint handling, add User-Agent header, an…#2074

Open
arjun-rajappa wants to merge 2 commits into
open-telemetry:mainfrom
arjun-rajappa:add-tests-otlp-http
Open

feat(otlp-http): improve endpoint handling, add User-Agent header, an…#2074
arjun-rajappa wants to merge 2 commits into
open-telemetry:mainfrom
arjun-rajappa:add-tests-otlp-http

Conversation

@arjun-rajappa
Copy link
Copy Markdown
Contributor

Fixes #1667

  • Add spec-compliant default User-Agent header with exporter version and Ruby runtime info
  • Fix endpoint path construction to properly handle OTEL_EXPORTER_OTLP_ENDPOINT with/without trailing slashes
  • Implement proper endpoint precedence: explicit endpoint > OTEL_EXPORTER_OTLP_TRACES_ENDPOINT > OTEL_EXPORTER_OTLP_ENDPOINT
  • Add metrics for compressed and uncompressed message sizes
  • Add specific error handling and logging for 404 responses
  • Refactor endpoint and header preparation into dedicated methods
  • Prevent header mutation by duplicating Hash parameters
  • Add comprehensive test coverage for endpoint path handling and User-Agent header

…d enhance metrics

- Add spec-compliant default User-Agent header with exporter version and Ruby runtime info
- Fix endpoint path construction to properly handle OTEL_EXPORTER_OTLP_ENDPOINT with/without trailing slashes
- Implement proper endpoint precedence: explicit endpoint > OTEL_EXPORTER_OTLP_TRACES_ENDPOINT > OTEL_EXPORTER_OTLP_ENDPOINT
- Add metrics for compressed and uncompressed message sizes
- Add specific error handling and logging for 404 responses
- Refactor endpoint and header preparation into dedicated methods
- Prevent header mutation by duplicating Hash parameters
- Add comprehensive test coverage for endpoint path handling and User-Agent header

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
Comment thread exporter/otlp-http/lib/opentelemetry/exporter/otlp/http/trace_exporter.rb Outdated
compression: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_COMPRESSION', 'OTEL_EXPORTER_OTLP_COMPRESSION', default: 'gzip'),
timeout: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_TIMEOUT', 'OTEL_EXPORTER_OTLP_TIMEOUT', default: 10),
metrics_reporter: nil)
raise ArgumentError, "invalid url for OTLP::Exporter #{endpoint}" unless OpenTelemetry::Common::Utilities.valid_url?(endpoint)
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.

why remove this validation?

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.

redo if backoff?(retry_count: retry_count += 1, reason: response.code)
FAILURE
when Net::HTTPNotFound
log_request_failure(response.code)
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.

There is no metrics support, OpenTelemetry.handle_error seems enough.

@github-actions
Copy link
Copy Markdown
Contributor

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

Comment thread exporter/otlp-http/lib/opentelemetry/exporter/otlp/http/trace_exporter.rb Outdated
Comment thread exporter/otlp-http/test/opentelemetry/exporter/otlp/http/trace_exporter_test.rb Outdated
headers
end

def prepare_endpoint(endpoint)
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.

Thank you for adding protections for edge cases!

@arjun-rajappa arjun-rajappa force-pushed the add-tests-otlp-http branch 2 times, most recently from 63304ce to 96374cc Compare May 26, 2026 05:07
- Remove metrics_reporter parameter and all internal metrics recording
- Remove private_constant declarations for KEEP_ALIVE_TIMEOUT, RETRY_COUNT, and ERROR_MESSAGE_INVALID_HEADERS
- Simplify compression logic using ternary operator
- Remove measure_request_duration method and inline request execution
- Replace metrics recording with standard error logging in backoff
- Remove metrics-related test case
- Fix typo

This change removes the internal metrics instrumentation from the OTLP HTTP trace exporter, simplifying the codebase and reducing dependencies.

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
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.

Make otlp-http, otlp-grpc, and otlp-common gems production-ready

3 participants