Skip to content

[FLINK-4184] [metrics] Replace invalid characters in ScheduledDropwizardReporter#2220

Closed
tillrohrmann wants to merge 3 commits into
apache:masterfrom
tillrohrmann:fixDropwizardReporters
Closed

[FLINK-4184] [metrics] Replace invalid characters in ScheduledDropwizardReporter#2220
tillrohrmann wants to merge 3 commits into
apache:masterfrom
tillrohrmann:fixDropwizardReporters

Conversation

@tillrohrmann
Copy link
Copy Markdown
Contributor

The GraphiteReporter and GangliaReporter report metric names which can contain invalid
characters. These characters include quotes and dots. In order to properly report metrics
to these systems, the afore-mentioned characters have to be replaced in metric names.

The PR also removes quotes from the garbage collector metric name.

The PR sets the default value for TTL in the GangliaReporter to 1, because -1 causes the
reporter to fail.

R @zentol.

builder.append(replaceInvalidChars(componentName)).append(".");
}

builder.append(replaceInvalidChars(metricName));
Copy link
Copy Markdown
Contributor

@zentol zentol Jul 8, 2016

Choose a reason for hiding this comment

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

the call to replaceInvalidChars is not required; metric names can only contain alphanumeric characters. I don't think any reporter will not support these.

@zentol
Copy link
Copy Markdown
Contributor

zentol commented Jul 8, 2016

This PR will heavily conflict with #2219, in their current state we can't merge one without blocking the other.

@tillrohrmann
Copy link
Copy Markdown
Contributor Author

True, it conflicts with your proposed changes for the definable metric group delimiter. I will rebase and adapt this PR wrt #2219.

…ardReporter

The GraphiteReporter and GangliaReporter report metric names which can contain invalid
characters. These characters include quotes and dots. In order to properly report metrics
to these systems, the afore-mentioned characters have to be replaced in metric names.

The PR also removes quotes from the garbage collector metric name.

The PR sets the default value for TTL in the GangliaReporter to 1, because -1 causes the
reporter to fail.
…c name out

The character filter is applied to all components of the fully qualified metric name.
The ScheduledDropwizardReporter and AbstractReporter implement this interface to generate
compatible metric names.
@tillrohrmann tillrohrmann force-pushed the fixDropwizardReporters branch from d639114 to 8387528 Compare July 13, 2016 14:54
@tillrohrmann
Copy link
Copy Markdown
Contributor Author

I rebased on the latest master and introduced a CharacterFilter interface. The CharacterFilter allows to filter out invalid characters while generating the fully qualified metric name.

In order to do this, the AbstractMetricGroup#generateMetricName takes a CharacterFilter as argument. The AbstractReporter and the ScheduledDropwizardReporter implement this interface to filter out reporter specific characters.

if (scopeString == null) {
scopeString = ScopeFormat.concat(registry.getDelimiter(), scopeComponents);
if (filter != null) {
scopeString = ScopeFormat.concat(registry.getDelimiter(), scopeComponents);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if no filter is given we will now never assign to scopeString, breaking all names. We should assume that no filtering is required.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

True, this is wrong. Fill fix it.

@zentol
Copy link
Copy Markdown
Contributor

zentol commented Jul 14, 2016

do we have a test that verifies that reporters properly pass their filter when notified of new metrics?

* {@code "host-7.taskmanager-2.window_word_count.my-mapper.metricName"}
*
* @param metricName metric name
* @param filter character filter which is applied to the fully qualified metric name
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is misleading; it is not applied to the fully qualified name (as delimiter's are not filtered)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will adapt the comment

…eck that reporters filter out invalid characters
@tillrohrmann
Copy link
Copy Markdown
Contributor Author

Thanks for the review @zentol. I've addressed your comments and added test cases which verify that the corresponding MetricReporters filter out invalid characters in the fully qualified metric name.

// Getters
// ------------------------------------------------------------------------

// used for testing purposes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we move this into the TestingScheduledDropwizardReporter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can, if we mark the counters, gauges and histograms fields as protected. But then we would expose the implementation details to all sub-classes instead of having a getter which is package private. I think the latter option is a bit nicer, because it hides the implementation details.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You could also access the protected registry and get the counters from there.

We may not even need the gauges/counters/histograms fields in the ScheduledDropwizardReporter.

@zentol
Copy link
Copy Markdown
Contributor

zentol commented Jul 14, 2016

only one comment left, otherwise +1

@tillrohrmann
Copy link
Copy Markdown
Contributor Author

Thanks for the review @zentol. Will be merging this PR then.

@asfgit asfgit closed this in 70094a1 Jul 15, 2016
@zentol
Copy link
Copy Markdown
Contributor

zentol commented Jul 15, 2016

I would appreciate it if you would give me time to answer to your response before going ahead with a merge.

@tillrohrmann tillrohrmann deleted the fixDropwizardReporters branch August 19, 2016 12:13
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.

3 participants