mirror of
https://github.com/matter-labs/teepot.git
synced 2025-07-21 15:13:56 +02:00
feat(config): update OTLP endpoint and protocol handling
- Change default OTLP endpoint to match the HTTP/JSON spec. - Add dynamic protocol-based exporter configuration. - Support both gRPC and HTTP/JSON transports for logging. Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
parent
6c3bd96617
commit
e62aff3511
1 changed files with 26 additions and 10 deletions
|
@ -147,8 +147,8 @@ impl Default for TelemetryOtlpConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
enable: true,
|
enable: true,
|
||||||
endpoint: "http://127.0.0.1:4317".to_string(),
|
endpoint: "http://127.0.0.1:4318/v1/logs".to_string(),
|
||||||
protocol: "grpc".to_string(),
|
protocol: "http/json".to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,15 +269,31 @@ fn init_telemetry(
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Configure the OTLP exporter
|
// Parse the protocol from the configuration
|
||||||
let logging_provider = SdkLoggerProvider::builder()
|
let protocol = protocol_from_string(&config.otlp.protocol)?;
|
||||||
.with_batch_exporter(
|
|
||||||
opentelemetry_otlp::LogExporter::builder()
|
// Configure the OTLP exporter based on the protocol
|
||||||
.with_tonic()
|
let exporter_builder = opentelemetry_otlp::LogExporter::builder();
|
||||||
|
|
||||||
|
// Choose transport based on protocol
|
||||||
|
let exporter = match protocol {
|
||||||
|
opentelemetry_otlp::Protocol::Grpc => exporter_builder
|
||||||
|
.with_tonic()
|
||||||
|
.with_endpoint(&config.otlp.endpoint)
|
||||||
|
.with_protocol(protocol)
|
||||||
|
.build()?,
|
||||||
|
opentelemetry_otlp::Protocol::HttpBinary | opentelemetry_otlp::Protocol::HttpJson => {
|
||||||
|
exporter_builder
|
||||||
|
.with_http()
|
||||||
.with_endpoint(&config.otlp.endpoint)
|
.with_endpoint(&config.otlp.endpoint)
|
||||||
.with_protocol(protocol_from_string(&config.otlp.protocol)?)
|
.with_protocol(protocol)
|
||||||
.build()?,
|
.build()?
|
||||||
)
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Configure the logging provider with the exporter
|
||||||
|
let logging_provider = SdkLoggerProvider::builder()
|
||||||
|
.with_batch_exporter(exporter)
|
||||||
.with_resource(resource)
|
.with_resource(resource)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue