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

Commit

Permalink
make histogram metrics standard
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Jan 2, 2024
1 parent ba8bb41 commit 336ce0e
Show file tree
Hide file tree
Showing 13 changed files with 463 additions and 97 deletions.
2 changes: 1 addition & 1 deletion batcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "emit-batcher"
name = "emit_batcher"
version = "0.0.0"
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ full = ["emit/std", "emit/rng", "emit/serde", "emit/sval"]
[dependencies.emit]
path = "../"

[dependencies.emit-batcher]
[dependencies.emit_batcher]
path = "../batcher"

[dependencies.criterion]
Expand Down
11 changes: 8 additions & 3 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "0.0.0"
edition = "2021"

[features]
std = ["alloc", "value-bag/error"]
alloc = ["value-bag/alloc", "value-bag/owned"]
sval = ["value-bag/sval", "dep:sval", "dep:sval_ref"]
std = ["alloc", "value-bag/error", "sval_nested?/std", "sval?/std", "serde?/std"]
alloc = ["value-bag/alloc", "value-bag/owned", "sval_nested?/alloc", "sval?/alloc", "serde?/alloc"]
sval = ["value-bag/sval", "dep:sval", "dep:sval_ref", "dep:sval_nested"]
serde = ["value-bag/serde", "dep:serde"]

[dependencies.value-bag]
Expand All @@ -22,6 +22,11 @@ version = "2"
optional = true
default-features = false

[dependencies.sval_nested]
version = "2"
optional = true
default-features = false

[dependencies.serde]
version = "1"
optional = true
Expand Down
8 changes: 4 additions & 4 deletions core/src/key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use core::{borrow::Borrow, fmt, hash, marker::PhantomData};

#[cfg(feature = "alloc")]
use alloc::boxed::Box;

pub struct Key<'k> {
value: *const str,
value_static: Option<&'static str>,
Expand Down Expand Up @@ -244,7 +247,7 @@ impl<'k> serde::Serialize for Key<'k> {

#[cfg(feature = "alloc")]
mod alloc_support {
use alloc::borrow::Cow;
use alloc::borrow::{Cow, ToOwned};

use super::*;

Expand Down Expand Up @@ -286,6 +289,3 @@ mod alloc_support {
}

use crate::value::{ToValue, Value};

#[cfg(feature = "alloc")]
pub use self::alloc_support::*;
2 changes: 1 addition & 1 deletion core/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ mod tests {

assert_eq!("metric", well_known.name());
assert_eq!("sum", well_known.kind());
assert_eq!(1, well_known.value().to_usize().unwrap());
assert_eq!(1.0, well_known.value().to_f64().unwrap());
}
}
8 changes: 5 additions & 3 deletions core/src/template.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use core::fmt;

#[cfg(feature = "alloc")]
use alloc::boxed::Box;

use crate::{
empty::Empty,
key::Key,
Expand Down Expand Up @@ -424,6 +427,8 @@ enum PartKind<'a> {
mod alloc_support {
use super::*;

use alloc::vec::Vec;

impl Template<'static> {
pub fn new_owned(parts: impl Into<Box<[Part<'static>]>>) -> Self {
let parts = parts.into();
Expand Down Expand Up @@ -482,6 +487,3 @@ mod alloc_support {
}
}
}

#[cfg(feature = "alloc")]
pub use self::alloc_support::*;
Loading

0 comments on commit 336ce0e

Please sign in to comment.