Skip to content

Panic when used with tests #60

@Karrq

Description

@Karrq

When running an instrumented application's test suite I'm getting errors like the following:

Failed to overwrite metric overlay_outbound_transit_seconds, Labels: 

This is probably because when running tests the metric initialization is also run in parallel, and since the registry used is the same across all there each test is attempting to override the same metric name.

Sample:

#[metrics(scope = "app")]
pub struct MyMetric {
   #[metric]
  pub my_metric: Counter,
}

#[test]
fn foo() {
   let metrics = MyMetric::default();

   ...
}

#[test]
fn bar() {
   let metrics = MyMetric::default();

   ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions