OP and Logging to Elasticsearch

This commit is contained in:
Roland Fieger
2021-10-12 16:42:24 +02:00
parent 66f8d19f67
commit e9d30aad16
8 changed files with 81 additions and 41 deletions

View File

@@ -1,27 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Repositories;
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;
using Repositories;
using Repositories.Interfaces;
using SearchLogic;
namespace FwSearchApi
{
@@ -50,13 +45,12 @@ namespace FwSearchApi
services.AddTransient<IFwMariaSearchRepo, FwMariaSearchRepo>();
services.AddTransient<ISearchLogic, SearchLogic.SearchLogic>();
services.AddSwaggerGen();
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); //needed if no Security is used when calling APM Server
services.AddOpenTelemetryTracing((builder) => builder
//.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("TxSearchApi"))
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("TxSearchApi"))
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddEntityFrameworkCoreInstrumentation()
.AddConsoleExporter()
.AddEntityFrameworkCoreInstrumentation(o => o.SetDbStatementForText = true) //logging of Statement as Span
.AddOtlpExporter(otlpOptions => {
otlpOptions.Endpoint = new Uri("http://192.168.178.44:8200");
}));
@@ -75,8 +69,6 @@ namespace FwSearchApi
app.UseSwagger();
//app.UseElasticApm(_configuration, new EfCoreDiagnosticsSubscriber());
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "FeatureWerk Search API V1");