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

Metrics documentation update #171

Merged
merged 8 commits into from
Jun 17, 2020
Merged

Metrics documentation update #171

merged 8 commits into from
Jun 17, 2020

Conversation

michalwski
Copy link
Contributor

This PR is primarily about metrics documentation update. It also contains the following changes which may be extracted to separate PR based on review comments.

  • Start the MongoosePush.Metrics.TelemetryMetrics child befor others to captuer events at startup
  • Short metrics documentation in the code
  • Add example Prometheus config for MongoosePush and docker-compose file to help with a basic setup.

Assuming that MongoosePush was started with the following command:

    MIX_ENV=integration mix do test.env.up

You can start Prometheus configured to monitor MongoosePush in container
executing the command below:

    docker-compose -f test/docker/docker-compose.prometheus.yml up -d
This is to capture some of the events emitted when APNS or FCM services start
Copy link
Contributor

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

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

Fantastic!

The only thing I'd say is that MPush docs, i.e., a single README, is getting out of control with the size, but reorganising that is on a different task 🙂

Oh, and some articles were missing 😛

lib/mongoose_push/metrics/telemetry_metrics.ex Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
children =
service_children() ++ [MongoosePushWeb.Endpoint, MongoosePush.Metrics.TelemetryMetrics]
[MongoosePush.Metrics.TelemetryMetrics] ++ service_children() ++ [MongoosePushWeb.Endpoint]
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch 🙂

lib/mongoose_push/metrics/telemetry_metrics.ex Outdated Show resolved Hide resolved
Copy link
Contributor

@kmakiela kmakiela left a comment

Choose a reason for hiding this comment

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

Great update! However, reading through 600 lines of readme is a bit much so that may be something we want to change in the near future.

README.md Outdated

* `mongoose_push_supervisor_init_count{service=${SERVICE}}` - Counts number of push notification service supervisor starts.
The `SERVICE` variable can take `"apns"` or `"fcm"` as a value.
This metrics is update when MongoosePush starts or later when the underlying supervision tree is terminated and the error is propagate to the main application supervisor.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This metrics is update when MongoosePush starts or later when the underlying supervision tree is terminated and the error is propagate to the main application supervisor.
This metric is updated when MongoosePush starts or later when the underlying supervision tree is terminated and the error is propagated to the main application supervisor.

@@ -1,5 +1,5 @@
# This file needs to be used along with `docker-compose.mocks.yml`:
# docker-compose -f test/docker/docker-compose.mocks.yml -f test/docker/docker-compose.mpush.yml ...
# PRIV=priv docker-compose -f test/docker/docker-compose.mocks.yml -f test/docker/docker-compose.mpush.yml ...
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docker-compose-mpush.yml requires the PRIV env var. It's set for us when we do mix text.env.up but when running from console we need to export it manually.

@michalwski
Copy link
Contributor Author

@NelsonVides @kmakiela thanks for the review. I 100% agree with the documentation split/refactoring. This is definitely a subject for a separate PR.

Copy link
Contributor

@janciesla8818 janciesla8818 left a comment

Choose a reason for hiding this comment

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

Good stuff! I really like the PR, we just need to make sure that the part regarding less or equal is accurate as it can be a bit confusing.

README.md Outdated
* `LE` defines the `less or equal` values for buckets, currently `1000`, `10_000`, `25_000`, `50_000`, `100_000`, `250_000`, `500_000`, `1000_000` or `+Inf`

> **NOTE**
> A mesurment of value 50_000 will be added to all buckets which are less or equal to 50_000.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if I understand this right, I think this is the other way around. The bucket contains measurements that are less or equal to the bucket size.

More particularly they're counters which form a cumulative histogram, le stands for less than or equal to. So 26688 requests took less than or equal to 200ms, 27760 requests took less than or equal to 400ms, and there were 28860 requests in total.
https://www.robustperception.io/how-does-a-prometheus-histogram-work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I messed with that. Good catch!

README.md Outdated
```

The above command assumes that MongoosePush runs on `localhost` and listens on port `8443`.
Please, mind the `HTTPS` protocol, metrics are hosted on the same port as other API.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Please, mind the `HTTPS` protocol, metrics are hosted on the same port as other API.
Please, mind the `HTTPS` protocol, metrics are hosted on the same port as other API endpoints.

How about this as compromise?
the same as seems more grammatically correct than the same than

lib/mongoose_push/metrics/telemetry_metrics.ex Outdated Show resolved Hide resolved
Comment on lines 36 to 37
Telemetry.Metrics.counter(
"mongoose_push.apns.state.get_default_topic.count",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Telemetry.Metrics.counter(
"mongoose_push.apns.state.get_default_topic.count",
Telemetry.Metrics.counter("mongoose_push.apns.state.get_default_topic.count",

just for consistency with the remaining events.

@michalwski
Copy link
Contributor Author

@janciesla8818 thanks for the review. I think I applied all the comments now.

Co-authored-by: Nelson Vides <nelson.vides@erlang-solutions.com>
@NelsonVides NelsonVides merged commit e4caac2 into master Jun 17, 2020
@NelsonVides NelsonVides deleted the mp/metrics-doc-update branch June 17, 2020 10:21
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.

4 participants