none
Custom Session tracking - no session duration metric available

    Question

  • ## Summary

    I've customized session tracking within AI by adding a TelemetryInitializer.

    This is working in part, but session duration metrics are not being tracked. Please can you guide me where I can customize AI further.

    ## Details

    Clients connecting to our MS MVC Web API 2 do not use cookies and so the standard mechanism in AI for session tracking is not applicable.

    Instead our custom TelemetryInitializer will set the context.Session.Id to the value of custom HTTP header.

    This seems to be working in as far as I see certain telemetry metrics in the Azure Portal "light up". For example I get to see the option "Related Items" > "All available telemetry for this operation". Clicking on this link shows me all requests with the same session id that my custom TelemetryInitializer has set.

    However, when I go to add a chart that displays Session duration, the chart displays the message "No data for 'session duration'".

    Clearly setting session id in a custom TelemetryInitializer is only part of the solution. What other areas of AI do I need to customize to enable session duration tracking?

    ### Additional setup details

    • I've removed SessionTelemetryInitializer from the ApplicationInsights.config
    • My custom TelemetryInitializer is added as the last initializer within ApplicationInsights.config
    • AI version in use: 2.1.0-beta4
    • Javascript clients have NOT been instrumented with AI (ie javascript SDK is not being included)

    Thanks

    Chrisitian

    Thursday, May 19, 2016 6:47 AM

Answers

  • Hi Christian,

    We are no longer calculating session duration and other usage metrics. We haven't done a good job of communicating these changes and I've just added an announcement about this: https://github.com/Microsoft/ApplicationInsights-Announcements/issues/10

    As part of the announcement I included an example of how session duration can be calculated using Application Analytics. In your case, sounds like using requests would be the right approach. Can you please try this:

    requests //or change to whatever type you feel is represented the most in your scenario
    | where session_Id != ""
    | summarize max(timestamp), min(timestamp) by session_Id
    | extend sessionDurationSeconds=todouble(max_timestamp-min_timestamp)/10000000.00 //convert timespan to ticks and divide by 10mln to get seconds
    | summarize percentile(sessionDurationSeconds, 50) , stdev(sessionDurationSeconds), avg(sessionDurationSeconds), count(sessionDurationSeconds) by bin(min_timestamp,1d)
    | order by min_timestamp asc

    Thanks!

    Alex


    www.twitter.com/bulankou

    Thursday, May 19, 2016 4:06 PM

All replies

  • Hi Christian,

    We are no longer calculating session duration and other usage metrics. We haven't done a good job of communicating these changes and I've just added an announcement about this: https://github.com/Microsoft/ApplicationInsights-Announcements/issues/10

    As part of the announcement I included an example of how session duration can be calculated using Application Analytics. In your case, sounds like using requests would be the right approach. Can you please try this:

    requests //or change to whatever type you feel is represented the most in your scenario
    | where session_Id != ""
    | summarize max(timestamp), min(timestamp) by session_Id
    | extend sessionDurationSeconds=todouble(max_timestamp-min_timestamp)/10000000.00 //convert timespan to ticks and divide by 10mln to get seconds
    | summarize percentile(sessionDurationSeconds, 50) , stdev(sessionDurationSeconds), avg(sessionDurationSeconds), count(sessionDurationSeconds) by bin(min_timestamp,1d)
    | order by min_timestamp asc

    Thanks!

    Alex


    www.twitter.com/bulankou

    Thursday, May 19, 2016 4:06 PM
  • OK will try this instead.

    So are you going to be also removing those usage metrics as options from the metrics explorer?

    Thanks

    Christian

    Thursday, May 19, 2016 4:17 PM
  • Thanks for pointing this out! - we'll remove them from ME.


    www.twitter.com/bulankou

    Thursday, May 19, 2016 9:52 PM