Skip to content

Commit 5d8a44d

Browse files
authored
Naming guide improvements for metrics (elastic#139686)
1 parent 876b250 commit 5d8a44d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

modules/apm/NAMING.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Follow with a module name, team or area of code, e.g. `snapshot, repositories, i
3232
The **hierarchy** of segments should be built by putting "more common" segments at the beginning. This facilitates the creation of new metrics under a common namespace.
3333
Each element in the metric name specializes or describes the prefix that precedes it. Rule of thumb: you could truncate the name at any segment, and what you're left with is something that makes sense by itself.
3434

35-
Example: Prefer `.docs.deleted.total` over `.deleted.docs.total` so `.docs.ingested.total` could be added later.
35+
Example: Prefer `es.indices.docs.deleted.total` over `es.indices.deleted.docs.total` so `es.indices.docs.ingested.total` could be added later.
36+
37+
**Note, to better highlight key differences, examples below starting with `.` omit the `es.` prefix and initial segments.**
3638

3739
Recommendations:
3840
- When adding new metrics, [look for existing segments](#inspect-registered-metrics) as prefix in your domain. Also keep language consistent across the hierarchy, re-using segment names / terminology when possible.
@@ -44,7 +46,7 @@ E.g. stick to using `.error.total` if already in use rather than introducing `.f
4446
### Name suffix
4547

4648
The metric suffix is essential to describe the semantics of a metric and guide consumers on how to interpret and use a metric appropriately.
47-
If multiple suffixes are applicable, chose the most specific one.
49+
If multiple suffixes are applicable, choose the most specific one.
4850

4951
* `total`: a monotonic metric (always increasing counter), e.g. <code>es.indices.docs.deleted.<strong>total</strong></code>)
5052
* Note: such metrics typically report deltas that must be accumulated to get the total over a time window
@@ -72,7 +74,7 @@ Units are configured at registration time of the metric.
7274

7375
**WARNING** Do not use **high cardinality** attributes / dimensions. This might result in the APM Java agent dropping events.
7476

75-
It is not always straight forward to decide if something should part of the metric name or an attribute (dimension) of that metric. As a rule of thumb:
77+
It is not always straight forward to decide if something should be part of the metric name or an attribute (dimension) of that metric. As a rule of thumb:
7678
- any aggregation across any dimensions of a metric should be meaningful, and
7779
- meaningful aggregations should be possible without having to aggregate over different metrics.
7880

@@ -92,7 +94,9 @@ es(_<segment>)+
9294
- The name may not exceed 255 characters.
9395

9496
Attributes that represent an entity should be named in singular.
95-
If the attribute value represents a collection, it should be named in plural.
97+
If the attribute value represents a collection, it should be named in plural, e.g.
98+
- `es_security_realm_type`: singular, a single entity
99+
- `es_rest_request_headers`: plural, a collection of headers
96100

97101
### Migration of existing, invalid attributes
98102

0 commit comments

Comments
 (0)