[8.19] [APM] Fix Otel missing fields undefined errors (#254271)#254758
Merged
jennypavlova merged 2 commits intoelastic:8.19from Feb 24, 2026
Merged
[8.19] [APM] Fix Otel missing fields undefined errors (#254271)#254758jennypavlova merged 2 commits intoelastic:8.19from
jennypavlova merged 2 commits intoelastic:8.19from
Conversation
Closes elastic#254222 ## Summary This PR fixes uncaught errors when APM data has missing `service` or `service.environment` (e.g. OpenTelemetry or incomplete documents). The UI was reading `error.service.environment`, `transaction.service.environment`, and similar properties without optional chaining, causing "Cannot read properties of undefined (reading 'environment')" and error boundary crashes. This PR: - Adds optional chaining and fallbacks to `ENVIRONMENT_NOT_DEFINED` / `getEnvironmentLabel` where service or environment may be missing - Updates **error group details**: error sample detail, contextual insight, and sample summary (optional `error`/`service`, safe access to `error.error`) - Updates **transaction/span flyouts**: transaction flyout, view full trace link, span flyout sticky properties - Updates **agent configuration link**: safe access to `configService?.name` and `configService?.environment` ## How to test - Use APM with data that has no `service` or no `service.environment` (e.g. OTel or incomplete documents): If using synthtrace I added a scenario: - Run `node scripts/synthtrace missing_service_environment --from=now-1h --to=now+1h` - Confirm that the service.environment is not in the document and there is no error in the flyout: <img width="3446" height="1962" alt="image" src="https://github.com/user-attachments/assets/04867ef0-f89b-4601-b0bf-381a795ab2a6" /> - Open error group details and an error sample, transaction flyout, span flyout, or a view that uses agent config service - Confirm the UI no longer crashes and shows "Not defined" (or equivalent) for missing environment where appropriate: <img width="3456" height="1994" alt="image" src="https://github.com/user-attachments/assets/21fb7684-2c40-4eb5-b83d-063d9b2437be" /> https://github.com/user-attachments/assets/19c46cb3-ff2e-4938-8cf3-2316f7a1a4ae --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit f0e605f) # Conflicts: # src/platform/packages/shared/kbn-apm-synthtrace/src/scenarios/missing_service_environment.ts # x-pack/solutions/observability/plugins/apm/public/components/app/error_group_details/error_sampler/error_sample_detail.tsx
Contributor
|
Pinging @elastic/obs-presentation-team (Team:obs-presentation) |
rmyz
approved these changes
Feb 24, 2026
Contributor
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
History
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto8.19:Questions ?
Please refer to the Backport tool documentation