Configure breakers metrics in Vets API for external services
Last Updated:
Breakers is a Ruby gem that utilizes the circuit breaker pattern and integrates with Faraday middleware to manage service interactions, allowing metrics collected by Breakers to be displayed in Datadog via StatsD. This page provides steps to collect the metrics for your external service and surface them in a Datadog dashboard.
Configure external services in Vets-API
These steps use VAProfile::AddressValidation
Service as an example.
Determine which configuration (
configuration VAProfile::AddressValidation::Configuration
, for example) your service is using and add it to config/initializers/breakers.rb.Add the appropriate
STATSD_KEY_PREFIX
variable above your service’s configuration definition. See example:- RUBY
STATSD_KEY_PREFIX = "#{VAProfile::Service::STATSD_KEY_PREFIX}.address_validation".freeze configuration VAProfile::AddressValidation::Configuration
Note: In the case of our example, the
STATSD_KEY_PREFIX
value utilizes VAProfile’sservice.rb
, which in turn calls VAProfile’s stats.rb—the latter handles the incrementation of metrics. Your service’s setup may be different, so please adjust accordingly. For more examples showing how to increment metrics with StatsD, please check out this page.
Update your service class. Address Validation example.
Include
Common::Client::Concerns::Monitoring
in your service in order to make use of itswith_monitoring
method.Wrap your central method or methods in a
with_monitoring do
block.Example:
RUBYclass Service < VAProfile::Service include Common::Client::Concerns::Monitoring STATSD_KEY_PREFIX = "#{VAProfile::Service::STATSD_KEY_PREFIX}.address_validation".freeze configuration VAProfile::AddressValidation::Configuration ... def address_suggestions(address) with_monitoring do candidate_res = candidate(address) AddressSuggestionsResponse.new(candidate_res) end end
Once your PR is reviewed, merged, and deployed, metrics will eventually populate in Datadog, though depending on traffic, this may take some time.
Surfacing breakers metrics in Datadog dashboards
Once your service has been configured using the steps above, it can take hours or more than a day for all of its metrics to surface in Datadog. A metric won’t populate until it starts receiving traffic. For example, if your newly-configured service has not yet experienced a failure, its “failed” metric will remain unsearchable until at least one failure is logged.
Is your metric showing up yet?
Using the left-side menu, click on Metrics > Summary.
Use the Search box at the top of the page to search for your specific service, e.g.
VAProfile_AddressValidation
The search results show the types of metrics currently available for your service, which may include “success”, “failed”, and “median”, among others.
If the desired metric shows up, it’s available to add to a dashboard.
Add metrics to your dashboard
Assuming your dashboard is already created, navigate to it by clicking Dashboards from the left-side menu and entering its name in the Search box.
Once on your dashboard, add a new widget to it by clicking the plus sign in the large lavender box entitled, “Add Widgets or Powerpacks”.
Click the Timeseries Widget from the right-side menu that appears.
In the popup modal, under “Graph Your Data”, enter your service, e.g.
VAProfile_AddressValidation
The dropdown from the search box shows available metrics associated with the service. Click the appropriate one.
Give your graph a title.
Click “Save”.
Help and feedback
Get help from the Platform Support Team in Slack.
Submit a feature idea to the Platform.