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

Document that MeterFilters are expected to be static #5809

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/modules/ROOT/pages/concepts/meter-filters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ new MeterFilter() {

This filter adds a name prefix and an additional tag conditionally to meters starting with a name of `test`.

[IMPORTANT]
.`MeterFilter` implementations of `map` should be "static"
====
The `id` parameter is the only dynamic input that changes over the lifecycle of the `MeterFilter` on which they should depend.
Use cases where dynamic behavior is desired, such as defining tags based on the context of a request etc., should be implemented in the instrumentation itself rather than in a `MeterFilter`.
For example, see `MongoMetricsCommandListener` and the `MongoCommandTagsProvider` it takes in a constructor argument as well as the default implementation `DefaultMongoCommandTagsProvider`.
See also xref:../observation/components.adoc#micrometer-observation-predicates-filters[ObservationFilter] which allows dynamic implementations.
====

=== Convenience Methods

`MeterFilter` provides convenience builders for many common transformation cases:

* `commonTags(Iterable<Tag>)`: Adds a set of tags to all metrics. Adding common tags for application name, host, region, and others is a highly recommended practice.
Expand Down
Loading