Skip to content

Commit

Permalink
Merge pull request #741 from logzio/rusk-sdk-jan5
Browse files Browse the repository at this point in the history
Rust
  • Loading branch information
Simplychee authored Jan 27, 2025
2 parents e63a729 + f0baf85 commit 16c4de6
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/shipping/Code/dotnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ This integration uses the OpenTelemetry logging exporter to send logs to Logz.io
- An active account with Logz.io

:::note
If you need an example aplication to test this integration, please refer to our [.NET OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/dotnet/logs).
If you need an example application to test this integration, please refer to our [.NET OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/dotnet/logs).
:::

### Configure the instrumentation
Expand Down
2 changes: 1 addition & 1 deletion docs/shipping/Code/go.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ This integration uses the OpenTelemetry logging exporter to send logs to Logz.io
- Go 1.21 or newer

:::note
If you need an example aplication to test this integration, please refer to our [Go OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/go/logs).
If you need an example application to test this integration, please refer to our [Go OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/go/logs).
:::

### Configure the instrumentation
Expand Down
4 changes: 2 additions & 2 deletions docs/shipping/Code/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ This integration uses the OpenTelemetry logging exporter to send logs to Logz.io
- Java 8+

:::note
If you need an example aplication to test this integration, please refer to our [Java OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/java/logs).
If you need an example application to test this integration, please refer to our [Java OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/java/logs).
:::

### Configure the instrumentation
Expand Down Expand Up @@ -1447,7 +1447,7 @@ Deploy this integration to auto-instrument your Java application running on AWS
{@include: ../../_include/log-shipping/aws-region-limitation.md}
:::note
If you need an example aplication to test this integration, please refer to our [Java OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/java/traces/lambda-service).
If you need an example application to test this integration, please refer to our [Java OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/java/traces/lambda-service).
:::
**Before you begin, you'll need**:
Expand Down
2 changes: 1 addition & 1 deletion docs/shipping/Code/node-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ This integration uses the OpenTelemetry logging exporter to send logs to Logz.io
- An active account with Logz.io

:::note
If you need an example aplication to test this integration, please refer to our [NodeJS OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/nodejs/logs).
If you need an example application to test this integration, please refer to our [NodeJS OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/nodejs/logs).
:::

### Configure the instrumentation
Expand Down
2 changes: 1 addition & 1 deletion docs/shipping/Code/php.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This integration uses the OpenTelemetry logging exporter to send logs to Logz.io
- PHP 7.4+ for manual instrumentation or PHP 8.0+ for auto-instrumentation.

:::note
If you need an example aplication to test this integration, please refer to our [PHP OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/php).
If you need an example application to test this integration, please refer to our [PHP OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/php).
:::

### Configure the instrumentation
Expand Down
2 changes: 1 addition & 1 deletion docs/shipping/Code/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ This integration uses the OpenTelemetry logging exporter to send logs to Logz.io
- An active account with Logz.io

:::note
If you need an example aplication to test this integration, please refer to our [Python OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/python/logs).
If you need an example application to test this integration, please refer to our [Python OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/python/logs).
:::

1. Install OpenTelemetry dependencies:
Expand Down
89 changes: 89 additions & 0 deletions docs/shipping/Code/rustsdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
id: Rust
title: Rust
overview: Deploy this integration to collect logs from your Rust application.
product: ['logs']
os: ['windows', 'linux']
filters: ['Code']
logo: https://logzbucket.s3.eu-west-1.amazonaws.com/logz-docs/shipper-logos/rust-logo-blk.svg
logs_dashboards: []
logs_alerts: []
logs2metrics: []
metrics_dashboards: []
metrics_alerts: []
drop_filter: []
---

:::note
If you need an example application to test this integration, please refer to our [Rust OpenTelemetry repository](https://github.com/logzio/opentelemetry-examples/tree/main/rust/logs).
:::

This guide explains how to configure your Rust application to send logs to Logz.io via OpenTelemetry.

## Prerequisites

* A Rust application with logging capabilities.
* An active Logz.io account
* Your log shipping token
* Port `8071` available on your host system


## Add Dependencies

To send logs to Logz.io via OpenTelemetry, add the required dependencies to your `Cargo.toml` file:

```toml
[dependencies]
log = "0.4"
opentelemetry = "0.27"
opentelemetry-appender-log = "0.27"
opentelemetry_sdk = { version = "*", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "*", features = ["http-proto", "reqwest-client", "reqwest-rustls"] }
tokio = { version = "1", features = ["full"] }
```

## Configure Logging and Implement OTLP Communication

Import the following modules into your existing app:

```rust
use opentelemetry_appender_log::OpenTelemetryLogBridge;
use opentelemetry_otlp::{WithExportConfig, WithHttpConfig};
use std::collections::HashMap;
```

Add the exporters and logger provider section to your code:

```rust
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {

let endpoint = "https://otlp-listener.logz.io/v1/logs";
let api_token = "LOGZ_IO_TOKEN";

let logger_provider = opentelemetry_sdk::logs::LoggerProvider::builder()
.with_batch_exporter(
opentelemetry_otlp::LogExporter::builder()
.with_http()
.with_endpoint(endpoint)
.with_headers(HashMap::from([
("Authorization".to_string(), format!("Bearer {}", api_token), ),
("User-Agent".to_string(), format!("logzio-rust-logs-otlp"), ),
]))
.build()?,
opentelemetry_sdk::runtime::Tokio,
)
.build();

let log_bridge = OpenTelemetryLogBridge::new(&logger_provider);

```

Replace `LOGZ_IO_TOKEN` with the shipping token of the account.

If needed, update the `https://otlp-listener.logz.io/v1/logs` with the URL of [your hosting region](https://docs.logz.io/docs/user-guide/admin/hosting-regions/account-region/#opentelemetry-protocol-otlp-regions).

## Run the application and check Logz.io for logs

Run your application with `cargo run`. Give your logs some time to get from your system to ours.

Encounter an issue? See our [log shipping troubleshooting](https://docs.logz.io/docs/user-guide/log-management/troubleshooting/log-shipping-troubleshooting/) guide.
2 changes: 1 addition & 1 deletion static/manifest.json

Large diffs are not rendered by default.

0 comments on commit 16c4de6

Please sign in to comment.