sentry-prometheus-exporter icon indicating copy to clipboard operation
sentry-prometheus-exporter copied to clipboard

Fix no issue if project has no env

Open quangpham7 opened this issue 3 years ago • 4 comments

Description

Fix exporter expose no issue if project has no environment.

In Sentry there are a few projects which have no environment. sentry-prometheus-exporter didn't get sentry_open_issue_events metric for these project. So I added a MR to fix that.

quangpham7 avatar Aug 16 '21 16:08 quangpham7

Hey @quangpham7, first of all, thanks for contributing! Could you please elaborate more about the issue and changes you're proposing here?

Also, I saw that there are several code format changes on files, could you please review the lint workflow and reformat your code according to the black params?

italux avatar Aug 16 '21 17:08 italux

Thanks @italux .

quangpham7 avatar Aug 17 '21 07:08 quangpham7

Thanks @italux .

@quangpham7 I have some projects without environments and I'm trying to reproduce the issue you've mention but I wasn't able to. Are you running the Sentry saas version or hosted? There some exception, if yes, could please paste here?

italux avatar Oct 11 '21 17:10 italux

@quangpham7 while testing your fix I face a new issue as we can see below. I still investigating, but I can't find the source yet

2021-10-18 19:28:05,763 - 88563 - ERROR - exporter - Exception on /metrics/ [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2070, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1515, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1513, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1499, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "exporter.py", line 61, in sentry_exporter
    REGISTRY.register(SentryCollector(sentry, ORG_SLUG, get_metric_config(), PROJECTS_SLUG))
  File "/usr/local/lib/python3.7/site-packages/prometheus_client/registry.py", line 26, in register
    names = self._get_names(collector)
  File "/usr/local/lib/python3.7/site-packages/prometheus_client/registry.py", line 66, in _get_names
    for metric in desc_func():
  File "/Users/italo.santos/github/sentry-prometheus-exporter/helpers/prometheus.py", line 262, in collect
    events_24h += int(issue.get("count") or 0)
AttributeError: 'str' object has no attribute 'get'

italux avatar Nov 02 '21 19:11 italux