Telegram Group & Telegram Channel
Использование OpenTelemetry в Rust

В статье рассмотрено, как использовать OpenTelemetry в Rust для мониторинга и трассировки приложений. OpenTelemetry — это мощный инструмент для сбора и анализа данных о производительности, который помогает отслеживать выполнение запросов в распределенных системах.

В статье показано, как интегрировать OpenTelemetry в приложение на Rust, используя библиотеку tracing и экспортировать данные в Jaeger. Приведены примеры кода, объясняющие настройку и использование трейсов для диагностики проблем и улучшения производительности.

Базовый конвейер с OpenTelemetry можно настроить с помощью opentelemetry_otlp. Затем создаётся слой tracing_opentelemetry, использующий этот конвейер, и добавляется в подписчик трассировки, который инициализируется.


// note that here, localhost:4318 is the default HTTP address
// for a local OpenTelemetry collector
let tracer = opentelemetry_otlp
::new_pipeline()
.tracing()
.with_exporter(opentelemetry_otlp::new_exporter().http().with_endpoint("localhost:4318"))
.install_batch(Tokio)
.unwrap();

// log level filtering here
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))
.unwrap();

// fmt layer - printing out logs
let fmt_layer = fmt::layer().compact();

// turn our OTLP pipeline into a tracing layer
let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);

// initialise our subscriber
subscriber
.with(filter_layer)
.with(fmt_layer)
.with(otel_layer)
// The error layer needs to go after the otel_layer, because it needs access to the
// otel_data extension that is set on the span in the otel_layer.
.with(ErrorTracingLayer::new())
.init();


https://shuttle.rs/blog/2024/04/10/using-opentelemetry-rust

👉 @rust_lib



tg-me.com/rust_lib/226
Create:
Last Update:

Использование OpenTelemetry в Rust

В статье рассмотрено, как использовать OpenTelemetry в Rust для мониторинга и трассировки приложений. OpenTelemetry — это мощный инструмент для сбора и анализа данных о производительности, который помогает отслеживать выполнение запросов в распределенных системах.

В статье показано, как интегрировать OpenTelemetry в приложение на Rust, используя библиотеку tracing и экспортировать данные в Jaeger. Приведены примеры кода, объясняющие настройку и использование трейсов для диагностики проблем и улучшения производительности.

Базовый конвейер с OpenTelemetry можно настроить с помощью opentelemetry_otlp. Затем создаётся слой tracing_opentelemetry, использующий этот конвейер, и добавляется в подписчик трассировки, который инициализируется.


// note that here, localhost:4318 is the default HTTP address
// for a local OpenTelemetry collector
let tracer = opentelemetry_otlp
::new_pipeline()
.tracing()
.with_exporter(opentelemetry_otlp::new_exporter().http().with_endpoint("localhost:4318"))
.install_batch(Tokio)
.unwrap();

// log level filtering here
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))
.unwrap();

// fmt layer - printing out logs
let fmt_layer = fmt::layer().compact();

// turn our OTLP pipeline into a tracing layer
let otel_layer = tracing_opentelemetry::layer().with_tracer(tracer);

// initialise our subscriber
subscriber
.with(filter_layer)
.with(fmt_layer)
.with(otel_layer)
// The error layer needs to go after the otel_layer, because it needs access to the
// otel_data extension that is set on the span in the otel_layer.
.with(ErrorTracingLayer::new())
.init();


https://shuttle.rs/blog/2024/04/10/using-opentelemetry-rust

👉 @rust_lib

BY Rust




Share with your friend now:
tg-me.com/rust_lib/226

View MORE
Open in Telegram


Rust Telegram | DID YOU KNOW?

Date: |

Telegram and Signal Havens for Right-Wing Extremists

Since the violent storming of Capitol Hill and subsequent ban of former U.S. President Donald Trump from Facebook and Twitter, the removal of Parler from Amazon’s servers, and the de-platforming of incendiary right-wing content, messaging services Telegram and Signal have seen a deluge of new users. In January alone, Telegram reported 90 million new accounts. Its founder, Pavel Durov, described this as “the largest digital migration in human history.” Signal reportedly doubled its user base to 40 million people and became the most downloaded app in 70 countries. The two services rely on encryption to protect the privacy of user communication, which has made them popular with protesters seeking to conceal their identities against repressive governments in places like Belarus, Hong Kong, and Iran. But the same encryption technology has also made them a favored communication tool for criminals and terrorist groups, including al Qaeda and the Islamic State.

The global forecast for the Asian markets is murky following recent volatility, with crude oil prices providing support in what has been an otherwise tough month. The European markets were down and the U.S. bourses were mixed and flat and the Asian markets figure to split the difference.The TSE finished modestly lower on Friday following losses from the financial shares and property stocks.For the day, the index sank 15.09 points or 0.49 percent to finish at 3,061.35 after trading between 3,057.84 and 3,089.78. Volume was 1.39 billion shares worth 1.30 billion Singapore dollars. There were 285 decliners and 184 gainers.

Rust from us


Telegram Rust
FROM USA