Skip to content

Add histogram metrics#18

Draft
the-mikedavis wants to merge 2 commits into
rabbitmq:mainfrom
the-mikedavis:histogram
Draft

Add histogram metrics#18
the-mikedavis wants to merge 2 commits into
rabbitmq:mainfrom
the-mikedavis:histogram

Conversation

@the-mikedavis
Copy link
Copy Markdown
Contributor

This adds a osiris_histogram module adapted from the RabbitMQ message size histogram metrics. A histogram can be registered within a group with a custom set of buckets. Then callers record with observe/3.

This is spun out of rabbitmq/osiris#215.

Copy link
Copy Markdown
Contributor

@kjnilsson kjnilsson left a comment

Choose a reason for hiding this comment

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

a few comments on the API mostly

Comment thread src/seshat_histogram.erl Outdated
Labels = maps:get(labels, Opts, #{}),
Help = maps:get(help, Opts, ""),
%% Store in persistent_term for fast observe path
persistent_term:put({?MODULE, Group, Id},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont think we should do this for every histogram we want to create surely?

Comment thread src/seshat_histogram.erl Outdated

%% @doc Record an observation.
-spec observe(group(), id(), non_neg_integer()) -> ok.
observe(Group, Id, Value) when is_integer(Value), Value >= 0 ->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rather than relying on persistent terms we should expect callers to retain an opaque type with all the counters and stuff necessary to perform the observation. E.g. the main seshat API assumes local state and I dont think we want a completely different approach here.

Comment thread src/seshat_histogram.erl Outdated
%% A histogram metric type for seshat, backed by Erlang counters.
%% Histograms are registered in groups alongside regular counters
%% and can be exported via prom_format.
-module(seshat_histogram).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need a new and different module for this or can the API needed be added to seshat?

This adds a osiris_histogram module adapted from the RabbitMQ message
size histogram metrics. A histogram can be registered within a group
with a custom set of buckets. Then callers record with `observe/3`.
@the-mikedavis
Copy link
Copy Markdown
Contributor Author

Yeah I agree on the persistent term part. Better for seshat to expose the ref information you need and give you control over how to hold it.

I'm not sure which approach I like for the API better (seshat_histogram or put everything in seshat) so I made one commit with one and one commit with the other. What do you think?

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