Skip to content
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

Prometheus metrics #1498

Merged
merged 3 commits into from
Aug 28, 2019
Merged

Prometheus metrics #1498

merged 3 commits into from
Aug 28, 2019

Conversation

devduarte
Copy link
Contributor

Changes and files for #1472

@devduarte devduarte added this to the 0.23.0 milestone Aug 20, 2019
@waj waj changed the title Prometheus metrics, first commit. Prometheus metrics Aug 20, 2019
@waj waj removed this from the 0.23.0 milestone Aug 20, 2019
Copy link
Contributor

@waj waj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I'd move some calls to increment counters as soon as possible within the functions to capture the metrics despite runtime errors

|> Nuntium.Client.send_ao(channel.settings["nuntium_account"], messages)

SurvedaMetrics.increment_counter_with_label(:surveda_nuntium_enqueue, [elem(response, 0)])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will label the status with "ok" or "error" instead of the HTTP status code from Nuntium

{:ok, %{"state" => "expired"}} -> false
{:ok, %{"state" => _}} -> true
{:ok, %{"state" => _}} ->
SurvedaMetrics.increment_counter_with_label(:surveda_verboice_enqueue, [elem(response, 0)])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not where a call is enqueued in Verboice. Move this to the setup function.

alias Ask.Repo

def collect_mf(_registry, callback) do
respondent_stats_query = "select rs.* from respondent_stats rs"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use RespondentStats model?

|> Enum.zip(row)
|> Enum.into([])
end)
callback.(create_gauge(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not generating the gauge with the right shape. The count value from the table should be used as the value for each set of labels.

Also I'd not "reflect" on the columns. The mode column currently stores a JSON with an array of strings. Let's convert that into a comma separated string for the mode label in the gauge.

Prometheus.Model.create_mf(name, help, :gauge, __MODULE__, data)
end

defp formatRow(row) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use camel case

…e RespondentStats model and correct formatting of metrics, moved verboice and nuntium enqueue metrics to each client accordingly to get the request status code
@waj waj merged commit d84d23e into master Aug 28, 2019
@waj waj deleted the feature/1472_metrics_prometheus branch August 28, 2019 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants