-
Notifications
You must be signed in to change notification settings - Fork 172
chore: add telemetry properties for vector search and mcp auto-embed usage #796
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
base: main
Are you sure you want to change the base?
Changes from all commits
0b60d8a
80f9e7e
de74005
68fc2f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ import { | |
| assertVectorSearchFilterFieldsAreIndexed, | ||
| type SearchIndex, | ||
| } from "../../../helpers/assertVectorSearchFilterFieldsAreIndexed.js"; | ||
| import type { AutoEmbeddingsUsageMetadata, ConnectionMetadata } from "../../../telemetry/types.js"; | ||
|
|
||
| const pipelineDescriptionWithVectorSearch = `\ | ||
| An array of aggregation stages to execute. | ||
|
|
@@ -344,4 +345,23 @@ The aggregation resulted in ${aggResultsCount === undefined ? "indeterminable nu | |
| Returning ${documents.length} documents${appliedLimitText ? ` ${appliedLimitText}` : "."}\ | ||
| `; | ||
| } | ||
|
|
||
| protected resolveTelemetryMetadata( | ||
| args: ToolArgs<typeof this.argsShape>, | ||
| { result }: { result: CallToolResult } | ||
| ): ConnectionMetadata | AutoEmbeddingsUsageMetadata { | ||
| const [maybeVectorStage] = args.pipeline; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the vector stage always first?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea Vector stage, if included, should always be at the first position in the pipeline. |
||
| if ( | ||
| maybeVectorStage && | ||
| (maybeVectorStage as z.infer<typeof VectorSearchStage>)?.["$vectorSearch"]?.embeddingParameters && | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is hard to read; can it be `maybeVectorStage instanceof Object && "$vectorSearch" in maybeVectorStage && "embeddingParameters" in maybeVectorStage["$vectorSearch"] |
||
| this.config.voyageApiKey | ||
| ) { | ||
| return { | ||
| ...super.resolveTelemetryMetadata(args, { result }), | ||
| embeddingsGeneratedBy: "mcp", | ||
| }; | ||
| } else { | ||
| return super.resolveTelemetryMetadata(args, { result }); | ||
| } | ||
| } | ||
himanshusinghs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: while we can add arrays in telemetry, this really makes stuff like amplitude difficult as the values appear as one text with spaces normally.
ordering of strings is also a problem as you can't queries based on keys or position.
since this pattern is already stablished let's proceed, but ideally we should be removing arrays from segment events.