public async Task ShouldPushStandAloneSpanToAppInsights()
        {
            if (!_fixture.EnableIntegrationSpecs)
            {
                return;
            }

            string traceId = null;

            using (var span = _tracer.BuildSpan("simple1").WithSpanKind(SpanKind.CLIENT).StartActive())
            {
                traceId = span.Span.Context.TraceId;

                // sanity check
                traceId.Should().NotBeNullOrEmpty();
                span.Span.Context.SpanId.Should().NotBeNullOrEmpty();
            }

            // give the span a chance to be uploaded and processed
            await ExponentialBackoff.AwaitAssert(async() =>
            {
                var queryResult = await _fixture.QueryOperationsForTraceId(traceId);
                queryResult.isSuccess.Should().BeTrue();

                var parsedResults = AppInsightsDeserializer.DeserializeResult(queryResult.response);
                parsedResults.tables.Count.Should().Be(1);
                parsedResults.tables[0].rows.Count.Should().Be(1);
            });
        }
        public async Task ShouldPushSpanLogstoAppInsights()
        {
            if (!_fixture.EnableIntegrationSpecs)
            {
                return;
            }

            string traceId = null;

            using (var span = _tracer.BuildSpan("op1").WithSpanKind(SpanKind.CLIENT).StartActive())
            {
                traceId = span.Span.Context.TraceId;

                // generate 3 trace events in AppInsights
                span.Span.Log("one").Log("two").Log("three");
            }

            // give the span a chance to be uploaded and processed
            await ExponentialBackoff.AwaitAssert(async() =>
            {
                var queryResult = await _fixture.QueryOperationsForTraceId(traceId);
                queryResult.isSuccess.Should().BeTrue();

                var parsedResults = AppInsightsDeserializer.DeserializeResult(queryResult.response);
                parsedResults.tables.Count.Should().Be(1);
                parsedResults.tables[0].rows.Count.Should().Be(4); // Request + 3 correlated traces
            });
        }
Exemplo n.º 3
0
        public void ShouldDeserializeValidAppInsightsJson()
        {
            var obj = AppInsightsDeserializer.DeserializeResult(_sampleJson);

            obj.tables.Count.Should().Be(1);
            obj.tables[0].rows.Count.Should().Be(4); // 4 ops in this JSON
        }
        public async Task ShouldPushParentAndChildRequestSpansToAppInsights()
        {
            if (!_fixture.EnableIntegrationSpecs)
            {
                return;
            }

            string traceId = null;

            using (var span = _tracer.BuildSpan("op1").WithSpanKind(SpanKind.CLIENT).StartActive())
            {
                traceId = span.Span.Context.TraceId;

                using (var child = _tracer.BuildSpan("op1.child").WithSpanKind(SpanKind.CLIENT).StartActive())
                {
                    child.Span.SetTag("child", true);

                    using (var grandChild =
                               _tracer.BuildSpan("op1.grandchild").WithSpanKind(SpanKind.CLIENT).StartActive())
                    {
                        grandChild.Span.SetTag("child", true).SetTag("grandChild", true);
                    }
                }
            }

            // give the span a chance to be uploaded and processed
            await ExponentialBackoff.AwaitAssert(async() =>
            {
                var queryResult = await _fixture.QueryOperationsForTraceId(traceId);
                queryResult.isSuccess.Should().BeTrue();

                var parsedResults = AppInsightsDeserializer.DeserializeResult(queryResult.response);
                parsedResults.tables.Count.Should().Be(1);
                parsedResults.tables[0].rows.Count.Should().Be(3); // parent, child, and grandchild

                // TODO: deserialize table rows and validate parent --> child --> grandchild relationships
                // So far we've manually verified this through AppInsights dashboard and analytics queries
            });
        }