Pretty print application id source, with standard serialization
@@ -95,7 +95,7 @@ public class Notifier {
private Mail mailOf(Notification n, Collection<String> recipients) {
var source = n.source();
- var subject = Text.format("[%s] %s Vespa Notification for %s - %s", n.level().toString().toUpperCase(), n.type().name(), source.tenant(), source.application());
+ var subject = Text.format("[%s] %s Vespa Notification for %s", n.level().toString().toUpperCase(), n.type().name(), applicationIdSource(source));
var body = new StringBuilder();
body.append("Source: ").append(n.source().toString()).append("\n")
.append("\n")
@@ -105,6 +105,14 @@ public class Notifier {
return new Mail(recipients, subject.toString(), body.toString());
}
+ private String applicationIdSource(NotificationSource source) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(source.tenant().value());
+ source.application().ifPresent(applicationName -> sb.append(".").append(applicationName.value()));
+ source.instance().ifPresent(instanceName -> sb.append(".").append(instanceName.value()));
+ return sb.toString();
+ }
+
private URI url(NotificationSource source) {
if (source.application().isPresent() && source.instance().isPresent()) {
if (source.jobType().isPresent() && source.runNumber().isPresent()) {
