Exemplo n.º 1
0
        public void CreatingOperationHolderWithParentActivityRestoresIt()
        {
            var client = new TelemetryClient(TelemetryConfiguration.CreateDefault());

            var originalActivity = new Activity("original").Start();
            var operation        = new OperationHolder <DependencyTelemetry>(client, new DependencyTelemetry(), originalActivity);

            // child of original
            var newActivity = new Activity("new").Start();

            operation.Telemetry.Id = newActivity.SpanId.ToHexString();
            operation.Dispose();
            Assert.AreEqual(Activity.Current, originalActivity);
        }
Exemplo n.º 2
0
        public void CreatingOperationHolderWithNullOriginalActivityDoesNotRestoreIt()
        {
            var client = new TelemetryClient(TelemetryConfiguration.CreateDefault());

            var originalActivity = new Activity("original").Start();
            var operation        = new OperationHolder <DependencyTelemetry>(client, new DependencyTelemetry(), null);

            var newActivity = new Activity("new").SetParentId("detached-parent").Start();

            operation.Telemetry.Id = newActivity.SpanId.ToHexString();

            operation.Dispose();
            Assert.IsNull(Activity.Current);
        }
Exemplo n.º 3
0
        public void CreatingOperationHolderWithDetachedOriginalActivityRestoresIt()
        {
            var client = new TelemetryClient(TelemetryConfiguration.CreateDefault());

            var originalActivity = new Activity("original").Start();
            var operation        = new OperationHolder <DependencyTelemetry>(client, new DependencyTelemetry(), originalActivity);

            var newActivity = new Activity("new").SetParentId("detached-parent").Start();

            operation.Telemetry.Id = $"|{newActivity.TraceId.ToHexString()}.{newActivity.SpanId.ToHexString()}.";

            operation.Dispose();
            Assert.AreEqual(Activity.Current, originalActivity);
        }
Exemplo n.º 4
0
 public void CreatingOperationItemDoesNotThrowOnPassingValidArguments()
 {
     var operationItem = new OperationHolder <DependencyTelemetry>(new TelemetryClient(TelemetryConfiguration.CreateDefault()), new DependencyTelemetry());
 }
Exemplo n.º 5
0
 public void CreatingOperationItemWithNullTelemetryThrowsArgumentNullException()
 {
     var operationItem = new OperationHolder <DependencyTelemetry>(new TelemetryClient(TelemetryConfiguration.CreateDefault()), null);
 }
Exemplo n.º 6
0
 public void CreatingOperationItemWithNullTelemetryClientThrowsArgumentNullException()
 {
     var operationItem = new OperationHolder <DependencyTelemetry>(null, new DependencyTelemetry());
 }