Reputation: 105
I am using Application Insights to track usage of my application. In my service layer I am using the App Insights API to manually track requests and exceptions and have disabled the default sets of telemetry initializers and modules that track request and exceptions in favor of some custom instrumentation based on the framework I am using. However, when I manually track a request like this I do not see any user information in the request details on the Application Insights dashboard.
A simplified version that demonstrates the issue I am having:
Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active
.InstrumentationKey = "<InstrumentationKey>";
var tc = new TelemetryClient();
var request = new RequestTelemetry();
request.Context.User.Id = "1234";
request.Name = "Test Request";
tc.TrackRequest(request);
EDIT 11/30/15
This was a bug in the application insights portal. It has since been resolved.
Upvotes: 5
Views: 2653
Reputation: 21
I recently discovered that if UserAgent is not set in the telemetry context, the user and session data will be ignored. Try setting Context.User.UserAgent to something (ideally HttpContext.Request.UserAgent but any non-empty string should work).
Upvotes: 1
Reputation: 66
It should work. We are investigating the issue.
I created an issue here: https://github.com/Microsoft/ApplicationInsights-dotnet/issues/111
Upvotes: 2
Reputation: 901
Try setting SessionId, in addition to Userid. We automatically nullify Userid when sessionId is null
Upvotes: 1
Reputation: 21
That should work, I've done something similar. To clarify you are seeing your custom request telemetry show up in the dashboard but you're not seeing any data in your users charts? You could try also setting the AuthenticatedUserId field as well to see if that works.
Upvotes: 1