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

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Liudmila Molkova committed May 4, 2017
1 parent 0827d68 commit db87b9b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public void Initialize()
DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated = false;
}

[TestCleanup]
public void Cleanup()
{
DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated = false;
}

[TestMethod]
[Timeout(5000)]
public void TestDependencyCollectionDiagnosticSourceNoParentActivity()
Expand All @@ -64,6 +70,7 @@ public void TestDependencyCollectionDiagnosticSourceNoParentActivity()
module.EnableDiagnosticSourceInstrumentation = true;
module.ProfileQueryEndpoint = FakeProfileApiEndpoint;
module.Initialize(this.config);
Assert.IsTrue(DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated);

var url = new Uri("https://www.bing.com/");
HttpWebRequest request = WebRequest.CreateHttp(url);
Expand Down Expand Up @@ -107,6 +114,7 @@ public void TestDependencyCollectionEventSource()
{
module.ProfileQueryEndpoint = FakeProfileApiEndpoint;
module.Initialize(this.config);
Assert.IsFalse(DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated);

var url = new Uri("https://www.bing.com/");
HttpWebRequest request = WebRequest.CreateHttp(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class DependencyTrackingTelemetryModule : ITelemetryModule, IDisposable
public bool DisableRuntimeInstrumentation { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to disable runtime instrumentation.
/// Gets or sets a value indicating whether to enable Http Desktop DiagnosticSource instrumentation
/// </summary>
public bool EnableDiagnosticSourceInstrumentation { get; set; }

Expand Down Expand Up @@ -288,7 +288,7 @@ private void InitializeForRuntimeInstrumentationOrFramework()
}
else
{
// if profiler is not attached then default to framework event source
// if profiler is not attached then default to diagnositics and framework event source
this.InitializeForDiagnosticAndFrameworkEventSource();

// Log a message to indicate the profiler is not attached
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ internal static Tuple<DependencyTelemetry, bool> GetTupleForSqlDependencies(SqlC

Tuple<DependencyTelemetry, bool> telemetryTuple = null;

if (DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated || DependencyTableStore.Instance.IsProfilerActivated || PretendProfilerIsAttached)
if (DependencyTableStore.Instance.IsProfilerActivated || PretendProfilerIsAttached)
{
telemetryTuple = DependencyTableStore.Instance.SqlRequestConditionalHolder.Get(sqlRequest);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ internal static void AddTupleForSqlDependencies(SqlCommand sqlRequest, Dependenc
}

var telemetryTuple = new Tuple<DependencyTelemetry, bool>(telemetry, isCustomCreated);
if (DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated || DependencyTableStore.Instance.IsProfilerActivated || PretendProfilerIsAttached)
if (DependencyTableStore.Instance.IsProfilerActivated || PretendProfilerIsAttached)
{
DependencyTableStore.Instance.SqlRequestConditionalHolder.Store(sqlRequest, telemetryTuple);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ public void CurrentActivityIsNull(string appDomainName = "Incorrect")
this.WriteEvent(23, this.ApplicationName);
}

[Event(
24,
Message = "HttpDesktopDiagnosticSourceListener is activated.",
Level = EventLevel.Verbose)]
public void HttpDesktopDiagnosticSourceListenerIsActivated(string appDomainName = "Incorrect")
{
this.WriteEvent(24, this.ApplicationName);
}

[Event(
25,
Message = "HttpDesktopDiagnosticSourceListener is activated.",
Level = EventLevel.Verbose)]
public void HttpDesktopDiagnosticSourceListenerIsDeactivated(string appDomainName = "Incorrect")
{
this.WriteEvent(25, this.ApplicationName);
}

[NonEvent]
private string GetApplicationName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void OnNext(DiagnosticListener value)
{
this.sourceSubscription = value.Subscribe(this.parent, (Predicate<string>)null);
DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated = true;
DependencyCollectorEventSource.Log.HttpDesktopDiagnosticSourceListenerIsActivated();
}
}
}
Expand Down Expand Up @@ -91,6 +92,9 @@ protected virtual void Dispose(bool disposing)
}
}

DependencyTableStore.Instance.IsDesktopHttpDiagnosticSourceActivated = false;
DependencyCollectorEventSource.Log.HttpDesktopDiagnosticSourceListenerIsDeactivated();

this.disposed = true;
}
}
Expand Down

0 comments on commit db87b9b

Please sign in to comment.