Skip to content

.Net: [Feature Branch] Vector Store Logging #10865

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

Conversation

dmytrostruk
Copy link
Member

@dmytrostruk dmytrostruk commented Mar 9, 2025

Motivation and Context

Related: #10596

This PR enhances the vector store functionality by adding builder pattern implementations and logging decorators for key vector data interfaces, along with supporting utilities and DI integration.

Interfaces handled:

  • IKeywordHybridSearch<TRecord>
  • IVectorizableTextSearch<TRecord>
  • IVectorizedSearch<TRecord>
  • IVectorStore
  • IVectorStoreRecordCollection<TKey, TRecord>

Class types added:

  • Builders: implement a pipeline pattern with Use and Build methods.
  • Logging Extensions: provide reusable logging methods for tasks and enumerables, handling success, failure and cancellation.
  • Logging Decorators: wrap the interfaces to add logging by using LoggingExtensions reusable logging methods.
  • Builder Extensions: Add AsBuilder methods to convert service instances into builders.
  • Logging Builder Extensions: Add UseLogging methods to integrate logging into builder pipelines.
  • Service Collection Extensions: Add Add{T} and AddKeyed{T} methods for DI registration with configurable lifetimes.

Other changes:

  • Split Verify class into Verify and KernelVerify in order to be able to use Verify methods in Microsoft.Extensions.VectorData package without a reference to Semantic Kernel specific logic, like ValidPluginName, ValidFunctionName etc.
  • Added unit tests for new classes and methods.
  • Added usage example in Concepts/Memory folder.

Usage example

Logging with manual registration:

var vectorStore = new InMemoryVectorStore()
    .AsBuilder()
    .UseLogging(this.LoggerFactory)
    .Build();

Logging with DI:

serviceCollection.AddInMemoryVectorStore();

serviceCollection
    .AddVectorStore(s => s.GetRequiredService<InMemoryVectorStore>())
    .UseLogging(this.LoggerFactory);

Contribution Checklist

@dmytrostruk dmytrostruk self-assigned this Mar 9, 2025
@dmytrostruk dmytrostruk requested a review from a team as a code owner March 9, 2025 23:01
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel kernel.core labels Mar 10, 2025
@github-actions github-actions bot changed the title [Feature Branch] .Net: Vector Store Logging .Net: [Feature Branch] .Net: Vector Store Logging Mar 10, 2025
@dmytrostruk dmytrostruk changed the title .Net: [Feature Branch] .Net: Vector Store Logging .Net: [Feature Branch] Vector Store Logging Mar 10, 2025
Copy link
Member

@markwallace-microsoft markwallace-microsoft left a comment

Choose a reason for hiding this comment

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

Just some documentation updates (I didn't comment everywhere) and the question about adding the same instance twice.

@dmytrostruk dmytrostruk merged commit 3fca31f into microsoft:feature-vector-data-telemetry Mar 12, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation kernel.core kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants