Skip to content

Commit

Permalink
Implement label filtering
Browse files Browse the repository at this point in the history
Signed-off-by: MOZGIII <mike-n@narod.ru>
  • Loading branch information
MOZGIII committed Sep 15, 2020
1 parent 67d471b commit 7503b77
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{event::Metric, Event};
use metrics::{Key, Recorder};
use metrics_tracing_context::TracingContextLayer;
use metrics::{Key, Label, Recorder};
use metrics_tracing_context::{LabelFilter, TracingContextLayer};
use metrics_util::layers::Layer;
use metrics_util::{CompositeKey, Handle, MetricKind, Registry};
use once_cell::sync::OnceCell;
Expand Down Expand Up @@ -81,6 +81,15 @@ impl Recorder for VectorRecorder {
}
}

#[derive(Debug, Clone)]
struct ComponentNameFilter;

impl LabelFilter for ComponentNameFilter {
fn should_include_label(&self, label: &Label) -> bool {
label.name() == "component_name"
}
}

/// Controller allows capturing metric snapshots.
pub struct Controller {
registry: Arc<Registry<CompositeKey, Handle>>,
Expand Down

0 comments on commit 7503b77

Please sign in to comment.