Hridya
Hridya

Reputation: 244

Track the total amount of API requests in Grape

I have a set of grape APIs which run on Rack.

Is there any way to get total amount of API requests after the server start?

Is there any other way how API request count can be tracked?

Upvotes: 1

Views: 499

Answers (1)

Yury Lebedev
Yury Lebedev

Reputation: 4015

You can use statsd-ruby library together with statsd.

You would just need to call statsd.increment with the counter name in the before_action on your ApplicationController.

There are many backends for statsd, which aggregate the data. The easiest way would be to use some service, like datadog.

Upvotes: 3

Related Questions