forked from romansp/MiniProfiler.Elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from pawel-madurski/features/init
Inital commit
- Loading branch information
Showing
45 changed files
with
191 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,41 @@ | ||
# MiniProfiler.Elasticsearch | ||
Put your [Elasticsearch.Net and NEST](https://github.com/elastic/elasticsearch-net) requests timings directly into [MiniProfiler](https://github.com/MiniProfiler/dotnet). | ||
# MiniProfiler.OpenSearch | ||
|
||
[![Build status](https://ci.appveyor.com/api/projects/status/m15gemuqkcs1rbv4/branch/main?svg=true)](https://ci.appveyor.com/project/romansp/miniprofiler-elasticsearch/branch/main) [![Nuget feed](https://img.shields.io/nuget/vpre/MiniProfiler.Elasticsearch.svg)](https://www.nuget.org/packages/MiniProfiler.Elasticsearch) | ||
*** This project has been forked from https://github.com/romansp/MiniProfiler.Elasticsearch and compiled against OpenSearch *** | ||
|
||
![profiler-popup](https://user-images.githubusercontent.com/3474842/30780873-de83efd8-a11d-11e7-8735-49dea4a1d4f1.png) | ||
![profiler-queries](https://user-images.githubusercontent.com/3474842/30780952-edf8adea-a11e-11e7-8d64-c65331f389bf.png) | ||
Put your [OpenSearch.Net and OpencSearch.Client](https://github.com/opensearch-project/opensearch-net) requests timings directly into [MiniProfiler](https://github.com/MiniProfiler/dotnet). | ||
|
||
[![Build status](https://ci.appveyor.com/api/projects/status/e9axfh54cvn3qqti/branch/main?svg=true)](https://ci.appveyor.com/project/pawel-madurski/miniprofiler-opensearch/branch/main) | ||
![Nuget](https://img.shields.io/nuget/v/DexxLab.MiniProfiler.OpenSearch) | ||
|
||
![image](https://github.com/pawel-madurski/MiniProfiler.OpenSearch/assets/11866857/74293aab-6ad3-4ee1-8014-908d831b9646) | ||
|
||
## Usage | ||
You have two options on how to start profiling your Elastic requests. | ||
You have two options on how to start profiling your OpenSearch requests. | ||
|
||
### Option 1. Register in services collection | ||
In your `Startup.cs`, call `AddElastic()`: | ||
In your `Startup.cs`, call `AddOpenSearch()`: | ||
|
||
```c# | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMiniProfiler(options => { | ||
options.ExcludeElasticAssemblies(); | ||
options.ExcludeOpenSearchAssemblies(); | ||
}) | ||
.AddElastic(); | ||
.AddOpenSearch(); | ||
} | ||
``` | ||
|
||
### Option 2. Create profiled client manually | ||
Update usages of `ElasticClient` or `ElasticLowLevelClient` with their respected profiled version `ProfiledElasticClient` or `ProfiledElasticLowLevelClient`. | ||
Update usages of `OpenSearchClient` or `OpenSearchLowLevelClient` with their respected profiled version `ProfiledOpenSearchClient` or `ProfiledOpenSearchLowLevelClient`. | ||
|
||
```c# | ||
services.AddSingleton<IElasticClient>(x => | ||
services.AddSingleton<IOpenSearchClient>(x => | ||
{ | ||
var node = new Uri("http://localhost:9200"); | ||
var connectionSettings = new ConnectionSettings(node).DefaultIndex("elasticsearch-sample"); | ||
return new ProfiledElasticClient(connectionSettings); | ||
var connectionSettings = new ConnectionSettings(node).DefaultIndex("opensearch-sample"); | ||
return new ProfiledOpenSearchClient(connectionSettings); | ||
}); | ||
``` | ||
|
||
## Sample | ||
See [Sample.Elasticsearch.Core](https://github.com/romansp/MiniProfiler.Elasticsearch/tree/main/samples/Sample.Elasticsearch.Core) for working example. | ||
See [Sample.OpenSearch.Core](https://github.com/pawel-madurski/MiniProfiler.OpenSearch/tree/main/samples/Sample.OpenSearch.Core) for working example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...search.Core/Controllers/HomeController.cs → ...search.Core/Controllers/HomeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
samples/Sample.Elasticsearch.Core/Program.cs → samples/Sample.Opensearch.Core/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sticsearch.Core/Views/_ViewImports.cshtml → ...Opensearch.Core/Views/_ViewImports.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
src/MiniProfiler.Elasticsearch/MiniProfilerBaseOptionsExtensions.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
src/MiniProfiler.Elasticsearch/ProfiledElasticLowLevelClient.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Collections.Generic; | ||
using StackExchange.Profiling.Internal; | ||
|
||
namespace StackExchange.Profiling.OpenSearch.Internal; | ||
|
||
internal static class ProfilerUtils { | ||
/// <summary> | ||
/// OpenSearch-related assemblies to exclude from profiling | ||
/// </summary> | ||
internal static HashSet<string> ExcludedAssemblies { get; } = new HashSet<string> { | ||
"OpenSearch.Client", | ||
"OpenSearch.Net.Diagnostics", | ||
typeof(MiniProfilerOpenSearch).Namespace, | ||
typeof(MiniProfilerOpenSearch).Assembly.GetName().Name, | ||
}; | ||
|
||
/// <summary> | ||
/// Excludes OpenSearch assemblies from passed in <paramref name="options"/>, so they won't be included into <see cref="MiniProfiler"/> timings' call-stack. | ||
/// </summary> | ||
/// <param name="options"></param> | ||
internal static void ExcludeOpenSearchAssemblies(this MiniProfilerBaseOptions options) { | ||
foreach (var excludedAssembly in ExcludedAssemblies) { | ||
options.ExcludeAssembly(excludedAssembly); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Excludes OpenSearch assemblies from <see cref="MiniProfiler.DefaultOptions"/>, so they won't be included into <see cref="MiniProfiler"/> timings' call-stack. | ||
/// </summary> | ||
internal static void ExcludeOpenSearchAssemblies() => MiniProfiler.DefaultOptions.ExcludeOpenSearchAssemblies(); | ||
} |
Oops, something went wrong.