You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.
If you are reporting bug/issue, please provide detailed Repro instructions.
Repro Steps
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.DataContracts;
namespace MvcFiveApp.Controllers
{
public class TestController : ApiController
{
private readonly TelemetryClient telemetryClient = new TelemetryClient();
[System.Web.Http.AcceptVerbs("GET")]
public async Task<string> DoWork([FromUri] int WorkID)
{
try
{
Activity.Current.AddTag("WorkID", WorkID.ToString()); // Exists for Request, Dependency, Trace and Exception telemetry
using (var dependency = this.telemetryClient.StartOperation<DependencyTelemetry>("StoreWork"))
{
Activity.Current.AddTag("DependencyID", Guid.NewGuid().ToString("N")); // Exists only for Trace telemetry. Expectation: exists for Dependency as well
this.telemetryClient.TrackTrace("MyTrace");
await Task.Delay(TimeSpan.FromMilliseconds(267)).ConfigureAwait(false);
this.telemetryClient.TrackTrace("MyTrace2");
if (WorkID > 10)
{
throw new Exception("Too big ID!");
}
}
return WorkID.ToString();
}
catch (Exception ex)
{
this.telemetryClient.TrackException(ex);
throw;
}
}
}
}
Actual Behavior
TelemetryInitializer is called twice (once upon StartOperation and one as a part of Track), both with Activity.Current pointing to RequestTelemetry and not DependencyTelemetry
Expected Behavior
TelemetryInitializer is called once. Activity.Current should point to Dependency activity
Version Info
SDK Version : 2.6-beta2
.NET Version :
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS :
Hosting Info (IIS/Azure WebApps/ etc) :
The text was updated successfully, but these errors were encountered:
I used this TelemetryInitializer to add tags (thank you @lmolkova for helping with this!):
using System.Diagnostics;
using System.Web;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
namespace MvcFiveApp.Controllers
{
public class ActvityTagsTelemetryInitializer : ITelemetryInitializer
{
public void Initialize(ITelemetry telemetry)
{
Activity current = Activity.Current;
if (current == null)
{
current = (Activity)HttpContext.Current.Items["__AspnetActivity__"];
}
while (current != null)
{
foreach (var tag in current.Tags)
{
if (!telemetry.Context.Properties.ContainsKey(tag.Key))
{
telemetry.Context.Properties.Add(tag.Key, tag.Value);
}
}
current = current.Parent;
}
}
}
}
If you are reporting bug/issue, please provide detailed Repro instructions.
Repro Steps
Actual Behavior
TelemetryInitializer is called twice (once upon StartOperation and one as a part of Track), both with Activity.Current pointing to RequestTelemetry and not DependencyTelemetry
Expected Behavior
TelemetryInitializer is called once. Activity.Current should point to Dependency activity
Version Info
SDK Version : 2.6-beta2
.NET Version :
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS :
Hosting Info (IIS/Azure WebApps/ etc) :
The text was updated successfully, but these errors were encountered: