I have an ASP.NET Core 2.1 WebApi running on a Service Fabric node behind a reverse proxy (Azure Application Gateway).
The Urls are something as follows:
- https://mycustomdomain.demo/product/api/controller/action (Public)
- http://myinternalserver:12345/product/api/controller/action (internal)
- https://mycustomdomain.demo/controller/action (Application insights request telemetry)
Application Insights is added as usual.
public void ConfigureServices(IServiceCollection services)
{
services.AddApplicationInsightsTelemetry();
new ServiceInstanceListener(serviceContext => new HttpSysCommunicationListener(serviceContext, "ServerServiceEndpoint",
(url, listener) =>
{
var endpointConfig = serviceContext.CodePackageActivationContext.GetEndpoint("ServerServiceEndpoint");
return new WebHostBuilder()
.UseHttpSys()
.ConfigureServices(services => services.AddSingleton(serviceContext))
.UseContentRoot(Directory.GetCurrentDirectory())
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
.UseStartup<Startup>()
.UseUrls($"{url}{endpointConfig.PathSuffix}") // "/product/api"
.Build();
}))
So endpointConfig.PathSuffix
is not being added to the request telemetry. What can I do to fix this? I would prefer to to write a custom telemetry initializer or processor.
I tried adding this line to my WebHostBuilder, without any change in behavior:
.Configure(app => app.UsePathBase(endpointConfig.PathSuffix))
Edit: The PathBase
is identified correctly by ASP.NET Core, but it is missing from the Request Telemetry. If I set up a standalone project without Service Fabric, PathBase is added to Request Telemetry as expected.