Skip to content

Commit

Permalink
Only emit product origin in deprecation log if present (elastic#111683)
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 authored Aug 8, 2024
1 parent aaf65b7 commit b31feb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/changelog/111683.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 111683
summary: Only emit product origin in deprecation log if present
area: Infra/Logging
type: bug
issues:
- 81757
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 b31feb3

Please sign in to comment.