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

per metric dimensions #24

Merged
merged 3 commits into from
Jun 20, 2019
Merged

Conversation

jebl01
Copy link
Contributor

@jebl01 jebl01 commented Jun 18, 2019

This PR makes it possible to provide dimensions per metric. Typically by doing something like this;

final DimensionedName dimensionedName = DimensionedName.withName("test")
        .withDimension("key1", "val1")
        .withDimension("key2", "val2")
        .withDimension("key3", "val3")
        .build();

metricRegistry.counter(dimensionedName.encode()).inc();

Sadly AWS doesn't support aggregating custom metrics on dimensions (yet?), so the usefulness is more or less limited to improved search and filtering in the CloudWatch console for now...

Related to: #19

metricRegistry.counter(new DimensionedNameBuilder(ARBITRARY_COUNTER_NAME)
.addDimension(new Dimension().withName("key1").withValue("value1"))
.addDimension(new Dimension().withName("key2").withValue("value2"))
.build().encode()).inc();
Copy link
Owner

Choose a reason for hiding this comment

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

Can the .encode() be called as part of .build()? Is there a use case where we would build a DimensionedName without encoding it? Also, a requirement to invoke the .encode() explicitly may open a door to errors where a client code may forget to call the API.

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can always do: String myMetricName = dimensioned.encode() and then use that one over and over.

Anyhow, I have done some refactoring, and also made the API a bit easier to use... might also give a reason to keep this as it is :-)

@azagniotov azagniotov merged commit b703417 into azagniotov:master Jun 20, 2019
@jebl01 jebl01 deleted the custom-metric-dimensions branch June 25, 2019 08:27
@azagniotov
Copy link
Owner

Hi @jebl01, I released a new version

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