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

Support Mp Metrics 5.1 MP Config properties for Histogram and Timer metrics #636

Merged

Conversation

Channyboy
Copy link
Contributor

@Channyboy Channyboy commented Aug 17, 2023

Fixe #665

Context the new MP Config properties for metrics v5.1 follow the following syntax:

<property>=<metric_name>=value[,value2,value3];<metric_name2>=value[,value2,value3]

^^ That is to say property is a semi-colon separated values that define the configuration for a specific metric name.

MericsConfigurationManger has getxxx() which returns an respective sub-class of PropertyConfiguration .
For example getPercentilesConfiguration(...) returns MetricPercentileConfiguration.

This is called as appropriate from the HistogramAdapter or TimerAdapter during registration as it needs this info to customize the metric.

During the getxxx(), it checks if MericsConfigurationManger contains an existing collection of configuration objects for the app name that is passed in in its respective Map<String, Collection<T extends PropertyConfiguration>>. The collection represents the configuration of the whole property (i.e. all metric names and its associative values). The *appname that is passed in is used to parse this collection for the specific metric name and value. This is done by calling a static method matches(Collection<T extends PropertyConfiguration> collection, String metricName) which accepts a metric name and the collection to go through.

If not, it will retrieve the MP Config property from the ConfigProvider and add to the respective Map<String, Collection<T extends PropertyConfiguration>>.

// .filter(s -> s.matches("[0-9]+[.]*[0-9]*"))
// .map(Double::parseDouble)
.map(s -> {
if (s.matches("[0-9]+[.]*[0-9]*")) {
Copy link

Choose a reason for hiding this comment

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

Do you intend to match a decimal point? Should the dot be escaped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the [ ] character set allows for matching explicitly the characters within it.


// metricGroup=<blank> == invalid
if (keyValueSplit.length == 2) {
if (keyValueSplit[1].matches(("[0-9]+[.]*[0-9]*"))) {
Copy link

Choose a reason for hiding this comment

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

Does the dot need escape?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the [ ] character set allows for matching explicitly the characters within it.


// metricGroup=<blank> == invalid
if (keyValueSplit.length == 2) {
if (keyValueSplit[1].matches(("[0-9]+[.]*[0-9]*"))) {
Copy link

Choose a reason for hiding this comment

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

Does the dot need escape?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the [ ] character set allows for matching explicitly the characters within it.

// Parse values of percentile - ensure value is 0 <= x <= 1.0
Double[] percentileValues = Arrays.asList(keyValueSplit[1].split(",")).stream().map(s -> {

if (s.matches("[0][.][0-9]+")) {
Copy link

Choose a reason for hiding this comment

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

Does the dot need escape?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the [ ] character set allows for matching explicitly the characters within it.

Copy link

@fmhwong fmhwong left a comment

Choose a reason for hiding this comment

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

Please see code comments.

@Channyboy Channyboy force-pushed the micrometer-histoTimer-properties branch from 3760eb1 to 607670c Compare August 18, 2023 15:19
Copy link

@fmhwong fmhwong left a comment

Choose a reason for hiding this comment

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

LGTM

@Channyboy Channyboy merged commit d10b053 into smallrye:micrometer Aug 18, 2023
3 checks passed
@Channyboy Channyboy added this to the 5.1 milestone Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants