Skip to content

Commit

Permalink
Finish moving run_id and TimelineIds to the worker task
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmunns committed Aug 22, 2022
1 parent 1e67fee commit be93d49
Show file tree
Hide file tree
Showing 4 changed files with 292 additions and 254 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ members = [
"tracing-serde-modality-ingest",
"tracing-serde-subscriber",
]

# TODO(AJM): Work around mismatched UUID version
[patch.crates-io.modality-ingest-client]
git = "https://github.com/auxoncorp/modality-sdk"
rev = "4a3b9e3cca08e8225e084f9e8409e818646589ec"
12 changes: 2 additions & 10 deletions tracing-modality/src/async/layer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::common::options::Options;
use crate::{InitError, TIMELINE_IDENTIFIER, RUN_ID};
use crate::{InitError, TIMELINE_IDENTIFIER};

use crate::common::layer::LayerHandler;
use crate::ingest::{ModalityIngest, ModalityIngestTaskHandle, WrappedMessage};
Expand All @@ -8,7 +8,6 @@ use anyhow::Context as _;
use tokio::sync::mpsc::{self, UnboundedSender};
use tracing_core::Subscriber;
use tracing_subscriber::{layer::SubscriberExt, Registry};
use uuid::Uuid;

/// A `tracing` `Layer` that can be used to record trace events and stream them to modality in real
/// time.
Expand All @@ -26,15 +25,8 @@ impl ModalityLayer {

/// Initialize a new `ModalityLayer`, with specified options.
pub async fn init_with_options(
mut opts: Options,
opts: Options,
) -> Result<(Self, ModalityIngestTaskHandle), InitError> {
let run_id = Uuid::new_v4();
opts.add_metadata("run_id", run_id.to_string());

RUN_ID
.set(run_id)
.map_err(|_| InitError::InitializedTwice)?;

TIMELINE_IDENTIFIER
.set(opts.timeline_identifier)
.map_err(|_| InitError::InitializedTwice)?;
Expand Down
12 changes: 2 additions & 10 deletions tracing-modality/src/blocking/layer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::common::options::Options;
use crate::{InitError, RUN_ID, TIMELINE_IDENTIFIER};
use crate::{InitError, TIMELINE_IDENTIFIER};

use crate::common::layer::LayerHandler;
use crate::ingest::{ModalityIngest, ModalityIngestThreadHandle, WrappedMessage};
Expand All @@ -8,7 +8,6 @@ use anyhow::Context as _;
use tokio::sync::mpsc::{self, UnboundedSender};
use tracing_core::Subscriber;
use tracing_subscriber::{layer::SubscriberExt, Registry};
use uuid::Uuid;

/// A `tracing` `Layer` that can be used to record trace events and stream them to modality in real
/// time.
Expand All @@ -26,15 +25,8 @@ impl ModalityLayer {

/// Initialize a new `ModalityLayer`, with specified options.
pub fn init_with_options(
mut opts: Options,
opts: Options,
) -> Result<(Self, ModalityIngestThreadHandle), InitError> {
let run_id = Uuid::new_v4();
opts.add_metadata("run_id", run_id.to_string());

RUN_ID
.set(run_id)
.map_err(|_| InitError::InitializedTwice)?;

TIMELINE_IDENTIFIER
.set(opts.timeline_identifier)
.map_err(|_| InitError::InitializedTwice)?;
Expand Down
Loading

0 comments on commit be93d49

Please sign in to comment.