some OP
This commit is contained in:
@@ -26,7 +26,7 @@ namespace Repositories
|
|||||||
{
|
{
|
||||||
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
|
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development")
|
||||||
{
|
{
|
||||||
_dbContext._connectionString = "SERVER=127.0.0.1;DATABASE=testdb;PORT=3306;USER=root;PASSWORD=example";
|
_dbContext._connectionString = "SERVER=192.168.178.44;DATABASE=fwTest;PORT=3330;USER=root;PASSWORD=$64,Rf1209";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ namespace Repositories
|
|||||||
_logger.LogError(ex, "Error reading Lookup Data");
|
_logger.LogError(ex, "Error reading Lookup Data");
|
||||||
return new DataResult<List<LookupCategory>>
|
return new DataResult<List<LookupCategory>>
|
||||||
{
|
{
|
||||||
UserMessage = "Daten f<>r Lookups konnten nicht gelesen werden.",
|
UserMessage = "Daten f<>r Lookups konnten nicht gelesen werden.",
|
||||||
ServerMessage = ex.Message,
|
ServerMessage = ex.Message,
|
||||||
GeneralResult = GeneralResults.DatabaseError,
|
GeneralResult = GeneralResults.DatabaseError,
|
||||||
StackTrace = ex.StackTrace
|
StackTrace = ex.StackTrace
|
||||||
@@ -79,7 +79,7 @@ namespace Repositories
|
|||||||
_logger.LogError(ex, $"Error reading Lookup Category with Id: {id}");
|
_logger.LogError(ex, $"Error reading Lookup Category with Id: {id}");
|
||||||
return new DataResult<LookupCategory>
|
return new DataResult<LookupCategory>
|
||||||
{
|
{
|
||||||
UserMessage = $"Daten f<>r Lookup Kategorie mit Id {id} konnten nicht gelesen werden.",
|
UserMessage = $"Daten f<>r Lookup Kategorie mit Id {id} konnten nicht gelesen werden.",
|
||||||
ServerMessage = ex.Message,
|
ServerMessage = ex.Message,
|
||||||
GeneralResult = GeneralResults.DatabaseError,
|
GeneralResult = GeneralResults.DatabaseError,
|
||||||
StackTrace = ex.StackTrace
|
StackTrace = ex.StackTrace
|
||||||
@@ -103,7 +103,7 @@ namespace Repositories
|
|||||||
_logger.LogError(ex, $"Error reading Lookup Category with Name: {categoryName}");
|
_logger.LogError(ex, $"Error reading Lookup Category with Name: {categoryName}");
|
||||||
return new DataResult<List<LookupCategory>>
|
return new DataResult<List<LookupCategory>>
|
||||||
{
|
{
|
||||||
UserMessage = $"Daten f<>r Lookup Kategorie mit Namen {categoryName} konnten nicht gelesen werden.",
|
UserMessage = $"Daten f<>r Lookup Kategorie mit Namen {categoryName} konnten nicht gelesen werden.",
|
||||||
ServerMessage = ex.Message,
|
ServerMessage = ex.Message,
|
||||||
GeneralResult = GeneralResults.DatabaseError,
|
GeneralResult = GeneralResults.DatabaseError,
|
||||||
StackTrace = ex.StackTrace
|
StackTrace = ex.StackTrace
|
||||||
@@ -127,7 +127,7 @@ namespace Repositories
|
|||||||
_logger.LogError(ex, "Error reading active Lookup Data");
|
_logger.LogError(ex, "Error reading active Lookup Data");
|
||||||
return new DataResult<List<LookupCategory>>
|
return new DataResult<List<LookupCategory>>
|
||||||
{
|
{
|
||||||
UserMessage = "Daten f<>r aktive Lookups konnten nicht gelesen werden.",
|
UserMessage = "Daten f<>r aktive Lookups konnten nicht gelesen werden.",
|
||||||
ServerMessage = ex.Message,
|
ServerMessage = ex.Message,
|
||||||
GeneralResult = GeneralResults.DatabaseError,
|
GeneralResult = GeneralResults.DatabaseError,
|
||||||
StackTrace = ex.StackTrace
|
StackTrace = ex.StackTrace
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ namespace FwSearchApi.Controllers
|
|||||||
public async Task<JsonResult> GetAllLookups()
|
public async Task<JsonResult> GetAllLookups()
|
||||||
{
|
{
|
||||||
var result = await _lookupLogic.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);
|
return new JsonResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using System.Collections.Immutable;
|
||||||
|
using System.Buffers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -7,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using OpenTelemetry.Logs;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
namespace FwSearchApi
|
namespace FwSearchApi
|
||||||
@@ -21,22 +24,31 @@ namespace FwSearchApi
|
|||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Log.Logger = new LoggerConfiguration()
|
CreateHostBuilder(args).Build().Run();
|
||||||
.ReadFrom.Configuration(Configuration)
|
|
||||||
.CreateLogger();
|
|
||||||
try {
|
|
||||||
CreateWebHostBuilder(args).Build().Run();
|
|
||||||
}
|
|
||||||
finally{
|
|
||||||
Log.CloseAndFlush();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||||
WebHost.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
.UseConfiguration(Configuration)
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
.UseStartup<Startup>()
|
{
|
||||||
.UseSerilog()
|
webBuilder.UseStartup<Startup>();
|
||||||
.SuppressStatusMessages(true);
|
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>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
<LangVersion>10</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.16" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<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.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" Version="6.2.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.2.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" 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;
|
||||||
using BusinessLogic.LookupLogic.Interfaces;
|
using BusinessLogic.LookupLogic.Interfaces;
|
||||||
using SearchLogic;
|
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
|
namespace FwSearchApi
|
||||||
{
|
{
|
||||||
@@ -24,11 +31,10 @@ namespace FwSearchApi
|
|||||||
readonly ILogger<Startup> _logger;
|
readonly ILogger<Startup> _logger;
|
||||||
public IConfiguration _configuration { get; }
|
public IConfiguration _configuration { get; }
|
||||||
|
|
||||||
public Startup(IConfiguration configuration, ILogger<Startup> logger)
|
public Startup(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_configuration = 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.
|
// 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.AddTransient<ISearchLogic, SearchLogic.SearchLogic>();
|
||||||
services.AddSwaggerGen();
|
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.
|
// 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.UseSwagger();
|
||||||
|
|
||||||
|
app.UseElasticApm(_configuration, new EfCoreDiagnosticsSubscriber());
|
||||||
|
|
||||||
app.UseSwaggerUI(c =>
|
app.UseSwaggerUI(c =>
|
||||||
{
|
{
|
||||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "FeatureWerk Search API V1");
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "FeatureWerk Search API V1");
|
||||||
|
|||||||
@@ -6,5 +6,13 @@
|
|||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ElasticApm":
|
||||||
|
{
|
||||||
|
"ServerUrl": "http://192.168.178.44:8200",
|
||||||
|
"SecretToken": "",
|
||||||
|
"ServiceName": "TxSearchApi",
|
||||||
|
"Environment": "Development",
|
||||||
|
"CaptureBody": "all"
|
||||||
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user