Skip to content
This repository was archived by the owner on Jul 5, 2020. It is now read-only.

Setting dependency telemetry timestamp to when the activity started#670

Merged
SergeyKanzhelev merged 1 commit into
microsoft:developfrom
billpratt:fix/netcore2DependencyTimestamp
Aug 18, 2017
Merged

Setting dependency telemetry timestamp to when the activity started#670
SergeyKanzhelev merged 1 commit into
microsoft:developfrom
billpratt:fix/netcore2DependencyTimestamp

Conversation

@billpratt

@billpratt billpratt commented Aug 17, 2017

Copy link
Copy Markdown
Contributor

In .NET Core 2.0, a dependency telemetry timestamp is set when the activity finished, not when it started. This PR is to set the correct timestamp.

I started to notice this when I upgraded an app to .NET Core 2.0 and looked at the telemetry data in App Insights. Below is a screenshot of a dependency that took 112ms to complete. Notice the placement dependency in the graph.

screenshot at aug 17 18-04-04

The request telemetry JSON (abbreviated)

{
    "name": "Microsoft.ApplicationInsights.Dev.foo.Request",
    "time": "2017-08-17T20:48:03.9571942Z",
    "iKey": "...",
    "data": {
        "baseType": "RequestData",
        "baseData": {
            "ver": 2,
            "id": "...",
            "name": "...",
            "duration": "00:00:00.1258569",
            "success": true,
            "responseCode": "200"
        }
    }
}

The dependency telemetry JSON (abbreviated)

{
    "name": "Microsoft.ApplicationInsights.Dev.foo.RemoteDependency",
    "time": "2017-08-17T20:48:04.0709835Z",
    "iKey": "...",
    "data": {
        "baseType": "RemoteDependencyData",
        "baseData": {
            "ver": 2,
            "name": "...",
            "id": "...",
            "data": "...",
            "duration": "00:00:00.1122218",
            "resultCode": "200",
            "success": true,
            "type": "Http (tracked component)",
            "target": "..."
        }
    }
}

If you take the difference between when the request started 2017-08-17T20:48:03.9571942Z and when the dependency is reported as started 2017-08-17T20:48:04.0709835Z you'll notice its around 112ms, which is the same value as the duration.

@msftclas

Copy link
Copy Markdown

@billpratt,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@msftclas

Copy link
Copy Markdown

@billpratt, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, Microsoft Pull Request Bot

@billpratt billpratt changed the title Setting dependency telemetry timestamp to when the activity started, … Setting dependency telemetry timestamp to when the activity started Aug 17, 2017
@cijothomas

Copy link
Copy Markdown
Contributor

Thanks!

@SergeyKanzhelev

Copy link
Copy Markdown
Contributor

This fixes #658

@SergeyKanzhelev SergeyKanzhelev merged commit 0f7e08f into microsoft:develop Aug 18, 2017
@billpratt

billpratt commented Aug 18, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for merging. Do you have a rough idea on when this fix will get pushed?

@SergeyKanzhelev

Copy link
Copy Markdown
Contributor

@billpratt 2.5-beta1 will be ready in a month or so (roughly, not a commitment). Meanwhile to work around this issue you can create a telemetry initializer that will rewrite the start time with end time minus duration as a workaround.

@billpratt

Copy link
Copy Markdown
Contributor Author

@SergeyKanzhelev How would I access the end time in the initializer? DependencyTelemetry has a deprecated StartTime but no EndTime

@SergeyKanzhelev

Copy link
Copy Markdown
Contributor

end time is a current time

@billpratt

Copy link
Copy Markdown
Contributor Author

@SergeyKanzhelev Will 2.5 be coming out soon?

@cijothomas

Copy link
Copy Markdown
Contributor

2.5 beta1 for Web SDK should be out in 2-3 days on nuget, followed by asp.net core sdk for application insights.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants