Skip to content
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

Lost many context fields in 2.5.0 #708

Closed
stefangordon opened this issue Feb 19, 2018 · 8 comments
Closed

Lost many context fields in 2.5.0 #708

stefangordon opened this issue Feb 19, 2018 · 8 comments
Labels
Milestone

Comments

@stefangordon
Copy link

I am having trouble tracking down the expected behavior, but in the latest version various important context fields such as Context.Component.Version are no longer being transmitted to the service and show as "Undefined" in my data. Upon examining the telemetry object, I see these tags are showing up under the "Sanitized" property. Is this expected behavior and how do I resolve? Thanks!

Repro Steps

            telemetry = new TelemetryClient();

            // Telemetry setup
            telemetry.InstrumentationKey = "<key>";
            telemetry.Context.User.Id = Environment.UserName;
            telemetry.Context.Session.Id = SessionId;
            telemetry.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
            telemetry.Context.Device.Id = MachineId;
            telemetry.Context.Component.Version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() 

Actual Behavior

Version shows up in Azure portal as [undefined]

Expected Behavior

Version should show up correctly....

Version Info

SDK Version : 2.5.0
.NET Version : 4.5.2
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : c#/nuget
OS : Windows 10

@stefangordon
Copy link
Author

Note, reverting to 2.4.0 resolved my issue.

@older
Copy link

older commented Feb 20, 2018

Looks like the same problem as #706

@TimothyMothra
Copy link
Member

@lmolkova Can you please review this?
This seems to be related to PR #677

@TimothyMothra
Copy link
Member

Hi @pharring, can you please clarify where?

@pharring
Copy link
Member

I'm sorry, I deleted my comment because I think it was unrelated and distracted from the issue at hand.
But, for the record: I was reviewing the aforementioned PR #677 and noted that we didn't call telemetryClient.Initialize after constructing the OperationTelemetry here https://github.com/Microsoft/ApplicationInsights-dotnet/pull/677/files#diff-498e5cc99a0c604df36160a534acf301R236

@lmolkova
Copy link
Member

lmolkova commented Feb 21, 2018 via email

@lmolkova
Copy link
Member

The problem is indeed easy to repo

            var telemetry = new TelemetryClient();

            // Telemetry setup
            telemetry.Context.Operation.Id = "124234234";
            
            var dep =new DependencyTelemetry();
            telemetry.TrackDependency(dep);
            Assert.Equals(dep.Context.Operation.Id, "124234234"); Fails!

The root cause: TelemetryContext is not initialized in telemetry.Context.Initialize(this.Context, instrumentationKey);

https://github.com/Microsoft/ApplicationInsights-dotnet/blob/v2.5.0/src/Microsoft.ApplicationInsights/TelemetryClient.cs#L449

because ITelemetry.OperationContext (device context, etc) are not yet initialized by lazy initialization:

        internal void Initialize(TelemetryContext source, string instrumentationKey)
        {
            Property.Initialize(ref this.instrumentationKey, instrumentationKey);

            this.component?.CopyFrom(source);
            this.device?.CopyFrom(source);
            this.cloud?.CopyFrom(source);
            this.session?.CopyFrom(source);
            this.user?.CopyFrom(source);
            this.operation?.CopyFrom(source);
            this.location?.CopyFrom(source);
            this.Internal.CopyFrom(source);
        }

https://github.com/Microsoft/ApplicationInsights-dotnet/blob/v2.5.0/src/Microsoft.ApplicationInsights/TelemetryClient.cs#L449

All of them are null i.e. CopyTo is not called.

2.4 TelemetryContext.Intitialize - https://github.com/Microsoft/ApplicationInsights-dotnet/blob/v2.4.0/src/Core/Managed/Shared/DataContracts/TelemetryContext.cs#L140

2.5 TelemetryContext.Initialize - https://github.com/Microsoft/ApplicationInsights-dotnet/blob/v2.5.0/src/Microsoft.ApplicationInsights/DataContracts/TelemetryContext.cs#L155

TelemetyContext had a lot of changes from 2.4

@TimothyMothra
Copy link
Member

Today we released Microsoft.ApplicationInsights (v2.5.1) and Microsoft.ApplicationInsights.Web (v2.5.1) with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants