autometrics-dev / autometrics-py

Easily add metrics to your code that actually help you spot and debug issues in production. Built on Prometheus and OpenTelemetry.
https://autometrics.dev
Apache License 2.0
214 stars 7 forks source link

Add ok/error logic to the decorator #79

Closed flenter closed 1 year ago

flenter commented 1 year ago

And also switch to mypy (instead of pyright). There's an issue with pyright and the return value for coroutines (https://github.com/microsoft/pyright/issues/5745) which caused problems for our library and I also ran into issues when overloading the decorator and pyright not complaining about certain overloads which would never be used because other overloads were more generic/broadly defined).

Anyway the real meat of the matter is the addition of: record_error_if record_ok_if

Which allows the user of the lib to make certain exceptions not show up as errors and certain normal responses to register as errors.

Resolves https://github.com/autometrics-dev/autometrics-py/issues/45