Exemplo n.º 1
0
        internal static LambdaSpan CreateRootSpan(string operationName, DateTimeOffset timestamp, IDictionary <string, object> tags, string guid, ILogger logger = null, IFileSystemManager fileSystemManager = null)
        {
            if (logger == null)
            {
                logger = new MockLogger();
            }

            if (fileSystemManager == null)
            {
                fileSystemManager = new MockFileSystemManager();
            }

            var rootSpan = new LambdaRootSpan(operationName, timestamp, tags, guid, new DataCollector(logger, false, fileSystemManager), new TransactionState(), new PrioritySamplingState(), new DistributedTracingState());
            LambdaSpanContext context = new LambdaSpanContext(rootSpan);

            rootSpan.SetContext(context);
            return(rootSpan);
        }
        public void DoesWriteDataToNamedPipe()
        {
            var fileSystemManager = new MockFileSystemManager();

            fileSystemManager.PathExists = true;

            var startTime = DateTimeOffset.UtcNow;
            var span      = TestUtil.CreateRootSpan("operationName", startTime, new Dictionary <string, object>(), "testGuid", fileSystemManager: fileSystemManager);

            span.RootSpan.PrioritySamplingState.Sampled = true;

            span.Finish();

            var deserializedPayload = JsonConvert.DeserializeObject <object[]>(fileSystemManager.FileContents);
            var data = TestUtil.DecodeAndDecompressNewRelicPayload(deserializedPayload[3] as string);

            Assert.IsTrue(fileSystemManager.FileContents.Contains("NR_LAMBDA_MONITORING"));
            Assert.IsTrue(data.Contains("analytic_event_data"));
            Assert.IsTrue(data.Contains("span_event_data"));
        }