Skip to content

Commit

Permalink
[8.x] [APM] Empty/null service.environment error fix (#192448) (#193138)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[APM] Empty/null service.environment error fix
(#192448)](#192448)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Carlos
Crespo","email":"crespocarlos@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-17T10:36:24Z","message":"[APM]
Empty/null service.environment error fix (#192448)\n\nfixes
[192380](https://github.com/elastic/kibana/issues/192380)\r\n\r\n##
Summary\r\n\r\nRevert the `service.environment` comparison change. Using
`equals` can\r\nbe dangerous if the field is null, resulting in errors.
The previous\r\nversion worked fine, so I decided to revert the change
that modified the\r\ncondition.\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"4a2dd8a99370ce8d6678de15dd617565e5bfc5ac","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services","v8.15.0","v8.16.0"],"title":"[APM]
Empty/null service.environment error
fix","number":192448,"url":"https://github.com/elastic/kibana/pull/192448","mergeCommit":{"message":"[APM]
Empty/null service.environment error fix (#192448)\n\nfixes
[192380](https://github.com/elastic/kibana/issues/192380)\r\n\r\n##
Summary\r\n\r\nRevert the `service.environment` comparison change. Using
`equals` can\r\nbe dangerous if the field is null, resulting in errors.
The previous\r\nversion worked fine, so I decided to revert the change
that modified the\r\ncondition.\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"4a2dd8a99370ce8d6678de15dd617565e5bfc5ac"}},"sourceBranch":"main","suggestedTargetBranches":["8.15","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192448","number":192448,"mergeCommit":{"message":"[APM]
Empty/null service.environment error fix (#192448)\n\nfixes
[192380](https://github.com/elastic/kibana/issues/192380)\r\n\r\n##
Summary\r\n\r\nRevert the `service.environment` comparison change. Using
`equals` can\r\nbe dangerous if the field is null, resulting in errors.
The previous\r\nversion worked fine, so I decided to revert the change
that modified the\r\ncondition.\r\n\r\n---------\r\n\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"4a2dd8a99370ce8d6678de15dd617565e5bfc5ac"}},{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Carlos Crespo <crespocarlos@users.noreply.github.com>
  • Loading branch information
kibanamachine and crespocarlos authored Sep 17, 2024
1 parent 259bfca commit 447cbdd
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export async function fetchServicePathsFromTraceIds({

const numDocsPerShardAllowed = calculatedDocs > terminateAfter ? terminateAfter : calculatedDocs;

/*
* Any changes to init_script, map_script, combine_script and reduce_script
* must be replicated on https://github.com/elastic/elasticsearch-serverless/blob/main/distribution/archives/src/serverless-default-settings.yml
*/
const serviceMapAggs = {
service_map: {
scripted_metric: {
Expand Down Expand Up @@ -224,10 +228,9 @@ export async function fetchServicePathsFromTraceIds({
// if the parent has 'span.destination.service.resource' set, and the service is different, we've discovered a service
if (parent['span.destination.service.resource'] != null
&& !parent['span.destination.service.resource'].equals("")
&& (!parent['service.name'].equals(event['service.name'])
|| !parent['service.environment'].equals(event['service.environment'])
)
&& parent['span.destination.service.resource'] != ""
&& (parent['service.name'] != event['service.name']
|| parent['service.environment'] != event['service.environment'])
) {
def parentDestination = getDestination(parent);
context.externalToServiceMap.put(parentDestination, service);
Expand Down

0 comments on commit 447cbdd

Please sign in to comment.