some OP
This commit is contained in:
		| @@ -26,7 +26,10 @@ namespace FwSearchApi.Controllers | ||||
|         public async Task<JsonResult> GetAllLookups() | ||||
|         { | ||||
|             var result = await _lookupLogic.GetAllLookups(); | ||||
|             _logger.LogInformation($"Lookups zur Verf<72>gung gestellt von {nameof(GetAllLookups)}"); | ||||
|             if (result.GeneralResult != Datamodels.BusinessModels.GeneralResults.Success) { | ||||
|                 throw new System.Exception("das war wohl nix"); | ||||
|             } | ||||
|             _logger.LogInformation($"Lookups zur Verf<72>gung gestellt von {nameof(GetAllLookups)}"); | ||||
|             return new JsonResult(result); | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| using System.Collections.Immutable; | ||||
| using System.Buffers; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| @@ -7,6 +9,7 @@ using Microsoft.AspNetCore.Hosting; | ||||
| using Microsoft.Extensions.Configuration; | ||||
| using Microsoft.Extensions.Hosting; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using OpenTelemetry.Logs; | ||||
| using Serilog; | ||||
|  | ||||
| namespace FwSearchApi | ||||
| @@ -21,22 +24,31 @@ namespace FwSearchApi | ||||
|  | ||||
|         public static void Main(string[] args) | ||||
|         { | ||||
|             Log.Logger = new LoggerConfiguration() | ||||
|                 .ReadFrom.Configuration(Configuration) | ||||
|                 .CreateLogger(); | ||||
|             try { | ||||
|                 CreateWebHostBuilder(args).Build().Run(); | ||||
|             } | ||||
|             finally{ | ||||
|                 Log.CloseAndFlush(); | ||||
|             } | ||||
|             CreateHostBuilder(args).Build().Run(); | ||||
|         } | ||||
|  | ||||
|         public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | ||||
|             WebHost.CreateDefaultBuilder(args) | ||||
|                     .UseConfiguration(Configuration) | ||||
|                     .UseStartup<Startup>() | ||||
|                     .UseSerilog() | ||||
|                     .SuppressStatusMessages(true); | ||||
|         public static IHostBuilder CreateHostBuilder(string[] args) => | ||||
|             Host.CreateDefaultBuilder(args) | ||||
|                 .ConfigureWebHostDefaults(webBuilder =>  | ||||
|                 { | ||||
|                     webBuilder.UseStartup<Startup>(); | ||||
|                     webBuilder.UseConfiguration(Configuration); | ||||
|                 }) | ||||
|                 .ConfigureLogging((context, builder) => | ||||
|                 { | ||||
|                     builder.ClearProviders(); | ||||
|                     builder.AddConsole(); | ||||
|  | ||||
|                     builder.AddOpenTelemetry(options => | ||||
|                     { | ||||
|                         options.IncludeScopes = true; | ||||
|                         options.ParseStateValues = true; | ||||
|                         options.IncludeFormattedMessage = true; | ||||
|                         options.AddConsoleExporter(); | ||||
|                     }); | ||||
|                      | ||||
|                 }); | ||||
|          | ||||
|              | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -2,12 +2,21 @@ | ||||
|  | ||||
|   <PropertyGroup> | ||||
|     <TargetFramework>netcoreapp3.1</TargetFramework> | ||||
|     <LangVersion>10</LangVersion> | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Elastic.Apm.EntityFrameworkCore" Version="1.11.1" /> | ||||
|     <PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.11.1" /> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.16" /> | ||||
|     <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||||
|     <PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.1.0" /> | ||||
|     <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.1.0" /> | ||||
|     <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc7" /> | ||||
|     <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc7" /> | ||||
|     <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc7" /> | ||||
|     <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> | ||||
|     <PackageReference Include="serilog.sinks.console" Version="4.0.0" /> | ||||
|     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.2" /> | ||||
|     <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.2" /> | ||||
|     <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.2.2" /> | ||||
|   | ||||
| @@ -15,6 +15,13 @@ using Repositories.Interfaces; | ||||
| using BusinessLogic.LookupLogic; | ||||
| using BusinessLogic.LookupLogic.Interfaces; | ||||
| using SearchLogic; | ||||
| using OpenTelemetry.Exporter; | ||||
| using OpenTelemetry.Instrumentation.AspNetCore; | ||||
| using OpenTelemetry.Resources; | ||||
| using OpenTelemetry.Trace; | ||||
| using Elastic.Apm.AspNetCore; | ||||
| using Elastic.Apm.EntityFrameworkCore; | ||||
| using Elastic.Apm; | ||||
|  | ||||
| namespace FwSearchApi | ||||
| { | ||||
| @@ -24,11 +31,10 @@ namespace FwSearchApi | ||||
|         readonly ILogger<Startup> _logger; | ||||
|         public IConfiguration _configuration { get; } | ||||
|  | ||||
|         public Startup(IConfiguration configuration, ILogger<Startup> logger) | ||||
|         public Startup(IConfiguration configuration) | ||||
|         { | ||||
|             _configuration = configuration; | ||||
|             _logger = logger; | ||||
|             _logger.LogInformation("Starting up FeatureWerk Search API"); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         // This method gets called by the runtime. Use this method to add services to the container. | ||||
| @@ -45,7 +51,16 @@ namespace FwSearchApi | ||||
|             services.AddTransient<ISearchLogic, SearchLogic.SearchLogic>(); | ||||
|             services.AddSwaggerGen(); | ||||
|  | ||||
|             _logger.LogInformation("Services for FeatureWerkAPIs configured"); | ||||
|             services.AddOpenTelemetryTracing((builder) => builder | ||||
|                         .AddAspNetCoreInstrumentation() | ||||
|                         .AddHttpClientInstrumentation() | ||||
|                         .AddConsoleExporter() | ||||
|                         .AddOtlpExporter(otlpOptions => { | ||||
|                             otlpOptions.Endpoint = new Uri("http://192.168.178.44:8200"); | ||||
|                         })); | ||||
|                          | ||||
|  | ||||
|  | ||||
|         } | ||||
|  | ||||
|         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||||
| @@ -58,6 +73,8 @@ namespace FwSearchApi | ||||
|  | ||||
|             app.UseSwagger(); | ||||
|  | ||||
|             app.UseElasticApm(_configuration, new EfCoreDiagnosticsSubscriber()); | ||||
|  | ||||
|             app.UseSwaggerUI(c => | ||||
|             { | ||||
|                 c.SwaggerEndpoint("/swagger/v1/swagger.json", "FeatureWerk Search API V1"); | ||||
|   | ||||
| @@ -6,5 +6,13 @@ | ||||
|       "Microsoft.Hosting.Lifetime": "Information" | ||||
|     } | ||||
|   }, | ||||
|   "ElasticApm": | ||||
|     { | ||||
|       "ServerUrl": "http://192.168.178.44:8200", | ||||
|       "SecretToken": "", | ||||
|       "ServiceName": "TxSearchApi", | ||||
|       "Environment": "Development", | ||||
|       "CaptureBody": "all" | ||||
|     }, | ||||
|   "AllowedHosts": "*" | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user