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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add metrics #2
Comments
Do you want the transfered data metric just for a few specific endpoints or all endpoints transparently? Option 1: Instrument the specific endpoints manually by directly using the Prometheus library. Option 2: Not supported. I could put it on my bucket list. Though I'm not sure if I would hardcode the new metrics or do something like @rycus86 has done in his package for instrumenting Flask apps https://github.com/rycus86/prometheus_flask_exporter. And thanks |
Thanks for the quick answer!
Depends! It was just an example 馃檪 Could be both. Oh yes, it seems So I would say: don't hardcode it! Instead, provide a way for users to add their own custom, exported metrics. |
@pawamoy you can now select from a few already existing instrumentations or add your own. Check the updated Recording size of requests / responses: instrumentator.add(
metrics.request_size(
should_include_handler=False,
should_include_method=False,
should_include_status=False,
)
).add(
metrics.response_size(
should_include_handler=False,
should_include_method=False,
should_include_status=False,
)
) Or creating your own: def http_requested_languages_total() -> Callable[[Info], None]:
METRIC = Counter(
"http_requested_languages_total",
"Number of times a certain language has been requested.",
labelnames=("langs",)
)
def instrumentation(info: Info) -> None:
langs = set()
lang_str = info.request.headers["Accept-Language"]
for element in lang_str.split(",")
element = element.split(";")[0].strip().lower()
langs.add(element)
for language in langs:
METRIC.labels(language).inc()
return instrumentation
instrumentator.add(http_requested_languages_total()) |
Hello! Thanks for the projet 馃檪
I read the README and I'm left wondering how I can add metrics to the already defined ones. Is this even possible yet? For example, I'd like to add the average transfered data size per request/response. How would I add this into the instrumentator?
The text was updated successfully, but these errors were encountered: