Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover][APM] Trace badge icons for traces summary cell #209824

Merged
merged 28 commits into from
Feb 14, 2025

Conversation

Bluefinger
Copy link
Contributor

@Bluefinger Bluefinger commented Feb 5, 2025

Summary

Adds badges for the Summary cell in the Traces Data Source Profile mode for Discover. Shows service.name, event.outcome, transaction.name, transaction.duration.us, span.name and span.duration.us depending on whether the fields are available on the log document.

Closes #208692

Trace Badges - Screenshot 2025-02-07 123457

How to Test

  • Run synthtrace with the following profile/scenario: traces_logs_entitities.ts
  • Ensure there is a Data View enabled for Logs Explorer that has the following id structure: apm_static_data_view_id with index patterns that match on traces-*, and add the following to your kibana.dev.yml and:
discover.experimental.enabledProfiles:
  - traces-data-source-profile
  • Go to Logs Explorer (Discover) and there should be badges that show for trace data, corresponding to service.name, event.outcome, transaction.name and transaction.duration.us or span.name and span.duration.us
  • Each badge should be clickable and show a popover for applying a filter

@Bluefinger Bluefinger added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team labels Feb 5, 2025
@Bluefinger
Copy link
Contributor Author

/ci

2 similar comments
@Bluefinger
Copy link
Contributor Author

/ci

@Bluefinger
Copy link
Contributor Author

/ci

@Bluefinger Bluefinger marked this pull request as ready for review February 7, 2025 11:48
@Bluefinger Bluefinger requested review from a team as code owners February 7, 2025 11:48
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

Copy link
Contributor

@iblancof iblancof left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and really liked the quick filtering with highlighted attributes!

I noticed that badges are being added to all documents in the table, not just those with data_stream.type:"traces". Is this intentional and aligned with the original goal?

I get that impacting other documents comes at no extra cost, but I just want to ensure we're all aware and that it still makes sense in the context of improving the traces experience, especially since we won't rely on the APM Data View as an enabler forever.

Metrics Logs
Screenshot 2025-02-10 at 11 37 34 Screenshot 2025-02-10 at 11 38 08

},
resolve: ({ dataSource }) => {
if (
isDataSourceType(dataSource, DataSourceType.DataView) &&
dataSource.dataViewId === 'apm_static_data_view_id_default'
dataSource.dataViewId.includes('apm_static_data_view_id')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding support for multiple spaces!

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a bit of feedback, but the Data Discovery changes look good overall. I just noticed one issue when testing. It looks like filtering doesn't work for formatted fields -- are we able to pass the unformatted values instead?

filters.mp4

@@ -38,7 +43,7 @@ export interface SummaryColumnFactoryDeps {
share?: SharePluginStart;
}

export type SummaryColumnProps = DataGridCellValueElementProps;
export type SummaryColumnProps = DataGridCellValueElementProps & { isTracesSummary?: boolean };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I partly wonder if it would be better to either decompose these components or make them more generic vs adding a flag, but I guess it depends on how many variants we expect to have, and Logs UX would know better.

@Bluefinger Bluefinger force-pushed the discover-summary-badges branch from a25bde7 to a195f39 Compare February 11, 2025 11:13
@kpatticha
Copy link
Contributor

Similar to @davismcphee comment around the formatted filters I've noticed this one

Screen.Recording.2025-02-11.at.6.09.22.PM.mov

@kpatticha
Copy link
Contributor

kpatticha commented Feb 11, 2025

Another observation—I initially found this a bit confusing but later realized that the documents below represent aggregated metrics. This approach might work for the first iterations, but it's worth checkin.

We display badges only for raw transactions, while the APM data view can have the aggregated metrics.

Screenshot 2025-02-11 at 6 14 40 PM

@Bluefinger
Copy link
Contributor Author

while testing it locally for the transaction.duration.us badge I've noticed this
image

@kpatticha Which synthtrace dataset are you testing with or with real data?

@kpatticha
Copy link
Contributor

while testing it locally for the transaction.duration.us badge I've noticed this
image

@kpatticha Which synthtrace dataset are you testing with or with real data?

I used synthrace. First run node scripts/synthtrace simple_trace and then node scripts/synthtrace traces_logs_entities.ts

@iblancof
Copy link
Contributor

Hey, I was exploring a bit and noticed this, some durations don't seem to display their units.

This data comes from the traces_logs_entities.ts synthrace scenario.

Screenshot 2025-02-12 at 12 16 07

@Bluefinger
Copy link
Contributor Author

Bluefinger commented Feb 12, 2025

So, I refactored a bunch of the code, so it should be a bit more robust and also more reusable in additional contexts. However, I decided to not try to force the microsecond formatting, because there's a lot of machinery already for deciding how something gets formatted, and I don't want to second guess what it is doing. I brought back the translated labels for the Event Outcome badge, but it is only translated for the badge itself. On the popover, it shows the raw value, so to make it clear that the actual value that is being filtered on is what is represented by the raw value.

Also, I hope the generics aren't too hairy. I erased the generics, wasn't needed.

@Bluefinger
Copy link
Contributor Author

For today, I removed the translations for event.outcome as the designs no longer reflect this, and we'll be relying on the field formatting going forward.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1703 1706 +3
canvas 1227 1230 +3
cloudSecurityPosture 794 797 +3
discover 1101 1107 +6
esqlDataGrid 519 522 +3
eventAnnotationListing 746 749 +3
lens 1823 1826 +3
logsShared 363 366 +3
observability 1445 1448 +3
searchPlayground 296 299 +3
securitySolution 6791 6794 +3
slo 994 997 +3
unifiedDocViewer 281 284 +3
unifiedHistogram 288 291 +3
total +45

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/discover-utils 230 240 +10

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 847.9KB 851.8KB +3.9KB
unifiedDocViewer 148.5KB 149.0KB +527.0B
total +4.4KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/discover-utils 4 3 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
discover 44.8KB 44.8KB +1.0B
Unknown metric groups

API count

id before after diff
@kbn/discover-contextual-components 39 38 -1
@kbn/discover-utils 280 290 +10
total +9

History

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filtering is now working as expected, and the Data Discovery changes LGTM 👍 I left a couple more comments around field formatting, but I think this is good to approve on our end now. Thanks for working on it!


return availableResourceFields.map((name) => ({
name,
value: resourceDoc[name],
rawValue: resourceDoc[name],
value: getFormattedValue(name, resourceDoc[name], dataView),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
value: getFormattedValue(name, resourceDoc[name], dataView),
value: formatFieldValue(
resourceDoc[name],
row.raw,
fieldFormats,
dataView,
dataView.getFieldByName(name),
'html'
),

Since there's no longer any special handling going on here, I'd definitely recommend dropping the getFormattedValue function and using formatFieldValue since it's the standard util and will produce the best output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the change to make use of formatFieldValue, but as a note, there's a soundness hole with it in that in some circumstances, it doesn't actually return a string value. This is due to FieldFormat.convert not actually turning a value into string if there is no formatter present for it, instead it simply casts it to string. As such, I put TODOs on the places I've changed to using formatFieldValue to remove the string guards once the method no longer has a soundness hole.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating it 👍 And interesting, TIL. I suppose that would be an issue regardless for any use of getFormatterForField, but I don't think it's an actual scenario. It looks like converter never returns undefined and we we just have a redundant null check there. We should be able to drop it and get rid of value as string. Our team owns that code so we can take a look at it as a followup and update here too.

@Bluefinger Bluefinger merged commit a95f903 into elastic:main Feb 14, 2025
9 checks passed
davismcphee added a commit that referenced this pull request Feb 26, 2025
## Summary

It was [pointed
out](#209824 (comment))
during a recent review that the field format `convert()` value does some
odd casting. It looks like this probably isn't necessary since
`converter` should never be undefined, and we can just return the result
directly.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Elastic Machine <[email protected]>
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Feb 27, 2025
…#211342)

## Summary

It was [pointed
out](elastic#209824 (comment))
during a recent review that the field format `convert()` value does some
odd casting. It looks like this probably isn't necessary since
`converter` should never be undefined, and we can just return the result
directly.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discover][APM] Custom cell renderer with links for summary column in traces_data_source_profile
8 participants