Java Code Examples for io.micrometer.core.instrument.util.StringUtils#truncate()
The following examples show how to use
io.micrometer.core.instrument.util.StringUtils#truncate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynatraceMetricDefinition.java From micrometer with Apache License 2.0 | 6 votes |
String asJson() { String displayName = description == null ? metricId : StringEscapeUtils.escapeJson(description); String body = "{\"displayName\":\"" + StringUtils.truncate(displayName, MAX_DISPLAY_NAME) + "\""; if (StringUtils.isNotBlank(group)) body += ",\"group\":\"" + StringUtils.truncate(group, MAX_GROUP_NAME) + "\""; if (unit != null) body += ",\"unit\":\"" + unit + "\""; if (dimensions != null && !dimensions.isEmpty()) body += ",\"dimensions\":[" + dimensions.stream() .map(d -> "\"" + d + "\"") .collect(Collectors.joining(",")) + "]"; body += ",\"types\":[" + stream(technologyTypes).map(type -> "\"" + type + "\"").collect(Collectors.joining(",")) + "]"; body += "}"; return body; }
Example 2
Source File: SignalFxNamingConvention.java From micrometer with Apache License 2.0 | 6 votes |
@Override public String tagKey(String key) { String conventionKey = delegate.tagKey(key); conventionKey = START_UNDERSCORE_PATTERN.matcher(conventionKey).replaceAll(""); // 2 conventionKey = SF_PATTERN.matcher(conventionKey).replaceAll(""); // 2 conventionKey = PATTERN_TAG_KEY_BLACKLISTED_CHARS.matcher(conventionKey).replaceAll("_"); if (!START_LETTERS_PATTERN.matcher(conventionKey).matches()) { // 3 conventionKey = "a" + conventionKey; } if (PATTERN_TAG_KEY_BLACKLISTED_PREFIX.matcher(conventionKey).matches()) { logger.log("'" + conventionKey + "' (original name: '" + key + "') is not a valid tag key. " + "Must not start with any of these prefixes: aws_, gcp_, or azure_. " + "Please rename it to conform to the constraints. " + "If it comes from a third party, please use MeterFilter to rename it."); } return StringUtils.truncate(conventionKey, KEY_MAX_LENGTH); // 1 }
Example 3
Source File: CloudWatchNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagKey(String key) { return StringUtils.truncate(delegate.tagKey(key), MAX_TAG_KEY_LENGTH); }
Example 4
Source File: CloudWatchNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagValue(String value) { return StringUtils.truncate(delegate.tagValue(value), MAX_TAG_VALUE_LENGTH); }
Example 5
Source File: AppOpticsNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagKey(String key) { String sanitized = TAG_KEY_BLACKLIST.matcher(delegate.tagKey(key)).replaceAll("_"); return StringUtils.truncate(sanitized, MAX_TAG_KEY_LENGTH); }
Example 6
Source File: AppOpticsNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagValue(String value) { String sanitized = TAG_VALUE_BLACKLIST.matcher(delegate.tagValue(value)).replaceAll("_"); return StringUtils.truncate(sanitized, MAX_TAG_VALUE_LENGTH); }
Example 7
Source File: SignalFxNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagValue(String value) { String formattedValue = StringEscapeUtils.escapeJson(delegate.tagValue(value)); return StringUtils.truncate(formattedValue, TAG_VALUE_MAX_LENGTH); }
Example 8
Source File: CloudWatchNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagKey(String key) { return StringUtils.truncate(delegate.tagKey(key), MAX_TAG_KEY_LENGTH); }
Example 9
Source File: CloudWatchNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagValue(String value) { return StringUtils.truncate(delegate.tagValue(value), MAX_TAG_VALUE_LENGTH); }
Example 10
Source File: StackdriverNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
private String sanitize(String value, Pattern blacklist, int maxLength) { return StringUtils.truncate(blacklist.matcher(value).replaceAll("_"), maxLength); }
Example 11
Source File: StackdriverNamingConvention.java From micrometer with Apache License 2.0 | 4 votes |
@Override public String tagValue(String value) { return StringUtils.truncate(value, MAX_TAG_VALUE_LENGTH); }