Skip to content
This repository has been archived by the owner on Oct 22, 2019. It is now read-only.

Labels are creating duplicated metrics #74

Closed
kekko1212 opened this issue Apr 9, 2018 · 1 comment
Closed

Labels are creating duplicated metrics #74

kekko1212 opened this issue Apr 9, 2018 · 1 comment

Comments

@kekko1212
Copy link

kekko1212 commented Apr 9, 2018

I noticed that registering 2 different countrers (different namespaces and names) with 2 different labels creates a weird situation where metrics are messed up.

Here's how I register the 2 counters:

Counter 1

$counter = $this->metricsClient->getOrRegisterCounter(
    'oosm',
    'successful_login_total',
    'Total of successful login',
    ['role']
);

$roles = $event->getUser()->getRoles();
foreach ($roles as $role) {
    $counter->inc([$role]);
}

Counter 2

$counter = $this->metricsClient->getOrRegisterCounter(
    'oosm',
    'location_put_offline_total',
    'Total of location put offline',
    ['location_name']
);
$counter->inc([$event->getLocationName()]);

When I hit both this counters, the metric endpoint is returning:

# HELP oosm_location_put_offline_total Total of location put offline 
# TYPE oosm_location_put_offline_total counter 
oosm_location_put_offline_total{location_name="Springfield Avenue"} 1    <---- Ok

# HELP oosm_successful_login_total Total of successful login
# TYPE oosm_successful_login_total counter 

oosm_location_put_offline_total{role="Springfield Avenue"} 1    <---- This is wrong!
oosm_successful_login_total{role="ADMINISTRATOR"} 2    <---- Ok

Could be related to: #34 ?

PHP version: 7.1.13

@kekko1212
Copy link
Author

I found the issue, it was on the wrapper I wrote for the library. Sorry.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant