Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
start tightening up some APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Mar 17, 2024
1 parent a5791bb commit fcba120
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
6 changes: 0 additions & 6 deletions core/src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,6 @@ impl<W: Write> Write for WriteBraced<W> {

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)
Expand Down
2 changes: 1 addition & 1 deletion macros/src/span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ impl<C: Ctxt> Frame<C> {
}

#[track_caller]
pub fn with<R>(mut self, scope: impl FnOnce() -> R) -> R {
pub fn call<R>(mut self, scope: impl FnOnce() -> R) -> R {
let __guard = self.enter();
scope()
}

#[track_caller]
pub fn with_future<F>(self, future: F) -> FrameFuture<C, F> {
pub fn in_future<F>(self, future: F) -> FrameFuture<C, F> {
FrameFuture {
frame: self,
future,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
3 changes: 1 addition & 2 deletions src/metrics.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
6 changes: 3 additions & 3 deletions tests/smoke-test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)),
));
}

Expand Down

0 comments on commit fcba120

Please sign in to comment.