-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #863 from appsignal/delta-metrics
Store delta gauge of allocated objects in Ruby
- Loading branch information
Showing
6 changed files
with
76 additions
and
33 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.changesets/report-gauge-delta-value-for-allocated-objects.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
bump: "patch" | ||
type: "change" | ||
--- | ||
|
||
Report gauge delta value for allocated objects. This reports a more user friendly metric we can graph with a more stable continuous value in apps with stable memory allocation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module Appsignal | ||
module Probes | ||
module Helpers | ||
private | ||
|
||
def gauge_delta_cache | ||
@gauge_delta_cache ||= {} | ||
end | ||
|
||
# Calculate the delta of two values for a gauge metric | ||
# | ||
# First call will store the data for the metric in the cache and the | ||
# second call will return the delta of the gauge metric. This is used for | ||
# absolute counter values which we want to track as gauges. | ||
# | ||
# @example | ||
# gauge_delta :my_cache_key, 10 | ||
# gauge_delta :my_cache_key, 15 | ||
# # Returns a value of `5` | ||
def gauge_delta(cache_key, value) | ||
previous_value = gauge_delta_cache[cache_key] | ||
gauge_delta_cache[cache_key] = value | ||
return unless previous_value | ||
|
||
value - previous_value | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters