From fcba120bf85c8baff67b5ee0fc896744f9c818c8 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Mon, 18 Mar 2024 07:10:55 +1000 Subject: [PATCH] start tightening up some APIs --- core/src/template.rs | 6 ------ macros/src/span.rs | 2 +- src/frame.rs | 4 ++-- src/lib.rs | 2 +- src/metrics.rs | 3 +-- tests/smoke-test/main.rs | 6 +++--- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/core/src/template.rs b/core/src/template.rs index 4c36327..22a27d3 100644 --- a/core/src/template.rs +++ b/core/src/template.rs @@ -279,12 +279,6 @@ impl Write for WriteBraced { pub struct Braced<'a, P>(Render<'a, P>); -impl<'a> Template<'a> { - pub fn braced<'b>(&'b self) -> Braced<'b, Empty> { - self.render(Empty).braced() - } -} - impl<'a, P> Render<'a, P> { pub fn braced(self) -> Braced<'a, P> { Braced(self) diff --git a/macros/src/span.rs b/macros/src/span.rs index 2605ad6..6a27b9b 100644 --- a/macros/src/span.rs +++ b/macros/src/span.rs @@ -192,7 +192,7 @@ fn inject_async( quote!({ let (__ctxt, __timer) = emit::__private::__private_push_span_ctxt(#rt_tokens, #module_tokens, #when_tokens, #template_tokens, #ctxt_props_tokens, #evt_props_tokens); - __ctxt.with_future(async { + __ctxt.in_future(async { let #span_arg = emit::__private::__private_begin_span(__timer, |extent| { emit::__private::__private_emit( #rt_tokens, diff --git a/src/frame.rs b/src/frame.rs index a1ea232..cf7a0b7 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -58,13 +58,13 @@ impl Frame { } #[track_caller] - pub fn with(mut self, scope: impl FnOnce() -> R) -> R { + pub fn call(mut self, scope: impl FnOnce() -> R) -> R { let __guard = self.enter(); scope() } #[track_caller] - pub fn with_future(self, future: F) -> FrameFuture { + pub fn in_future(self, future: F) -> FrameFuture { FrameFuture { frame: self, future, diff --git a/src/lib.rs b/src/lib.rs index 93794f8..39ca9ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -92,7 +92,7 @@ pub use emit_macros::*; #[doc(inline)] pub use emit_core::{ - clock, ctxt, emitter, empty, event, extent, filter, props, rng, runtime, str, template, + clock, ctxt, emitter, empty, event, extent, filter, path, props, rng, runtime, str, template, timestamp, value, well_known, }; diff --git a/src/metrics.rs b/src/metrics.rs index 1572cd4..48b695b 100644 --- a/src/metrics.rs +++ b/src/metrics.rs @@ -1,10 +1,9 @@ use core::ops::ControlFlow; use emit_core::{ - empty::Empty, extent::{Extent, ToExtent}, path::Path, - props::Props, + props::{ByRef, ErasedProps, Props}, str::{Str, ToStr}, value::{ToValue, Value}, well_known::{KEY_METRIC_AGG, KEY_METRIC_NAME, KEY_METRIC_VALUE}, diff --git a/tests/smoke-test/main.rs b/tests/smoke-test/main.rs index e20b72d..f3a104d 100644 --- a/tests/smoke-test/main.rs +++ b/tests/smoke-test/main.rs @@ -27,11 +27,11 @@ async fn main() { emit_otlp::http("http://localhost:4318/v1/logs") .headers([("X-ApiKey", "1234")]), ) - .body(|evt, f| write!(f, "{}", evt.tpl().braced())), + .body(|evt, f| write!(f, "{}", evt.tpl().render(emit::empty::Empty).braced())), ) .traces( emit_otlp::traces_http_proto("http://localhost:4318/v1/traces") - .name(|evt, f| write!(f, "{}", evt.tpl().braced())), + .name(|evt, f| write!(f, "{}", evt.tpl().render(emit::empty::Empty).braced())), ) .metrics(emit_otlp::metrics_http_proto( "http://localhost:4318/v1/metrics", @@ -102,7 +102,7 @@ async fn in_trace() -> Result<(), io::Error> { futures.push(tokio::spawn( emit::runtime::shared() .current_frame() - .with_future(in_ctxt(i)), + .in_future(in_ctxt(i)), )); }