Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated timeseries in CollectorRegistry #3

Closed
turque opened this issue Oct 7, 2020 · 7 comments
Closed

Duplicated timeseries in CollectorRegistry #3

turque opened this issue Oct 7, 2020 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@turque
Copy link

turque commented Oct 7, 2020

Dears,

I'm having difficulties using this module with pytest.

I split my pytest in multiples files for better organization.

Using flask-prometheus-metrics i d'nt have test problem whit, but whit this flask_monitor only first test file pass whit successful and the others fail

`self = <prometheus_client.registry.CollectorRegistry object at 0x7fe30a7c8220>, collector = prometheus_client.metrics.Histogram(request_seconds)

def register(self, collector):
    """Add a collector to the registry."""
    with self._lock:
        names = self._get_names(collector)
        duplicates = set(self._names_to_collectors).intersection(names)
        if duplicates:
          raise ValueError(
                'Duplicated timeseries in CollectorRegistry: {0}'.format(
                    duplicates))

E ValueError: Duplicated timeseries in CollectorRegistry: {'request_seconds_bucket', 'request_seconds_created', 'request_seconds_count', 'request_seconds_sum'}

env/lib/python3.8/site-packages/prometheus_client/registry.py:29: ValueError
`

if i merge all test-files the test pass whit successful.

Do you have ideia about this problem?

@KarineValenca
Copy link
Collaborator

@gutorc92

@gutorc92
Copy link
Member

gutorc92 commented Oct 8, 2020

@turque, It is happen because every thread try to register the metrics and collectors do not accept it. I'm working in a fix to it.

@eabili0 eabili0 added the bug Something isn't working label Oct 8, 2020
@Ziul
Copy link
Member

Ziul commented Nov 11, 2020

@turque could you please check if v0.0.2 solved your issue?

@turque
Copy link
Author

turque commented Nov 13, 2020

@Ziul I tested it and the duplicated error did not occur but it's not generating metrics

They apscheduler dependency don't install automatically, we need install manually.

@Ziul
Copy link
Member

Ziul commented Nov 16, 2020

@turque looks like you’re having some issues with the registry. In v0.0.2 we did some changes to avoid the use of a custom registry. If you are using a custom registry yet, check this test where the /metrics route is customized to use a custom registry. If you are using a single Flask instance for those multiples files, the registry instance is being stored in app.extensions["registry"].

If yet the issues continue, please share some of your tests here, so we can help you.

@eabili0 eabili0 assigned Ziul and unassigned gutorc92 Nov 16, 2020
@turque
Copy link
Author

turque commented Nov 24, 2020

@Ziul i used custom registry like this test and it worked.
I will take more tests and reopen this issue if necessary.

One point, the apscheduler dependency don't install automatically, we need install manually, it's necessary to bb-flask-monitor version 0.0.2

@turque turque closed this as completed Nov 24, 2020
@Ziul
Copy link
Member

Ziul commented Nov 24, 2020

Missing dependency included in version 0.0.3. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants