Skip to content

Add grpc support to otlp exporter #18982

@Rjected

Description

@Rjected

Describe the feature

Right now the otlp exporter only supports http, not grpc:

SpanExporter::builder().with_http().with_endpoint(endpoint.to_string()).build()?;

We should make this support grpc as well, if the user specifies a grpc endpoint in the args:

/// CLI arguments for configuring `Opentelemetry` trace and span export.
#[derive(Debug, Clone, Default, Parser)]
pub struct TraceArgs {
/// Enable `Opentelemetry` tracing export to an OTLP endpoint.
///
/// If no value provided, defaults to `http://localhost:4318/v1/traces`.
///
/// Example: --tracing-otlp=http://collector:4318/v1/traces
#[arg(
long = "tracing-otlp",
global = true,
value_name = "URL",
num_args = 0..=1,
default_missing_value = "http://localhost:4318/v1/traces",
require_equals = true,
value_parser = parse_otlp_endpoint,
help_heading = "Tracing"
)]
pub otlp: Option<Url>,
}
// Parses and validates an OTLP endpoint url.
fn parse_otlp_endpoint(arg: &str) -> eyre::Result<Url> {
let url = Url::parse(arg).wrap_err("Invalid URL for OTLP trace output")?;
// OTLP url must end with `/v1/traces` per the OTLP specification.
ensure!(
url.path().ends_with("/v1/traces"),
"OTLP trace endpoint must end with /v1/traces, got path: {}",
url.path()
);
Ok(url)
}

Additional context

No response

Metadata

Metadata

Assignees

Labels

A-observabilityRelated to tracing, metrics, logs and other observability toolsC-enhancementNew feature or request

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions