Skip to content

Add endpointURL for bare IP:port values#24

Merged
bramwelt merged 2 commits intomainfrom
bramwelt/otel-endpoint-fix
Feb 16, 2026
Merged

Add endpointURL for bare IP:port values#24
bramwelt merged 2 commits intomainfrom
bramwelt/otel-endpoint-fix

Conversation

@bramwelt
Copy link
Contributor

This pull request improves the handling of OpenTelemetry (OTel) endpoint URLs to ensure compatibility with the OTel SDK's expectations and to prevent errors when using bare IP:port endpoints. The main enhancement is the normalization of the endpoint configuration to always include a URL scheme, which is now required for correct parsing by the SDK. The changes also update the SDK option usage to expect full URLs and add comprehensive tests for the new logic.

Endpoint normalization and SDK compatibility:

  • Added the endpointURL helper function in otel.go to ensure that the OTel endpoint always includes a URL scheme (http:// or https://), preventing SDK parsing errors with bare IP:port values. The function prepends the appropriate scheme based on the Insecure flag and leaves existing URLs unchanged. (pkg/utils/otel.go, [1] [2]
  • Updated all OTel SDK option calls to use the new WithEndpointURL methods instead of the deprecated WithEndpoint, ensuring the endpoint is always parsed as a URL and aligning with the latest SDK requirements. (pkg/utils/otel.go, [1] [2] [3] [4] [5] [6]

Testing improvements:

  • Added unit tests for the endpointURL function to verify correct scheme prepending and preservation of existing schemes. (pkg/utils/otel_test.go, pkg/utils/otel_test.goR427-R521)
  • Added an integration test to confirm that SetupOTelSDKWithConfig correctly normalizes a bare IP:port endpoint, preventing SDK errors related to invalid URL parsing. (pkg/utils/otel_test.go, pkg/utils/otel_test.goR427-R521)

bramwelt and others added 2 commits February 12, 2026 14:56
Prepend a URL scheme to bare IP:port endpoints so
the OTel SDK can parse them. Use WithEndpointURL
consistently for all exporters and update the env
var so the SDK reads a valid URL internally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-608
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
WithEndpointURL receives the normalized endpoint
explicitly, making the env var mutation unnecessary.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-608
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
@bramwelt bramwelt requested a review from a team as a code owner February 13, 2026 01:23
Copilot AI review requested due to automatic review settings February 13, 2026 01:23
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Walkthrough

Added endpointURL() function to normalize OTLP endpoint strings by ensuring they include URL schemes. Updated six OTLP exporter option constructors across HTTP/gRPC trace, metrics, and logs exporters to use URL-based endpoint endpoints parameters. Integrated endpoint normalization into SetupOTelSDKWithConfig.

Changes

Cohort / File(s) Summary
OTLP Endpoint URL Normalization
pkg/utils/otel.go
Added endpointURL() function to prepend http:// or https:// scheme when absent. Updated all OTLP exporter constructors (otlptracehttp, otlptracegrpc, otlpmetrichttp, otlpmetricgrpc, otlploghttp, otlploggrpc) to use WithEndpointURL() with normalized endpoints.
Endpoint Handling Tests
pkg/utils/otel_test.go
Added TestEndpointURL() and TestSetupOTelSDKWithConfig_IPEndpoint() to validate endpoint URL scheme normalization and bare IP:port endpoint handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: adding an endpointURL helper function to handle bare IP:port endpoint values by normalizing them with URL schemes.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the endpoint normalization logic, SDK compatibility updates, and testing improvements.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bramwelt/otel-endpoint-fix

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request improves OpenTelemetry endpoint handling by adding URL normalization to support bare IP:port values and migrating from deprecated SDK methods. The changes ensure compatibility with the OTel SDK v1.40.0's URL parsing requirements, which fail on bare IP:port endpoints without schemes.

Changes:

  • Added endpointURL helper function to normalize endpoints by prepending appropriate HTTP/HTTPS schemes based on the Insecure flag
  • Migrated all OTLP exporter configurations from deprecated WithEndpoint to WithEndpointURL methods across traces, metrics, and logs exporters
  • Added comprehensive unit tests for URL normalization and integration test for bare IP:port endpoint handling

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pkg/utils/otel.go Added endpointURL helper function and updated all OTLP exporters to use WithEndpointURL instead of deprecated WithEndpoint
pkg/utils/otel_test.go Added unit tests for endpointURL function and integration test for bare IP:port endpoint configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


import (
"context"

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Remove the blank line between standard library imports. Both "context" and "testing" are standard library packages and should be grouped together without a blank line separator. Go convention typically uses blank lines only to separate standard library imports from third-party imports.

Suggested change

Copilot uses AI. Check for mistakes.
@bramwelt bramwelt merged commit b91e302 into main Feb 16, 2026
12 checks passed
@bramwelt bramwelt deleted the bramwelt/otel-endpoint-fix branch February 16, 2026 21:37
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.

3 participants