From 4ec17fc9776b0cca913e104b7575ff694bb9fc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Madurski?= Date: Fri, 15 Sep 2023 08:48:57 -0500 Subject: [PATCH 1/7] Inital commit --- LICENSE.md | 4 +-- ...csearch.sln => MiniProfiler.OpenSearch.sln | 6 ++-- README.md | 25 +++++++------ appveyor.yml | 2 +- .../Controllers/HomeController.cs | 8 ++--- .../Program.cs | 10 +++--- .../Properties/launchSettings.json | 2 +- .../Sample.OpenSearch.Core.csproj} | 6 ++-- .../Views/Home/Index.cshtml | 0 .../Views/Shared/_Layout.cshtml | 4 +-- .../Views/_ViewImports.cshtml | 2 +- .../Views/_ViewStart.cshtml | 0 .../appsettings.Development.json | 0 .../appsettings.json | 0 .../wwwroot/css/site.css | 0 .../wwwroot/favicon.ico | Bin .../wwwroot/lib/bootstrap/LICENSE | 0 .../lib/bootstrap/dist/css/bootstrap-grid.css | 0 .../bootstrap/dist/css/bootstrap-grid.css.map | 0 .../bootstrap/dist/css/bootstrap-grid.min.css | 0 .../dist/css/bootstrap-grid.min.css.map | 0 .../bootstrap/dist/css/bootstrap-reboot.css | 0 .../dist/css/bootstrap-reboot.css.map | 0 .../dist/css/bootstrap-reboot.min.css | 0 .../dist/css/bootstrap-reboot.min.css.map | 0 .../lib/bootstrap/dist/css/bootstrap.css | 0 .../lib/bootstrap/dist/css/bootstrap.css.map | 0 .../lib/bootstrap/dist/css/bootstrap.min.css | 0 .../bootstrap/dist/css/bootstrap.min.css.map | 0 src/Directory.Build.props | 10 +++--- .../Internal/ProfilerUtils.cs | 32 ----------------- .../MiniProfilerBaseOptionsExtensions.cs | 34 ------------------ .../ProfiledElasticClient.cs | 18 ---------- .../ProfiledElasticLowLevelClient.cs | 18 ---------- .../Internal/MiniProfilerOpenSearch.cs} | 9 ++--- .../Internal/ProfilerUtils.cs | 31 ++++++++++++++++ .../MiniProfiler.OpenSearch.csproj} | 8 ++++- .../MiniProfilerBaseOptionsExtensions.cs | 34 ++++++++++++++++++ ...MiniProfilerServiceCollectionExtensions.cs | 10 +++--- .../OpenSearchDiagnosticListener.cs} | 15 ++++---- .../ProfiledOpenSeaarchClient.cs | 18 ++++++++++ .../ProfiledOpenSearchLowLevelClient.cs | 19 ++++++++++ .../ElasticClientTests.cs | 34 +++++++++--------- .../MiniProfiler.OpenSearch.Tests.csproj} | 2 +- 44 files changed, 186 insertions(+), 175 deletions(-) rename MiniProfiler.Elasticsearch.sln => MiniProfiler.OpenSearch.sln (88%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/Controllers/HomeController.cs (88%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/Program.cs (69%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/Properties/launchSettings.json (94%) rename samples/{Sample.Elasticsearch.Core/Sample.Elasticsearch.Core.csproj => Sample.Opensearch.Core/Sample.OpenSearch.Core.csproj} (60%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/Views/Home/Index.cshtml (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/Views/Shared/_Layout.cshtml (94%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/Views/_ViewImports.cshtml (78%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/Views/_ViewStart.cshtml (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/appsettings.Development.json (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/appsettings.json (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/css/site.css (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/favicon.ico (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/LICENSE (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css.map (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css.map (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap.css (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap.css.map (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css (100%) rename samples/{Sample.Elasticsearch.Core => Sample.Opensearch.Core}/wwwroot/lib/bootstrap/dist/css/bootstrap.min.css.map (100%) delete mode 100644 src/MiniProfiler.Elasticsearch/Internal/ProfilerUtils.cs delete mode 100644 src/MiniProfiler.Elasticsearch/MiniProfilerBaseOptionsExtensions.cs delete mode 100644 src/MiniProfiler.Elasticsearch/ProfiledElasticClient.cs delete mode 100644 src/MiniProfiler.Elasticsearch/ProfiledElasticLowLevelClient.cs rename src/{MiniProfiler.Elasticsearch/Internal/MiniProfilerElasticsearch.cs => MiniProfiler.OpenSearch/Internal/MiniProfilerOpenSearch.cs} (78%) create mode 100644 src/MiniProfiler.OpenSearch/Internal/ProfilerUtils.cs rename src/{MiniProfiler.Elasticsearch/MiniProfiler.Elasticsearch.csproj => MiniProfiler.OpenSearch/MiniProfiler.OpenSearch.csproj} (57%) create mode 100644 src/MiniProfiler.OpenSearch/MiniProfilerBaseOptionsExtensions.cs rename src/{MiniProfiler.Elasticsearch => MiniProfiler.OpenSearch}/MiniProfilerServiceCollectionExtensions.cs (66%) rename src/{MiniProfiler.Elasticsearch/ElasticDiagnosticListener.cs => MiniProfiler.OpenSearch/OpenSearchDiagnosticListener.cs} (87%) create mode 100644 src/MiniProfiler.OpenSearch/ProfiledOpenSeaarchClient.cs create mode 100644 src/MiniProfiler.OpenSearch/ProfiledOpenSearchLowLevelClient.cs rename tests/{MiniProfiler.Elasticsearch.Tests => MiniProfiler.OpenSearch.Tests}/ElasticClientTests.cs (72%) rename tests/{MiniProfiler.Elasticsearch.Tests/MiniProfiler.Elasticsearch.Tests.csproj => MiniProfiler.OpenSearch.Tests/MiniProfiler.OpenSearch.Tests.csproj} (91%) diff --git a/LICENSE.md b/LICENSE.md index 6584c29..8ed7e2e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ -The MIT License (MIT) +The MIT License (MIT) -Copyright (c) 2022 Raman Paulau +Copyright (c) 2022 Paweł Madurski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MiniProfiler.Elasticsearch.sln b/MiniProfiler.OpenSearch.sln similarity index 88% rename from MiniProfiler.Elasticsearch.sln rename to MiniProfiler.OpenSearch.sln index 6427229..056ea5f 100644 --- a/MiniProfiler.Elasticsearch.sln +++ b/MiniProfiler.OpenSearch.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.31019.35 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.Elasticsearch", "src\MiniProfiler.Elasticsearch\MiniProfiler.Elasticsearch.csproj", "{618356CB-5D70-48F3-8B1B-6DA56120E3AC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.OpenSearch", "src\MiniProfiler.OpenSearch\MiniProfiler.OpenSearch.csproj", "{618356CB-5D70-48F3-8B1B-6DA56120E3AC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{8991B302-DBA8-4CF8-88D2-5B276C9B37CB}" ProjectSection(SolutionItems) = preProject @@ -23,11 +23,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{16FF3561-A01 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{F57D62CB-485F-4E7A-9A23-8165941D5F41}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Elasticsearch.Core", "samples\Sample.Elasticsearch.Core\Sample.Elasticsearch.Core.csproj", "{275500BB-7676-4B66-93E3-422EF42A4678}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.OpenSearch.Core", "samples\Sample.OpenSearch.Core\Sample.OpenSearch.Core.csproj", "{275500BB-7676-4B66-93E3-422EF42A4678}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{C0A0C99B-744D-4C56-A53E-E22C51137ADF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.Elasticsearch.Tests", "tests\MiniProfiler.Elasticsearch.Tests\MiniProfiler.Elasticsearch.Tests.csproj", "{2CD0A79C-D950-44AE-BBEA-ACCD50BEF00E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfiler.OpenSearch.Tests", "tests\MiniProfiler.OpenSearch.Tests\MiniProfiler.OpenSearch.Tests.csproj", "{2CD0A79C-D950-44AE-BBEA-ACCD50BEF00E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{0A8BCF98-DC77-4CE9-B60B-3760D80E2955}" EndProject diff --git a/README.md b/README.md index 972a023..d07602c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -# 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 + +*** This project has been forked from https://github.com/romansp/MiniProfiler.Elasticsearch and compiled against OpenSearch *** + +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/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) @@ -7,32 +10,32 @@ Put your [Elasticsearch.Net and NEST](https://github.com/elastic/elasticsearch-n ![profiler-queries](https://user-images.githubusercontent.com/3474842/30780952-edf8adea-a11e-11e7-8d64-c65331f389bf.png) ## 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(x => +services.AddSingleton(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. diff --git a/appveyor.yml b/appveyor.yml index c23ead2..6076579 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,7 @@ nuget: before_build: - cmd: nuget restore build: - project: MiniProfiler.Elasticsearch.sln + project: MiniProfiler.OpenSearch.sln verbosity: minimal publish_nuget: true publish_nuget_symbols: true diff --git a/samples/Sample.Elasticsearch.Core/Controllers/HomeController.cs b/samples/Sample.Opensearch.Core/Controllers/HomeController.cs similarity index 88% rename from samples/Sample.Elasticsearch.Core/Controllers/HomeController.cs rename to samples/Sample.Opensearch.Core/Controllers/HomeController.cs index 12831ac..bef5aba 100644 --- a/samples/Sample.Elasticsearch.Core/Controllers/HomeController.cs +++ b/samples/Sample.Opensearch.Core/Controllers/HomeController.cs @@ -1,15 +1,15 @@ using Microsoft.AspNetCore.Mvc; -using Nest; +using OpenSearch.Client; using StackExchange.Profiling; -namespace Sample.Elasticsearch.Core.Controllers; +namespace Sample.OpenSearch.Core.Controllers; public record Person(string Id, string FirstName, string LastName); public class HomeController : Controller { - private readonly IElasticClient _client; + private readonly IOpenSearchClient _client; - public HomeController(IElasticClient client) { + public HomeController(IOpenSearchClient client) { _client = client; } diff --git a/samples/Sample.Elasticsearch.Core/Program.cs b/samples/Sample.Opensearch.Core/Program.cs similarity index 69% rename from samples/Sample.Elasticsearch.Core/Program.cs rename to samples/Sample.Opensearch.Core/Program.cs index 96b2196..da52745 100644 --- a/samples/Sample.Elasticsearch.Core/Program.cs +++ b/samples/Sample.Opensearch.Core/Program.cs @@ -1,15 +1,15 @@ -using Nest; +using OpenSearch.Client; using StackExchange.Profiling; var builder = WebApplication.CreateBuilder(args); var services = builder.Services; services.AddControllersWithViews(); -services.AddMiniProfiler(options => options.ExcludeElasticAssemblies()).AddElastic(); -services.AddSingleton(_ => { +services.AddMiniProfiler(options => options.ExcludeOpenSearchAssemblies()).AddOpenSearch(); +services.AddSingleton(_ => { var node = new Uri("http://localhost:9200"); - var connectionSettings = new ConnectionSettings(node).DefaultIndex("elasticsearch-sample"); - return new ElasticClient(connectionSettings); + var connectionSettings = new ConnectionSettings(node).DefaultIndex("opensearch-sample"); + return new OpenSearchClient(connectionSettings); }); services.Configure(options => { diff --git a/samples/Sample.Elasticsearch.Core/Properties/launchSettings.json b/samples/Sample.Opensearch.Core/Properties/launchSettings.json similarity index 94% rename from samples/Sample.Elasticsearch.Core/Properties/launchSettings.json rename to samples/Sample.Opensearch.Core/Properties/launchSettings.json index bb092fa..a716df8 100644 --- a/samples/Sample.Elasticsearch.Core/Properties/launchSettings.json +++ b/samples/Sample.Opensearch.Core/Properties/launchSettings.json @@ -8,7 +8,7 @@ } }, "profiles": { - "Sample.Elasticsearch.Core._6": { + "Sample.OpenSearch.Core._6": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, diff --git a/samples/Sample.Elasticsearch.Core/Sample.Elasticsearch.Core.csproj b/samples/Sample.Opensearch.Core/Sample.OpenSearch.Core.csproj similarity index 60% rename from samples/Sample.Elasticsearch.Core/Sample.Elasticsearch.Core.csproj rename to samples/Sample.Opensearch.Core/Sample.OpenSearch.Core.csproj index f08cd5d..6ebfae1 100644 --- a/samples/Sample.Elasticsearch.Core/Sample.Elasticsearch.Core.csproj +++ b/samples/Sample.Opensearch.Core/Sample.OpenSearch.Core.csproj @@ -4,17 +4,17 @@ net6.0 enable enable - Sample.Elasticsearch.Core + Sample.Opensearch.Core - + - + diff --git a/samples/Sample.Elasticsearch.Core/Views/Home/Index.cshtml b/samples/Sample.Opensearch.Core/Views/Home/Index.cshtml similarity index 100% rename from samples/Sample.Elasticsearch.Core/Views/Home/Index.cshtml rename to samples/Sample.Opensearch.Core/Views/Home/Index.cshtml diff --git a/samples/Sample.Elasticsearch.Core/Views/Shared/_Layout.cshtml b/samples/Sample.Opensearch.Core/Views/Shared/_Layout.cshtml similarity index 94% rename from samples/Sample.Elasticsearch.Core/Views/Shared/_Layout.cshtml rename to samples/Sample.Opensearch.Core/Views/Shared/_Layout.cshtml index a360b7d..8b64b67 100644 --- a/samples/Sample.Elasticsearch.Core/Views/Shared/_Layout.cshtml +++ b/samples/Sample.Opensearch.Core/Views/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewData["Title"] - Sample.Elasticsearch.Core + @ViewData["Title"] - Sample.OpenSearch.Core @@ -21,7 +21,7 @@