Exemple #1
0
        public void DisableSpanSelfTimeTest()
        {
            var payloadSender = new MockPayloadSender();

            using var agent = new ApmAgent(
                      new AgentComponents(
                          new NoopLogger(),
                          new MockConfiguration(metricsInterval: "1s", disableMetrics: "span.self_time"),
                          payloadSender,
                          null,               //metricsCollector will be set in AgentComponents.ctor
                          new CurrentExecutionSegmentsContainer(),
                          new NoopCentralConfigurationFetcher(),
                          new MockApmServerInfo(new ElasticVersion(7, 12, 0, string.Empty))));

            agent.Tracer.CaptureTransaction("Foo", "Bar", _ =>
            {
                Thread.Sleep(100);
            });

            payloadSender.WaitForTransactions();
            payloadSender.WaitForMetrics();
            payloadSender.Metrics
            .Where(n => n.Samples.Any(s => s.KeyValue.Key.Equals("span.self_time.count")))
            .Should()
            .BeNullOrEmpty();
            payloadSender.Metrics
            .Where(n => n.Samples.Any(s => s.KeyValue.Key.Equals("span.self_time.sum.us")))
            .Should()
            .BeNullOrEmpty();
        }