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

Adds support for bean regex tagging #167

Merged
merged 5 commits into from
Mar 5, 2018
Merged

Conversation

nmuesch
Copy link
Contributor

@nmuesch nmuesch commented Mar 2, 2018

Adds support for using the bean_regex syntax to capture groups for tags.

We currently support pulling in common attributes out of bean names, but this introduces the ability to specify any custom substring of a bean name to utilize as a tag on the associated attributes.

Ex:

init_config:
  conf:
    - include:
	bean_regex: 'Catalina:type=(.*?),*host=(.*?),context=(.*),*'
        attribute:
          spareNotFoundEntries:
            metric_type: gauge
            alias: tomcat.spareNotFound
          cacheMaxSize:
            metric_type: gauge
            alias: tomcat.cacheMax
        tags:
             TypeRegex: $1
             HostRegex: $2
             contextRegex: $3
             optional: tag

This will submit the metric tomcat.spareNotFound with tags hostRegex:<beanParameter> ,TypeRegex:<beanParameter>, and contextRegex<beanParameter> as well as the tag with key optional and value tag

Copy link
Contributor

@gmmeyer gmmeyer left a comment

Choose a reason for hiding this comment

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

I have a single nit, but I think this looks like a pretty clean change.


if(m.matches()) {
for (int i = 0; i<= m.groupCount(); i++) {
this.beanParameters.put(""+i, m.group(i));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a stylistic issue, not a technical one. I don't love

""+i

I don't think it's very clear. I think it would be better to make it more clear:

Integer.toString(i)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, that is definitely cleaner. Thanks!

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