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

Report Ruby VM probe metrics as gauges with a hostname tag #866

Merged
merged 3 commits into from
Jul 28, 2022

Conversation

tombruijn
Copy link
Member

Change all Ruby VM distributions to gauges

The problem the distribution values is that they will always be the same
because we report the metrics at very regular intervals, so the values
between mean, 90th percentile and 95 percentile won't be any different
as we've seen in the graphs these metrics create.

Refactor gauge calls to helper method in MRI probe

Call a private method that calls Appsignal.set_guage so that if we
want to change some defaults in metrics reported by this probe we only
have to do it in one place. Like adding a hostname tag.

Report hostname tag for Ruby VM probe metrics

The added hostname tag allows us to tell multiple hosts from each other
and graph them separately. If we do not, an app with multiple hosts
would have hosts overwrite one another's metrics. Only the last reported
value would be stored and shown.

I've copied some of the Sidekiq probe's and Puma plugin to determine the
hostname automatically and listen to the AppSignal config in case a
hostname was configured.

The problem the distribution values is that they will always be the same
because we report the metrics at very regular intervals, so the values
between mean, 90th percentile and 95 percentile won't be any different
as we've seen in the graphs these metrics create.
Call a private method that calls `Appsignal.set_guage` so that if we
want to change some defaults in metrics reported by this probe we only
have to do it in one place. Like adding a hostname tag.
The added hostname tag allows us to tell multiple hosts from each other
and graph them separately. If we do not, an app with multiple hosts
would have hosts overwrite one another's metrics. Only the last reported
value would be stored and shown.

I've copied some of the Sidekiq probe's and Puma plugin to determine the
hostname automatically and listen to the AppSignal config in case a
hostname was configured.
@tombruijn tombruijn added the bug label Jul 28, 2022
@tombruijn tombruijn self-assigned this Jul 28, 2022
tombruijn added a commit to appsignal/public_config that referenced this pull request Jul 28, 2022
We've noticed that distributions are not a good fit for this. For more
PR appsignal/appsignal-ruby#866 on the Ruby gem.
key, value, tags = distribution_value
next unless key == expected_key
next unless expected_value ? expected_value == value : !value.nil?
next unless tags == expected_tags
Copy link
Contributor

Choose a reason for hiding this comment

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

next unless ...? Shouldn't this be return false unless ...?

I suppose it doesn't make a difference -- next gives nil, which is falsy anyway. I've never seen it used this way before.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you call return the loop will exit and no other values will be checked. If you want it to exit out of that loop iteration with false you need to call next false if ... which is the same as next if ... for this because nil is falsy like you say.

@tombruijn tombruijn merged commit b422c72 into main Jul 28, 2022
@tombruijn tombruijn deleted the ruby-vm-metrics branch July 31, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants