Skip to content

[8.x] [GenAI Connectors] Add support for telemetry metadata (#208180)#210157

Merged
kibanamachine merged 2 commits intoelastic:8.xfrom
kibanamachine:backport/8.x/pr-208180
Feb 7, 2025
Merged

[8.x] [GenAI Connectors] Add support for telemetry metadata (#208180)#210157
kibanamachine merged 2 commits intoelastic:8.xfrom
kibanamachine:backport/8.x/pr-208180

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Marius Iversen "}},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com//pull/210016","number":210016,"state":"MERGED","mergeCommit":{"sha":"bf9401474bfe63139e25bb4c3546509f926954c7","message":"[8.18] [GenAI Connectors] Add support for telemetry metadata (#208180) (#210016)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.18`:\n- [[GenAI Connectors] Add support for telemetry metadata\n(#208180)](https://github.com//pull/208180)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Marius Iversen "}},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com//pull/208180","number":208180,"mergeCommit":{"message":"[GenAI Connectors] Add support for telemetry metadata (#208180)\n\n## Summary\n\nThis extends initial connector telemetry from PR ref\nhttps://github.com//pull/186936.\n\nThe PR adds the following optional fields when instantiating a new\nactionClient as part of its `subActionParams`:\n\n```ts\n{\n telemetryMetadata : {\n pluginId: \"your plugin name or unique identifier\",\n aggregateBy: \"ID to aggregate on\" \n }\n}\n```\n\nThe support is added to all AI connector models for both\nstream/non-stream/raw.\n\nThe PR also adds token count usage for bedrock `InvokeAIRaw`, as that\nwas currently not added correctly.\n\nPierre also helped with adding a new metadata optional field for the `NL\nto ESQL functions`, so that users can pass in similar metadata for LLM\nconversations using the InfereceClient.\n\nPluginId is a field used to filter telemetry in the way the team wants\nto implement it. It could be a team name, a plugin name etc, all\ndepending on how the team wants to group and filter on the telemetry\nevent.\n\nAggregateBy is intended to be used to group multiple LLM calls for\naggregations and stats, for example a conversationId that has multiple\nLLM calls.\n\nBoth fields are optional, so when you do not want to aggregate the\noption can simply be ignored.\n\n### Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers should verify this PR satisfies this list as well.\n\n- [x] Any text added follows [EUI's writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\nsentence case text and includes [i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n---------\n\nCo-authored-by: pgayvallet ","sha":"3394b691b1582d504195182013f833ba727c5e7e"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->

## Summary

This extends initial connector telemetry from PR ref
elastic#186936.

The PR adds the following optional fields when instantiating a new
actionClient as part of its `subActionParams`:

```ts
{
  telemetryMetadata : {
    pluginId: "your plugin name or unique identifier",
    aggregateBy: "ID to aggregate on"
  }
}
```

The support is added to all AI connector models for both
stream/non-stream/raw.

The PR also adds token count usage for bedrock `InvokeAIRaw`, as that
was currently not added correctly.

Pierre also helped with adding a new metadata optional field for the `NL
to ESQL functions`, so that users can pass in similar metadata for LLM
conversations using the InfereceClient.

PluginId is a field used to filter telemetry in the way the team wants
to implement it. It could be a team name, a plugin name etc, all
depending on how the team wants to group and filter on the telemetry
event.

AggregateBy is intended to be used to group multiple LLM calls for
aggregations and stats, for example a conversationId that has multiple
LLM calls.

Both fields are optional, so when you do not want to aggregate the
option can simply be ignored.

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [x] 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)
- [x] [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
- [x] 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: pgayvallet <pierre.gayvallet@elastic.co>
(cherry picked from commit 3394b69)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label Feb 7, 2025
@kibanamachine kibanamachine enabled auto-merge (squash) February 7, 2025 10:36
@kibanamachine kibanamachine merged commit aff32fa into elastic:8.x Feb 7, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

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/inference-common 59 62 +3

Page load bundle

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

id before after diff
inference 7.6KB 7.6KB +22.0B
Unknown metric groups

API count

id before after diff
@kbn/inference-common 174 180 +6

History

cc @P1llus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants