Skip to content

Conversation

@zentol
Copy link
Contributor

@zentol zentol commented Jun 12, 2017

This PR modifies the ScheduledDropwizardReporter to limit the size of every metric name component to 80 characters, with the same reasoning as #4109.

@greghogan
Copy link
Contributor

@zentol since this has not yet been reviewed I'll chance a question: is this needed in addition to #4109?

@zentol
Copy link
Contributor Author

zentol commented Jul 5, 2017

yes it is still required, but this PR does address a similar issue.

#4109 limits the size of the operator name in the metric identifier. This was a problem for all reporters, because a 200+ character name just isn't manageable.

This PR limits the size of all components of the metric identifier for DropwizardReporters, as the backends of several subclasses store metrics in files, with each component being one directory., like "taskmanager/abcde/job/myjob/task/mytask". Since they are used as names for directories they mustn't exceed a certain size (commonly 255). While technically a value close to 255 would suffice, i figure that anything above 80 characters isn't really well manageable as well.

@greghogan
Copy link
Contributor

What can cause such a long metric identifier? It seems risky to truncate the full identifier which could even completely remove the base name.

@zentol
Copy link
Contributor Author

zentol commented Jul 6, 2017

We don't truncate the full identifier, but each individual component before assembling the final identifier.

I.e. a.b.<reallyReallyLongSection>.c.d would become a.b.<notSoLongSection>.c.d.

The primary cause of this currently are the names of WindowOperators or long task chains; but given that the sections are partially controlled by the user there may be more cases.

@greghogan
Copy link
Contributor

That sounds reasonable. Can we add a warning as in #4109 and replace 80 with a constant (I see just now in TaskMetricGroup.java that 80 is hard-coded in the log string rather than using the constant)?

@zentol
Copy link
Contributor Author

zentol commented Jul 6, 2017

sure, i can do that.

@NicoK
Copy link
Contributor

NicoK commented Jul 6, 2017

just for clarification, a.b.<notSoLongSection>.c.d would then be stored in a/b/<notSoLongSection>/c/d so that each component/file/directory is not larger than 80?

@zentol
Copy link
Contributor Author

zentol commented Jul 6, 2017

@NicoK yes, that's how they would be stored in some backends.

@NicoK
Copy link
Contributor

NicoK commented Jul 10, 2017

@zentol then +1 after addressing @greghogan's comments (adding a warning + using a constant for the 80)

@zentol
Copy link
Contributor Author

zentol commented Jul 10, 2017

I've update the PR.

  • extended the change to cover the StatsDReporter
  • added the warning as requested
  • moved the limit into a configurable field
  • updated documentation
  • added tests

Copy link
Contributor

@NicoK NicoK left a comment

Choose a reason for hiding this comment

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

good changes + tests.
+1 after addressing some more comments

if (metricName.length() > maxComponentLength) {
log.warn("The metric name component {} exceeded the {} characters length limit and was truncated.", metricName, maxComponentLength);
}
final int strLen = Math.min(metricName.length(), maxComponentLength);
Copy link
Contributor

Choose a reason for hiding this comment

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

You actually don't need to call Math.min() anymore after you already checked the condition for the warning message. You could thus assign strLen yourself.

config.setProperty(StatsDReporter.ARG_MAX_COMPONENT_LENGTH, "10");

reporter.open(config);

Copy link
Contributor

Choose a reason for hiding this comment

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

...and the additional tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about the tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, seems something was lost during the transfer :(

iirc, I wanted to ask whether it makes sense to also test that things like a.b.0123456789DEADBEEF.c are properly truncated to a.b.0123456789.c for the whole metric name

if (input.length() > maxComponentLength) {
log.warn("The metric name component {} exceeded the {} characters length limit and was truncated.", input, maxComponentLength);
}
final int strLen = Math.min(input.length(), maxComponentLength);
Copy link
Contributor

Choose a reason for hiding this comment

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

same here about the Math.min

- `dmax` - hard limit for how long an old metric should be retained
- `ttl` - time-to-live for transmitted UDP packets
- `addressingMode` - UDP addressing mode to use (UNICAST/MULTICAST)
- `maxComponentLength` - limits the size of each scope component
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be described as the "length of the name of each scope component" rather than simply "size"? I'm not sure that it's immediately obvious what this parameter is limiting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"length of each scope component" would be better, I don't think we us "name of scope component" anywhere in the docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, works for me.

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.

4 participants