-
Notifications
You must be signed in to change notification settings - Fork 2
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
Chose producer_cls globally and for each producer #38
Comments
Hi, This is how i understood the issue, please tell if I misinterpreted. Wouldn't this solve your problem? app = FastKafka(...)
@app.produces()
async def to_prometheus_metrics(metrics: Metrics) -> MetricsDataFormat:
return MetricsDataFormat(metrics=metrics)
prometheus_pusher(metrics=[metrics.metric_factory.get_metrics()], job=pod_name)(
metrics.calculate(to_prometheus_metrics)
) |
My goal is to decorate AIOKafkaProducer.send & AIOKafkaProducer.send_batch methods, so
With that producer all "send" calls will push metrics. Can you please explain a little deeper, how provided above solution will solve my problem? |
My mistake, I think I understand now, So, the prometheus_pusher and metrics decorators collect and push metrics from the producing calls. Is there a particular reason why you don't decorate the producing functions instead of send and send_batch? Something like this: @app.produces()
@prometheus_pusher(metrics=[metrics.metric_factory.get_metrics()], job=pod_name)
@metrics.calculate
async def to_some_topic(...) -> ...:
... And about the global producer: I guess that you want to have a global producer to collect the metrics for all the messages being sent, no matter the topic? When we started with the implementation, we had an option to pass the producer object to the produces decorator, so you can pass your own custom producer (or a global one if that would be the case), we could plan for the reintroduction of that feature in the next sprints if that would solve your problem more elegantly |
Sorry for late answer( We are collecting metrics, including Summary. Summary measures time, required to execute function.
mb if decorators are placed that way, we'll summarize time to execute producer's functionality instead of lambda x: x? =) |
I'd like to use something like this:
as producer for whole application by default or with chosen producers.
For now, monkeypatch is an option, but I'd thank much for more flexible solution.
The text was updated successfully, but these errors were encountered: