Skip to content

Commit

Permalink
Only emit product origin in deprecation log if present
Browse files Browse the repository at this point in the history
The elastic product origin may not always be present when deprecation
messages are emitted. This commit changes the log message created for
deprecations to only emit the product origin field if it is not empty.

closes elastic#81757
  • Loading branch information
rjernst committed Aug 7, 2024
1 parent 3d6b7aa commit 3ad8334
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,12 @@ private static ESLogMessage getEsLogMessage(
.field(KEY_FIELD_NAME, key)
.field("elasticsearch.event.category", category.name().toLowerCase(Locale.ROOT));

if (Strings.isNullOrEmpty(xOpaqueId)) {
return esLogMessage;
if (Strings.isNullOrEmpty(xOpaqueId) == false) {
esLogMessage.field(X_OPAQUE_ID_FIELD_NAME, xOpaqueId)
}

return esLogMessage.field(X_OPAQUE_ID_FIELD_NAME, xOpaqueId).field(ELASTIC_ORIGIN_FIELD_NAME, productOrigin);
if (Strings.isNullOrEmpty(productOrigin) == false) {
esLogMessage.field(ELASTIC_ORIGIN_FIELD_NAME, productOrigin);
}
return esLogMessage;
}
}

0 comments on commit 3ad8334

Please sign in to comment.