Beispiel #1
0
        public async Task SubmitsTraces(string binding, bool enableNewWcfInstrumentation)
        {
            if (enableNewWcfInstrumentation)
            {
                SetEnvironmentVariable("DD_TRACE_DELAY_WCF_INSTRUMENTATION_ENABLED", "true");
            }

            Output.WriteLine("Starting WcfTests.SubmitsTraces. Starting the Samples.Wcf requires ADMIN privileges");

            var expectedSpanCount = 6;

            const string expectedOperationName = "wcf.request";

            using var telemetry = this.ConfigureTelemetry();
            int wcfPort = 8585;

            using (var agent = EnvironmentHelper.GetMockAgent())
                using (RunSampleAndWaitForExit(agent, arguments: $"{binding} Port={wcfPort}"))
                {
                    // Filter out WCF spans unrelated to the actual request handling, and filter them before returning spans
                    // so we can wait on the exact number of spans we expect.
                    agent.SpanFilters.Add(s => !s.Resource.Contains("schemas.xmlsoap.org") && !s.Resource.Contains("www.w3.org"));
                    var spans = agent.WaitForSpans(expectedSpanCount, operationName: expectedOperationName);

                    var settings = VerifyHelper.GetSpanVerifierSettings(binding, enableNewWcfInstrumentation);

                    await Verifier.Verify(spans, settings)
                    .UseMethodName("_");

                    // The custom binding doesn't trigger the integration
                    telemetry.AssertIntegration(IntegrationId.Wcf, enabled: binding != "Custom", autoEnabled: true);
                }
        }
Beispiel #2
0
        public async void SubmitThreadSamples()
        {
            SetEnvironmentVariable("SIGNALFX_PROFILER_ENABLED", "true");
            SetEnvironmentVariable("SIGNALFX_PROFILER_CALL_STACK_INTERVAL", "1000");

            using (var agent = EnvironmentHelper.GetMockAgent())
                using (var logsCollector = EnvironmentHelper.GetMockOtelLogsCollector())
                    using (var processResult = RunSampleAndWaitForExit(agent, logsCollector.Port))
                    {
                        var logsData = logsCollector.LogsData.ToArray();
                        // The application works for 6 seconds with debug logging enabled we expect at least 2 attempts of thread sampling in CI.
                        // On a dev box it is typical to get at least 4 but the CI machines seem slower, using 2
                        logsData.Length.Should().BeGreaterOrEqualTo(expected: 2);

                        var settings = VerifyHelper.GetThreadSamplingVerifierSettings();
                        settings.UseTextForParameters("OnlyCommonAttributes");

                        await DumpLogRecords(logsData);

                        var containStackTraceForClassHierarchy = false;
                        var expectedStackTrace = string.Join("\n", CreateExpectedStackTrace());

                        foreach (var data in logsData)
                        {
                            IList <Profile> profiles   = new List <Profile>();
                            var             logRecords = data.ResourceLogs[0].InstrumentationLibraryLogs[0].Logs;

                            foreach (var gzip in logRecords.Select(record => record.Body.StringValue).Select(Convert.FromBase64String))
                            {
                                await using var memoryStream = new MemoryStream(gzip);
                                await using var gzipStream   = new GZipStream(memoryStream, CompressionMode.Decompress);
                                var profile = Serializer.Deserialize <Profile>(gzipStream);
                                profiles.Add(profile);
                            }

                            containStackTraceForClassHierarchy |= profiles.Any(profile => ContainStackTraceForClassHierarchy(profile, expectedStackTrace));

                            using (new AssertionScope())
                            {
                                AllShouldHaveCorrectAttributes(logRecords, "pprof-gzip-base64");
                            }

                            // all samples should contain the same common attributes, only stack traces are vary
                            logRecords.Clear();
                            await Verifier.Verify(data, settings);
                        }

                        Assert.True(containStackTraceForClassHierarchy, "At least one stack trace containing class hierarchy should be reported.");
                    }
        }
Beispiel #3
0
        public async void SubmitThreadSamples()
        {
            SetEnvironmentVariable("SIGNALFX_PROFILER_ENABLED", "true");
            SetEnvironmentVariable("SIGNALFX_PROFILER_CALL_STACK_INTERVAL", "1000");
            SetEnvironmentVariable("SIGNALFX_PROFILER_EXPORT_FORMAT", "Text");

            using (var agent = EnvironmentHelper.GetMockAgent())
                using (var logsCollector = EnvironmentHelper.GetMockOtelLogsCollector())
                    using (var processResult = RunSampleAndWaitForExit(agent, logCollectorPort: logsCollector.Port))
                    {
                        var logsData = logsCollector.LogsData.ToArray();
                        // The application works for 6 seconds with debug logging enabled we expect at least 2 attempts of thread sampling in CI.
                        // On a dev box it is typical to get at least 4 but the CI machines seem slower, using 2
                        logsData.Length.Should().BeGreaterOrEqualTo(expected: 2);

                        var settings = VerifyHelper.GetThreadSamplingVerifierSettings();
                        settings.UseTextForParameters("OnlyCommonAttributes");

                        await DumpLogRecords(logsData);

                        var containStackTraceForClassHierarchy = false;
                        var expectedStackTrace = string.Join(string.Empty, CreateExpectedStackTrace().Select(frame => $"\tat {frame}\n"));

                        foreach (var data in logsData)
                        {
                            var logRecords = data.ResourceLogs[0].InstrumentationLibraryLogs[0].Logs;

                            containStackTraceForClassHierarchy |= logRecords.Any(record => ContainStackTraceForClassHierarchy(record, expectedStackTrace));

                            using (new AssertionScope())
                            {
                                AllShouldHaveCorrectAttributes(logRecords, "text");
                                AllBodiesShouldHaveCorrectFormat(logRecords);
                            }

                            // all samples should contain the same common attributes, only stack traces are vary
                            logRecords.Clear();
                            await Verifier.Verify(data, settings);
                        }

                        Assert.True(containStackTraceForClassHierarchy, "At least one stack trace containing class hierarchy should be reported.");
                    }
        }