Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Increment the:

## [Unreleased]

* [OTLP/gRPC] Support VSOCK endpoints on Linux
[#4706](https://github.com/open-telemetry/opentelemetry-cpp/issues/4706)

## [1.30.0] 2026-10-22

This release contains:
Expand Down
5 changes: 5 additions & 0 deletions exporters/otlp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ auto exporter = std::make_unique<otlp::OtlpFileExporter>(options);
|`metadata` |`OTEL_EXPORTER_OTLP_HEADERS` | | Custom metadata for GRPC |
| |`OTEL_EXPORTER_OTLP_TRACES_HEADERS` | | |

On Linux, the OTLP gRPC exporter supports VSOCK endpoints with gRPC 1.57.0 or
later. Set `vsock://<cid>:<port>` as the endpoint; the exporter converts it
to the `vsock:<cid>:<port>` target format expected by gRPC. A raw
`vsock:<cid>:<port>` target is also accepted.

### Configuration options ( OTLP HTTP Exporter )

| Option | Env Variable | Default | Description |
Expand Down
10 changes: 10 additions & 0 deletions exporters/otlp/src/otlp_grpc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ OtlpGrpcClient::~OtlpGrpcClient()

std::string OtlpGrpcClient::GetGrpcTarget(const std::string &endpoint)
{
// A raw VSOCK target is already in the format expected by gRPC.
if (endpoint.rfind("vsock:", 0) == 0 && endpoint.rfind("vsock://", 0) != 0)
{
return endpoint;
}

//
// Scheme is allowed in OTLP endpoint definition, but is not allowed for creating gRPC
// channel. Passing URI with scheme to grpc::CreateChannel could resolve the endpoint to some
Expand All @@ -327,6 +333,10 @@ std::string OtlpGrpcClient::GetGrpcTarget(const std::string &endpoint)
{
grpc_target = "unix:" + url.path_;
}
else if (url.scheme_ == "vsock")
{
Comment thread
Amanpal9 marked this conversation as resolved.
Resolved
grpc_target = "vsock:" + url.host_ + ":" + std::to_string(static_cast<int>(url.port_));
}
else
{
grpc_target = url.host_ + ":" + std::to_string(static_cast<int>(url.port_));
Expand Down
6 changes: 6 additions & 0 deletions exporters/otlp/test/otlp_grpc_target_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ TEST(OtlpGrpcClientEndpointTest, GrpcClientTest)
EXPECT_EQ(target3, "localhost:4317");
}

TEST(OtlpGrpcClientEndpointTest, VsockEndpoints)
{
EXPECT_EQ(OtlpGrpcClient::GetGrpcTarget("vsock:3:1234"), "vsock:3:1234");
EXPECT_EQ(OtlpGrpcClient::GetGrpcTarget("vsock://3:1234"), "vsock:3:1234");
}

TEST_F(OtlpGrpcClientTestPeer, ChannelArgumentsOptionTest)
{
OtlpGrpcClientOptions options;
Expand Down
Loading