Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ derive_more = "0.99"
futures = "0.3"
itertools = "0.10"
once_cell = "1.5"
opentelemetry-jaeger = "0.11"
opentelemetry = "0.12"
opentelemetry-jaeger = "0.12"
opentelemetry = { version = "0.13", features = ["rt-tokio"] }
parking_lot = "0.11"
prost = "0.7"
prost-types = "0.7"
Expand All @@ -28,7 +28,7 @@ thiserror = "1.0"
tokio = { version = "1.1", features = ["rt", "rt-multi-thread", "parking_lot"] }
tracing = { version = "0.1", features = ["log"] }
tracing-futures = "0.2"
tracing-opentelemetry = "0.11"
tracing-opentelemetry = "0.12"
tracing-subscriber = "0.2"
url = "2.2"
rand = "0.8.3"
Expand Down
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ We are using [clippy](https://github.com/rust-lang/rust-clippy) for linting.
You can run it using:
`cargo clippy --all -- -D warnings`

## Style Guidelines

### Error handling
Any error which is returned from a public interface should be well-typed, and we use
[thiserror](https://github.com/dtolnay/thiserror) for that purpose.

Errors returned from things only used in testing are free to use
[anyhow](https://github.com/dtolnay/anyhow) for less verbosity.


## Debugging
The crate uses [tracing](https://github.com/tokio-rs/tracing) to help with debugging. To enable
it for a test, insert the below snippet at the start of the test. By default, tracing data is output
Expand All @@ -54,4 +44,22 @@ let _enter = s.enter();
```

To run the Jaeger instance:
`docker run --rm -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest`
`docker run --rm -p6831:6831/udp -p6832:6832/udp -p16686:16686 jaegertracing/all-in-one:latest`

To show logs in the console, set the `RUST_LOG` environment variable to `temporal_sdk_core=DEBUG`
or whatever level you desire. The env var is parsed according to tracing's
[EnvFilter](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/struct.EnvFilter.html)
rules.

If you are working on a language SDK, you are expected to initialize tracing early in your `main`
equivalent.

## Style Guidelines

### Error handling
Any error which is returned from a public interface should be well-typed, and we use
[thiserror](https://github.com/dtolnay/thiserror) for that purpose.

Errors returned from things only used in testing are free to use
[anyhow](https://github.com/dtolnay/anyhow) for less verbosity.

16 changes: 7 additions & 9 deletions src/core_tracing.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
use itertools::Itertools;
use once_cell::sync::OnceCell;
use opentelemetry_jaeger::Uninstall;
use std::collections::VecDeque;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
use std::{collections::VecDeque, sync::Once};
use tracing_subscriber::util::SubscriberInitExt;
use tracing_subscriber::{layer::SubscriberExt, EnvFilter};

static TRACING_INIT: OnceCell<Uninstall> = OnceCell::new();
static TRACING_INIT: Once = Once::new();

/// Initialize tracing subscribers and output. Core will not call this itself, it exists here so
/// that consumers and tests have an easy way to initialize tracing.
pub fn tracing_init() {
TRACING_INIT.get_or_init(|| {
let (tracer, uninstall) = opentelemetry_jaeger::new_pipeline()
TRACING_INIT.call_once(|| {
let tracer = opentelemetry_jaeger::new_pipeline()
.with_service_name("coresdk")
.install()
.install_batch(opentelemetry::runtime::Tokio)
.unwrap();
let opentelemetry = tracing_opentelemetry::layer().with_tracer(tracer);
let filter_layer = EnvFilter::try_from_default_env()
Expand All @@ -26,7 +25,6 @@ pub fn tracing_init() {
.with(fmt_layer)
.try_init()
.unwrap();
uninstall
});
}

Expand Down