Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Perfomance] Track time range picker with
onPageReady
function (
#202889) (#204564) # Backport This will backport the following commits from `main` to `8.x`: - [[Perfomance] Track time range picker with `onPageReady` function (#202889)](#202889) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Katerina","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-13T13:11:44Z","message":"[Perfomance] Track time range picker with `onPageReady` function (#202889)\n\n## Summary\r\n\r\ncloses https://github.com/elastic/observability-dev/issues/3377\r\n## Metrics \r\n#### `meta.query_range_secs` - The duration of the selected time range\r\nin seconds.\r\n#### `meta.query_offset_secs` - The offset from \"now\" to the\r\n'rangeTo'/end' time picker value in seconds.\r\n\r\n____\r\n\r\nExtend the `onPageReady` function to support date ranges in the meta\r\nfield. The function should compute the query range in seconds based on\r\nthe provided time range and report it to telemetry as\r\nmeta.query_range_secs.\r\n\r\n\r\n\r\n\r\nIf the `rangeTo` is different from 'now', calculate the offset. \r\n- A negative offset indicates that the rangeTo is in the past, \r\n- a positive offset means it is in the future, \r\n- and zero indicates that the rangeTo is exactly 'now'.\" \r\n\r\n\r\n\r\n### How to instrument\r\nTo report the selected time range, pass the `rangeFrom` and `rangeTo` . \r\n> Failing to pass the correct type will result in TS error.\r\n\r\n\r\nThen, use this data when invoking onPageReady:\r\n```\r\n onPageReady({\r\n meta: { rangeFrom, rangeTo },\r\n });\r\n```\r\n\r\n### Analysis \r\n\r\nMeta is flatten field. In order to aggregate the data it's necessary to\r\ncreate a run time field. You can add a field in the\r\n\r\n1. select data view (`ebt-kibana-*-performance-metrics`) \r\n2. Add a new field\r\n3. Type double\r\n4. Set value \r\n\r\n`query_range_secs`\r\n```\r\ndef meta = doc[“meta”].size();\r\nif (meta > 0) {\r\n def range = doc[“meta.query_range_secs”].size();\r\n if (range > 0) {\r\n // Emit the value of ‘meta.target’\r\n emit(Double.parseDouble(doc[“meta.query_range_secs”].value));\r\n }\r\n}\r\n\r\n```\r\n\r\n`query_offset_secs` \r\n```\r\n\r\ndef meta = doc[“meta”].size();\r\nif (meta > 0) {\r\n def offset = doc[“meta.query_offset_secs”].size();\r\n if (offset > 0) {\r\n \r\n emit(Double.parseDouble(doc[“meta.query_offset_secs”].value));\r\n }\r\n}\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n### Examples\r\n\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 51 32\"\r\nsrc=\"https://github.com/user-attachments/assets/72f796e1-4f20-487f-b62a-b6a4aead9a4a\">\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 56 08\"\r\nsrc=\"https://github.com/user-attachments/assets/c278dc3b-e6f3-47ed-9c90-954d71b59161\">\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 53 45 1\"\r\nsrc=\"https://github.com/user-attachments/assets/ef42ecef-48cd-4396-9f5d-c971098d5219\">\r\n\r\n\r\n\r\n\r\n\r\n### Notes\r\n- Instrumented only 2 solutions as an example (dataset and apm services)\r\n\r\n### TODO\r\n- [x] Update documentation -\r\nhttps://github.com//pull/204179\r\n- [ ] Update dashboards (create a runtime field) \r\n- [x] Track offset ( we need to know if the user selected now or now)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"bd1c00fd65848ff27a1bace14363c5ab326c491d","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport missing","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-infra_services"],"number":202889,"url":"https://github.com/elastic/kibana/pull/202889","mergeCommit":{"message":"[Perfomance] Track time range picker with `onPageReady` function (#202889)\n\n## Summary\r\n\r\ncloses https://github.com/elastic/observability-dev/issues/3377\r\n## Metrics \r\n#### `meta.query_range_secs` - The duration of the selected time range\r\nin seconds.\r\n#### `meta.query_offset_secs` - The offset from \"now\" to the\r\n'rangeTo'/end' time picker value in seconds.\r\n\r\n____\r\n\r\nExtend the `onPageReady` function to support date ranges in the meta\r\nfield. The function should compute the query range in seconds based on\r\nthe provided time range and report it to telemetry as\r\nmeta.query_range_secs.\r\n\r\n\r\n\r\n\r\nIf the `rangeTo` is different from 'now', calculate the offset. \r\n- A negative offset indicates that the rangeTo is in the past, \r\n- a positive offset means it is in the future, \r\n- and zero indicates that the rangeTo is exactly 'now'.\" \r\n\r\n\r\n\r\n### How to instrument\r\nTo report the selected time range, pass the `rangeFrom` and `rangeTo` . \r\n> Failing to pass the correct type will result in TS error.\r\n\r\n\r\nThen, use this data when invoking onPageReady:\r\n```\r\n onPageReady({\r\n meta: { rangeFrom, rangeTo },\r\n });\r\n```\r\n\r\n### Analysis \r\n\r\nMeta is flatten field. In order to aggregate the data it's necessary to\r\ncreate a run time field. You can add a field in the\r\n\r\n1. select data view (`ebt-kibana-*-performance-metrics`) \r\n2. Add a new field\r\n3. Type double\r\n4. Set value \r\n\r\n`query_range_secs`\r\n```\r\ndef meta = doc[“meta”].size();\r\nif (meta > 0) {\r\n def range = doc[“meta.query_range_secs”].size();\r\n if (range > 0) {\r\n // Emit the value of ‘meta.target’\r\n emit(Double.parseDouble(doc[“meta.query_range_secs”].value));\r\n }\r\n}\r\n\r\n```\r\n\r\n`query_offset_secs` \r\n```\r\n\r\ndef meta = doc[“meta”].size();\r\nif (meta > 0) {\r\n def offset = doc[“meta.query_offset_secs”].size();\r\n if (offset > 0) {\r\n \r\n emit(Double.parseDouble(doc[“meta.query_offset_secs”].value));\r\n }\r\n}\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n### Examples\r\n\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 51 32\"\r\nsrc=\"https://github.com/user-attachments/assets/72f796e1-4f20-487f-b62a-b6a4aead9a4a\">\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 56 08\"\r\nsrc=\"https://github.com/user-attachments/assets/c278dc3b-e6f3-47ed-9c90-954d71b59161\">\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 53 45 1\"\r\nsrc=\"https://github.com/user-attachments/assets/ef42ecef-48cd-4396-9f5d-c971098d5219\">\r\n\r\n\r\n\r\n\r\n\r\n### Notes\r\n- Instrumented only 2 solutions as an example (dataset and apm services)\r\n\r\n### TODO\r\n- [x] Update documentation -\r\nhttps://github.com//pull/204179\r\n- [ ] Update dashboards (create a runtime field) \r\n- [x] Track offset ( we need to know if the user selected now or now)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"bd1c00fd65848ff27a1bace14363c5ab326c491d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/202889","number":202889,"mergeCommit":{"message":"[Perfomance] Track time range picker with `onPageReady` function (#202889)\n\n## Summary\r\n\r\ncloses https://github.com/elastic/observability-dev/issues/3377\r\n## Metrics \r\n#### `meta.query_range_secs` - The duration of the selected time range\r\nin seconds.\r\n#### `meta.query_offset_secs` - The offset from \"now\" to the\r\n'rangeTo'/end' time picker value in seconds.\r\n\r\n____\r\n\r\nExtend the `onPageReady` function to support date ranges in the meta\r\nfield. The function should compute the query range in seconds based on\r\nthe provided time range and report it to telemetry as\r\nmeta.query_range_secs.\r\n\r\n\r\n\r\n\r\nIf the `rangeTo` is different from 'now', calculate the offset. \r\n- A negative offset indicates that the rangeTo is in the past, \r\n- a positive offset means it is in the future, \r\n- and zero indicates that the rangeTo is exactly 'now'.\" \r\n\r\n\r\n\r\n### How to instrument\r\nTo report the selected time range, pass the `rangeFrom` and `rangeTo` . \r\n> Failing to pass the correct type will result in TS error.\r\n\r\n\r\nThen, use this data when invoking onPageReady:\r\n```\r\n onPageReady({\r\n meta: { rangeFrom, rangeTo },\r\n });\r\n```\r\n\r\n### Analysis \r\n\r\nMeta is flatten field. In order to aggregate the data it's necessary to\r\ncreate a run time field. You can add a field in the\r\n\r\n1. select data view (`ebt-kibana-*-performance-metrics`) \r\n2. Add a new field\r\n3. Type double\r\n4. Set value \r\n\r\n`query_range_secs`\r\n```\r\ndef meta = doc[“meta”].size();\r\nif (meta > 0) {\r\n def range = doc[“meta.query_range_secs”].size();\r\n if (range > 0) {\r\n // Emit the value of ‘meta.target’\r\n emit(Double.parseDouble(doc[“meta.query_range_secs”].value));\r\n }\r\n}\r\n\r\n```\r\n\r\n`query_offset_secs` \r\n```\r\n\r\ndef meta = doc[“meta”].size();\r\nif (meta > 0) {\r\n def offset = doc[“meta.query_offset_secs”].size();\r\n if (offset > 0) {\r\n \r\n emit(Double.parseDouble(doc[“meta.query_offset_secs”].value));\r\n }\r\n}\r\n\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n### Examples\r\n\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 51 32\"\r\nsrc=\"https://github.com/user-attachments/assets/72f796e1-4f20-487f-b62a-b6a4aead9a4a\">\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 56 08\"\r\nsrc=\"https://github.com/user-attachments/assets/c278dc3b-e6f3-47ed-9c90-954d71b59161\">\r\n\r\n<img width=\"1478\" alt=\"Screenshot 2024-12-09 at 19 53 45 1\"\r\nsrc=\"https://github.com/user-attachments/assets/ef42ecef-48cd-4396-9f5d-c971098d5219\">\r\n\r\n\r\n\r\n\r\n\r\n### Notes\r\n- Instrumented only 2 solutions as an example (dataset and apm services)\r\n\r\n### TODO\r\n- [x] Update documentation -\r\nhttps://github.com//pull/204179\r\n- [ ] Update dashboards (create a runtime field) \r\n- [x] Track offset ( we need to know if the user selected now or now)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"bd1c00fd65848ff27a1bace14363c5ab326c491d"}}]}] BACKPORT-->
- Loading branch information