forked from mirrors/relay
Name relay service for otel
This commit is contained in:
parent
5e24bb06a7
commit
82371d4a65
1 changed files with 13 additions and 8 deletions
21
src/main.rs
21
src/main.rs
|
@ -1,4 +1,5 @@
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
|
use opentelemetry::{sdk::Resource, KeyValue};
|
||||||
use opentelemetry_otlp::WithExportConfig;
|
use opentelemetry_otlp::WithExportConfig;
|
||||||
use tracing_actix_web::TracingLogger;
|
use tracing_actix_web::TracingLogger;
|
||||||
use tracing_error::ErrorLayer;
|
use tracing_error::ErrorLayer;
|
||||||
|
@ -46,14 +47,18 @@ async fn main() -> Result<(), anyhow::Error> {
|
||||||
.with(format_layer);
|
.with(format_layer);
|
||||||
|
|
||||||
if let Some(url) = config.opentelemetry_url() {
|
if let Some(url) = config.opentelemetry_url() {
|
||||||
let tracer = opentelemetry_otlp::new_pipeline()
|
let tracer =
|
||||||
.tracing()
|
opentelemetry_otlp::new_pipeline()
|
||||||
.with_exporter(
|
.tracing()
|
||||||
opentelemetry_otlp::new_exporter()
|
.with_trace_config(opentelemetry::sdk::trace::config().with_resource(
|
||||||
.tonic()
|
Resource::new(vec![KeyValue::new("service.name", config.software_name())]),
|
||||||
.with_endpoint(url.as_str()),
|
))
|
||||||
)
|
.with_exporter(
|
||||||
.install_batch(opentelemetry::runtime::TokioCurrentThread)?;
|
opentelemetry_otlp::new_exporter()
|
||||||
|
.tonic()
|
||||||
|
.with_endpoint(url.as_str()),
|
||||||
|
)
|
||||||
|
.install_batch(opentelemetry::runtime::TokioCurrentThread)?;
|
||||||
|
|
||||||
let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);
|
let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue