Skip to content

Commit

Permalink
Merge pull request #19 from Licenser/q1-2024-updates
Browse files Browse the repository at this point in the history
Update to newest otel libs and rust 1.76
  • Loading branch information
Licenser authored Mar 12, 2024
2 parents 901d05e + 5bd461d commit c12130a
Show file tree
Hide file tree
Showing 13 changed files with 152 additions and 219 deletions.
56 changes: 48 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,60 @@ include = ["src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
resolver = "2"

[dependencies]
opentelemetry = { version = "0.20", features = ["rt-tokio"] }
opentelemetry-otlp = { version = "0.13", features = ["prost", "tokio", "http-proto", "reqwest-client" ] }
opentelemetry = { version = "0.22" }
opentelemetry-otlp = { version = "0.15", features = [
"prost",
"tokio",
"http-proto",
"reqwest-client",
] }
tracing-core = { version = "0.1", default-features = false, features = ["std"] }
tracing-opentelemetry = { version = "0.21", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false, features = ["smallvec", "std", "registry", "fmt", "json" ] }
tracing-opentelemetry = { version = "0.23", default-features = false }
tracing-subscriber = { version = "0.3", default-features = false, features = [
"smallvec",
"std",
"registry",
"fmt",
"json",
] }
reqwest = { version = "0.11", default-features = false }
thiserror = "1"
opentelemetry-semantic-conventions = "0.12"
opentelemetry-semantic-conventions = "0.14"
url = "2.4.1"
opentelemetry_sdk = { version = "0.22.1", features = ["rt-tokio"] }

[dev-dependencies]
tokio = "1"
tracing = { version = "0.1", features = [ "log" ] }
opentelemetry = { version = "0.20", features = ["rt-tokio"] }
tokio = { version = "1", features = ["full", "tracing"] }
tracing = { version = "0.1", features = ["log"] }
opentelemetry = { version = "0.22" }
anyhow = "1.0.80"
uuid = { version = "1", features = ["v4"] }
tracing-subscriber = { version = "0.3", default-features = false, features = [
"smallvec",
"std",
"registry",
"fmt",
"json",
"ansi",
] }

# Example that demonstrates how to use the `tracing-axiom` layer with the `tracing-subscriber` crate.
[[example]]
name = "layers"

# Simple most example use of `tracing-axiom`.
[[example]]
name = "simple"

# Example that demonstrates using a nice color and formating
[[example]]
name = "fmt"


# Demonstrate setting config in the code
[[example]]
name = "noenv"


[features]
default = ["default-tls"]
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Now you can set up tracing in one line like this:
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_axiom::init()?;
say_hello();
// Ensure that the tracing provider is shutdown correctly
opentelemetry::global::shutdown_tracer_provider();
Ok(())
}
Expand All @@ -52,7 +56,7 @@ pub fn say_hello() {
For further examples, head over to the [examples](examples) directory.

> **Note**: Due to a limitation of an underlying library, [events outside of a
> span are not recorded](https://docs.rs/tracing-opentelemetry/0.17.4/src/tracing_opentelemetry/layer.rs.html#807).
> span are not recorded](https://docs.rs/tracing-opentelemetry/latest/src/tracing_opentelemetry/layer.rs.html#807).
## Features

Expand All @@ -66,6 +70,7 @@ that can be enabled or disabled:
- **rustls-tls**: Enables TLS functionality provided by `rustls`.

## FAQ & Troubleshooting

### How do I log traces to the console in addition to Axiom?
You can use this library to get a [`tracing-subscriber::layer`](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/index.html)
and combine it with other layers, for example one that prints traces to the
Expand Down
11 changes: 0 additions & 11 deletions examples/fmt/Cargo.toml

This file was deleted.

3 changes: 3 additions & 0 deletions examples/fmt/src/main.rs → examples/fmt/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

say_hello();

// Ensure that the tracing provider is shutdown correctly
opentelemetry::global::shutdown_tracer_provider();

Ok(())
}

Expand Down
15 changes: 0 additions & 15 deletions examples/layers/Cargo.toml

This file was deleted.

5 changes: 4 additions & 1 deletion examples/layers/src/main.rs → examples/layers/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use opentelemetry::global;
use opentelemetry::sdk::propagation::TraceContextPropagator;
use opentelemetry_sdk::propagation::TraceContextPropagator;
use tracing::{info, instrument};
use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
Expand Down Expand Up @@ -59,5 +59,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// do something with result ...

// Ensure that the tracing provider is shutdown correctly
opentelemetry::global::shutdown_tracer_provider();

Ok(())
}
10 changes: 0 additions & 10 deletions examples/noenv/Cargo.toml

This file was deleted.

7 changes: 5 additions & 2 deletions examples/noenv/src/main.rs → examples/noenv/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ fn say_hi(id: Uuid, name: impl Into<String> + std::fmt::Debug) {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_axiom::builder()
.with_tags(&[("aws_region", "us-east-1")]) // Set otel tags
.with_dataset("tracing-axiom-examples".to_string()) // Set dataset
.with_dataset("tracing-axiom-examples") // Set dataset
.with_token("xaat-some-valid-token") // Set API token
.with_url("Some valid URL other than default") // Set URL
.with_url("http://localhost:4318") // Set URL, can be changed to any OTEL endpoint
.init()?; // Initialize tracing

let uuid = Uuid::new_v4();
say_hi(uuid, "world");

// do something with result ...

// Ensure that the tracing provider is shutdown correctly
opentelemetry::global::shutdown_tracer_provider();

Ok(())
}
10 changes: 0 additions & 10 deletions examples/simple/Cargo.toml

This file was deleted.

17 changes: 17 additions & 0 deletions examples/simple/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use tracing::{error, instrument};

#[instrument]
fn say_hello() {
error!("hello world")
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_axiom::init()?;
say_hello();

// Ensure that the tracing provider is shutdown correctly
opentelemetry::global::shutdown_tracer_provider();

Ok(())
}
14 changes: 0 additions & 14 deletions examples/simple/src/main.rs

This file was deleted.

Loading

0 comments on commit c12130a

Please sign in to comment.