-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal]Implement ITelemetryInitializer to handle UseUniqueServiceUrl #13
Comments
Sorry for the delayed response. When you say it makes ServiceFabric telemetry difficult to correlate, what correlation are you talking about?
What are the sources of the above telemetry? It seems like request telemtry is gathered by the request tracking module in the AI sdk, but the message might be coming from Windows Azure Diagnostics agent running on the SF node that forwards ETW events to AI. If that is so, wouldn't the fix be make whatever component is generating the url with http:localhost1234, report the original url at which point we don't have to deal with the autogenerated guid at all? How do you propose to fix this? Is it easy to tell given a url, which part is auto generated? We would love to take a PR should the result of this thread be - we need a change. |
@nizarq I apologize for making this confusing. I will try to clear this up: It is based on HttpContext. If one is using ServiceFabricIntegrationOptions.UseUniqueServiceUrl the URL will look not very nice http://localhost:1234/{generated unique url}/mypath or http://mydomain/{generated unique ur}/mypath depending on whether developer is using UseForwardedHeaders middleware. I use following code to conditionally add my telemetry initializer.
and below is my initializer that works:
It's really trivial and it just removes first 3 segments. BUT I can make it much better if Microsoft.ServiceFabric.AspNetCore could be isolated into a separate package (today it is inside Microsoft.ServiceFabric.AspNetCore.Kestrel and Microsoft.ServiceFabric.AspNetCore.WebListener). I could then take AspNetCoreCommunicationListener and extract its url suffix like here: BTW. By correlation I mean correlation by telemetry display name or url in Application Insights UI. |
@mkosieradzki - Is ServiceFabricIntegrationOptions.UseUniqueServiceUrl only an asp.net core option. The problem it tries to solve - that of a different service using the same port after the original service had to be migrated - is not an asp.net core only possibility. Is there an equivalent for .net framework that we need to worry about as well? Also is the reverse proxy involved? Are you running the reverse proxy at http://mydomain? I imagine reverse proxy or no reverse proxy (direct calls), you would have to deal with this issue - correct? Removing the first three segments seems a little too arbitrary for the following reasons:
|
If @vturecek will agree to isolate Microsoft.ServiceFabric.AspNetCore into a separate package (microsoft/service-fabric-aspnetcore#20) we can use the listener to configure our middleware and keep everything consistent. In the meantime I will rework my middleware prototype to use UrlPrefix. |
The middleware sets Path and PathBase accordingly on HttpRequest. Path contains just your API path, e.g., /api/values, while PathBase has the unique URL path segments, e.g., /partitionId/replicaId/GUID. So rather than parse out the unique URL segments, can you just grab the value of Path? |
@vturecek I have explained why I can't do this in microsoft/service-fabric-aspnetcore#18 . Basically middleware recovers previous Path and PathBase values so during OnStarting or OnCompleted when telemetry is being generated PathBase is set to / and Path is set to full path. I was even proposing to alter this behavior for simplicity, but we agreed it's better to keep it as is for sake of consistency with other middlewares that also recover Path and PathBase. |
@mkosieradzki Path and PathBase get reset for middleware that runs before the SF middleware, but any middleware that runs after will have the unique path in PathBase. So couldn't you just run your middle after the SF middleware? |
@vturecek Not really, because:
|
@nizarq I see what @mkosieradzki is after now, this might be something we can handle in this package. |
Yeah this makes more sense now. Today - the nuget packages ( The TelemetryInitializer proposed here really only makes sense for 'asp.net core' applications. We should NOT ship it in one of the existing packages. Perhaps create an additional Microsoft.ApplciationInsights.ServiceFabric.AspNetCore? |
So I think we need two more packages: |
@mkosieradzki - I don't mind an extra package |
@nizarq thanks. When I get the green light on |
Hi @mkosieradzki - I noticed that the abstractions package is now available. Is this issue still something of interest to you? Do you plan to submit a PR or should we close it due to lack of interest? |
Hi @nizarq I will try to revisit this issue next month. I hope I can get ApplicationInsights-ServiceFabric working with .NET Standard... |
I have a change that will allow you to do that. I'll merge it soon. |
ServiceFabric AspNetCore middleware has an option ServiceFabricIntegrationOptions.UseUniqueServiceUrl. This option generates service-specific unique urls - which makes ServiceFabric telemetry difficult to correlate.
See microsoft/service-fabric-aspnetcore#18 .
IMO it would be really useful to have a telemetry initializer that strips autogenerated urls.
I can create a PR for this.
The text was updated successfully, but these errors were encountered: