-
Notifications
You must be signed in to change notification settings - Fork 155
Add PrometheusMetricsFactory #142
Add PrometheusMetricsFactory #142
Conversation
Signed-off-by: Eundoo Song <eundoo.song@gmail.com>
@yurishkuro @pytest.mark.skipif('prometheus_client' not in sys.modules,
reason="requires prometheus_client")
class TestPrometheusMetricsFactory:
def test_prometheus_metrics_counter(self):
.... But I can’t find any similar way(conditional skip) to do the same in pytest-cov. I have no idea how get the coverage passed in ci-testing. Alternatively, I prepared update-coveragerc.sh for adding a file path in “omit” when a library is not installed. If it looks good, I can merge this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall looks great. I just have a couple organizational questions:
- what benefits do you see in placing the new class in a subdirectory instead of, say,
jaeger_client/prometheus.py
? E.g.
from jaeger_client.prometheus import PrometheusMetricsFactory
- our main readme is not very large, I would add the Prometheus instructions there instead of hiding in a subdirectory (where it's much harder for people to find).
Why not always run them? prometheus_client can be declared as dev dependency, as we do with other modules like opentracing instrumentation or tchannel (https://github.com/jaegertracing/jaeger-client-python/blob/master/setup.py#L64) |
… setup.py Signed-off-by: Eundoo Song <eundoo.song@gmail.com>
Signed-off-by: Eundoo Song <eundoo.song@gmail.com>
Signed-off-by: Eundoo Song <eundoo.song@gmail.com>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think prometheus_metrics is somewhat not part of jaeger client, it's more like an optional plugin for metrics purpose. And probably there might be other metrics coming in the future too. So, I moved it to the subdirectory.
fair enough. I'd just ask you to DRY the naming, i.e
# instead of this
from jaeger_client.metrics_factory.prometheus_metrics import PrometheusMetricsFactory
# support this
from jaeger_client.metrics.prometheus import PrometheusMetricsFactory
README.md
Outdated
@@ -138,6 +138,21 @@ The B3 codec assumes it will receive lowercase HTTP headers, as this seems | |||
to be the standard in the popular frameworks like Flask and Django. | |||
Please make sure your framework does the same. | |||
|
|||
## Prometheus metrics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to move this to L83 as level-4 header, i.e. as a subsection of Configuration/Production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved
README.md
Outdated
config = Config( | ||
config={}, | ||
service_name='your-app-name', | ||
metrics_factory=PrometheusMetricsFactory(namespace=service_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe namespace='your-app-name'
for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add namespace='your-app-name'
Earlier, I named metrics as subdirectory, but naming conflict error came like below since metrics.py and metrics subdirectory existed in the same location. $ python example_prometheus.py
Traceback (most recent call last):
File "example_prometheus.py", line 3, in <module>
from jaeger_client import Config
File "/Users/eundusong/dev/opensource/jaeger/dev/jaeger-client-python/jaeger_client/__init__.py", line 26, in <module>
from .tracer import Tracer # noqa
File "/Users/eundusong/dev/opensource/jaeger/dev/jaeger-client-python/jaeger_client/tracer.py", line 33, in <module>
from .metrics import Metrics, LegacyMetricsFactory
ImportError: cannot import name Metrics |
rename prometheus_metrics.py to prometheus.py Signed-off-by: Eundoo Song <eundoo.song@gmail.com>
I see. I just put a PR #143 that moves metrics.py into a subdirectory. It looks like it's backwards compatible. Let's merge that first, then you can rebase and move your code to |
52a78c2
to
c0c5099
Compare
move test_prometheus.py to tests from test/metrics Signed-off-by: eundoo-song <eundoo.song@samsung.com>
@yurishkuro |
looks great. Thanks! |
As discussed in PR 129 with @yurishkuro, PrometheusMetricsFactory is ready for review.
Signed-off-by: Eundoo Song eundoo.song@gmail.com