https://github.com/romansp/MiniProfiler.Elasticsearch
Elasticsearch.Net/NEST client for logging to MiniProfiler
https://github.com/romansp/MiniProfiler.Elasticsearch
c-sharp elasticsearch miniprofiler nest
Last synced: about 1 month ago
JSON representation
Elasticsearch.Net/NEST client for logging to MiniProfiler
- Host: GitHub
- URL: https://github.com/romansp/MiniProfiler.Elasticsearch
- Owner: romansp
- License: mit
- Created: 2015-03-31T12:37:03.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2022-11-30T19:29:38.000Z (over 2 years ago)
- Last Synced: 2024-11-13T04:53:25.362Z (7 months ago)
- Topics: c-sharp, elasticsearch, miniprofiler, nest
- Language: C#
- Size: 1.19 MB
- Stars: 20
- Watchers: 6
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MiniProfiler.Elasticsearch
Put your [Elasticsearch.Net and NEST](https://github.com/elastic/elasticsearch-net) requests timings directly into [MiniProfiler](https://github.com/MiniProfiler/dotnet).[](https://ci.appveyor.com/project/romansp/miniprofiler-elasticsearch/branch/main) [](https://www.nuget.org/packages/MiniProfiler.Elasticsearch)

## Usage
You have two options on how to start profiling your Elastic requests.### Option 1. Register in services collection
In your `Startup.cs`, call `AddElastic()`:```c#
public void ConfigureServices(IServiceCollection services)
{
services.AddMiniProfiler(options => {
options.ExcludeElasticAssemblies();
})
.AddElastic();
}
```### Option 2. Create profiled client manually
Update usages of `ElasticClient` or `ElasticLowLevelClient` with their respected profiled version `ProfiledElasticClient` or `ProfiledElasticLowLevelClient`.```c#
services.AddSingleton(x =>
{
var node = new Uri("http://localhost:9200");
var connectionSettings = new ConnectionSettings(node).DefaultIndex("elasticsearch-sample");
return new ProfiledElasticClient(connectionSettings);
});
```## Sample
See [Sample.Elasticsearch.Core](https://github.com/romansp/MiniProfiler.Elasticsearch/tree/main/samples/Sample.Elasticsearch.Core) for working example.