Hi,
We are enabling Dynatrace Register for micrometer.
Below is the output we get.
It seems like the URI is too long for the dimension accepted in Dynatrace.
Any suggested workarounds for this?
2020-11-05 14:02:09.920 lvl=ERROR : failed to send metrics to dynatrace:
{
"error": {
"code": 400,
"message": "Constraints violated.",
"constraintViolations": [
{
"path": "series[68].dimensions.uri",
"message": "Value exceeds maximum length.Maximum value length: 128 (inclusively).",
"parameterLocation": "PAYLOAD_BODY",
"location": null
},
{
"path": "series[70].dimensions.uri",
"message": "Value exceeds maximum length.Maximum value length: 128 (inclusively).",
"parameterLocation": "PAYLOAD_BODY",
"location": null
},
{
"path": "series[69].dimensions.uri",
"message": "Value exceeds maximum length.Maximum value length: 128 (inclusively).",
"parameterLocation": "PAYLOAD_BODY",
"location": null
},
{
"path": "series[67].dimensions.uri",
"message": "Value exceeds maximum length.Maximum value length: 128 (inclusively).",
"parameterLocation": "PAYLOAD_BODY",
"location": null
}
]
}
}
I believe we simply weren't aware of this constraint due to it not being mentioned in the Dynatrace documentation. If 128 length is a constraint on dimension values, we should include truncating in the DynatraceNamingConvention to ensure we send valid tag values. This does mean your uri tags will be truncated in Dynatrace, though.
As for a workaround before we release a fix with this, you could ~extend the DynatraceNamingConvention to add the truncating logic for tag values and configure that naming convention on the DynatraceMeterRegistry~ (we don't offer a way to configure a custom naming convention with DynatraceMeterRegistry currently). Instead, you could register a MeterFilter like the following on the DynatraceMeterRegistry:
new MeterFilter() {
@Override
public Meter.Id map(Meter.Id id) {
return id.withTags(id.getTags().stream()
.filter(tag -> tag.getValue().length() > 128)
.map(tag -> Tag.of(tag.getKey(),
tag.getValue().substring(0, 128)))
.collect(Collectors.toList()));
}
};
If we can get some official answer on the dimension constraints, we can update this. I searched the official documentation again and there was no mention of length constraints anywhere I could find.
Hi!
I have requested, through a support case, that Dynatrace document the max length. From what they informed me: "the limit is 512 characters, but I have no public facing documentation to share. "
The limit from the above API response seems to be different from the limit the Dynatrace team shared above: 128 vs. 512
I reached out to the Dynatrace OSS Team, here's their answer:
It is a hardcoded limit of 128 for the length of a dimension value, so the message in the error response from the API is correct. The limit is not configurable. In this case, truncating would make sense.
@tutnes Would you like to prepare a PR for fixing this?
Hi @jonatan-ivanov, I implemented a fix for this (see #2575).
Fyi: let me leave this here in case somebody bump into issues like seeing a question mark (?) at the end of their tag value or a character that was never meant to be there (highly unlikely) or both: https://github.com/micrometer-metrics/micrometer/pull/2575#issuecomment-827107568