Hi,
during the work I've been doing lately on #5607 I've noticed a few patterns that might DRY'ed somehow in order to provide:
I'm sure as far as we get into adding more metrics to filters and outputs we will encounter patterns that might makes sense to uniform.
For this I started creating a namespaced metric, @metric_errors = metric.namespace(:errors) that later on is used to track error situations like exceptions, for example. This makes all error situation be namespaced.
example:

Style guide proposal:
snake_cased.name_unit where name is the name of the metric and unit is the unit of measurement. For example, "duration_millis" or "read_bytes".count unit. Using "event" as an example, where we would describe 'count of event' we should use the plural eventsconnection_errors -- we can ask "What kind of errors? Connection errors", then we can create an errors namespace with connections in it.errors namespace contains metrics for errors.{ "errors": { "connections": 5 } is better than { "connections": { "errors": 5 } }@jordansissel excellent writes up, I will finish the review of the PR and update this issue also.
I think we should name this as best practices, even if some of theses check could be done in the code. I think we shouldn't do it, since we want metric to be fast.
agreed, my though my preference is to call it a style guide, not best practices
What are others' thoughts on this style guide I proposed a few comments above?
+1. Looks good
@jordansissel thanks for your feedback, will update the current PR's following your advices. I'm not sure about the naming you propose, but I guess I'm good with it, basic idea for me was to extrapolate similar patterns for all to follow, so I guess naming is ok 馃樃 .
@ph what do you mean by
even if some of theses check could be done in the code
? curious to know more what you are thinking here.
I've reread the plugins PR and I am +1 with your proposal @jordansissel.
even if some of theses check could be done in the code
We could add to the metric library normalization of keys and adding validation.
edited for typos.
Thanks for this @jordansissel.
This style guide looks like good material to include within a general "Adding and Collecting New Plugin Metrics" section in the docs.
@acchen97 ++. Target this for 5.0.0?
++ added to 5.0 docs meta issue (https://github.com/elastic/logstash/issues/5148) to track.
Most helpful comment
Style guide proposal:
snake_cased.name_unitwherenameis the name of the metric andunitis the unit of measurement. For example, "duration_millis" or "read_bytes".countunit. Using "event" as an example, where we would describe 'count of event' we should use the pluraleventsconnection_errors-- we can ask "What kind of errors? Connection errors", then we can create anerrorsnamespace withconnectionsin it.errorsnamespace contains metrics for errors.{ "errors": { "connections": 5 }is better than{ "connections": { "errors": 5 } }