public void LogUsingFields()
        {
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanShim(spanMock);

            Assert.Throws <ArgumentNullException>(() => shim.Log((IEnumerable <KeyValuePair <string, object> >)null));

            shim.Log(new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>("foo", "bar"),
            });

            // "event" is a special event name
            shim.Log(new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>("event", "foo"),
            });

            var first = spanMock.Events.FirstOrDefault();
            var last  = spanMock.Events.LastOrDefault();

            Assert.Equal(2, spanMock.Events.Count);

            Assert.Equal(SpanShim.DefaultEventName, first.Name);
            Assert.True(first.Attributes.Any());

            Assert.Equal("foo", last.Name);
            Assert.False(last.Attributes.Any());
        }
        public void LogUsingFieldsWithExplicitTimestamp()
        {
            // TODO Explicit timestamps are unsupported in OpenTelemetry?
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanShim(spanMock);

            Assert.Throws <ArgumentNullException>(() => shim.Log((IEnumerable <KeyValuePair <string, object> >)null));

            shim.Log(DateTimeOffset.UtcNow, new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>("foo", "bar"),
            });

            // "event" is a special event name
            shim.Log(DateTimeOffset.UtcNow, new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>("event", "foo"),
            });

            Assert.Equal(2, spanMock.Events.Count);
            var first = spanMock.Events.First();
            var last  = spanMock.Events.Last();

            Assert.Equal(SpanShim.DefaultEventName, first.Name);
            Assert.True(first.Attributes.Any());

            Assert.Equal("foo", last.Name);
            Assert.False(last.Attributes.Any());
        }
        public void Log()
        {
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanShim(spanMock);

            shim.Log("foo");

            Assert.Single(spanMock.Events);
            var first = spanMock.Events.First();

            Assert.Equal("foo", first.Name);
            Assert.False(first.Attributes.Any());
        }
        public void LogWithExplicitTimestamp()
        {
            var spanMock = Defaults.GetOpenTelemetrySpanMock();
            var shim     = new SpanShim(spanMock);

            shim.Log(DateTimeOffset.UtcNow, "foo");

            Assert.Single(spanMock.Events);
            var first = spanMock.Events.First();

            Assert.Equal("foo", first.Name);
            Assert.False(first.Attributes.Any());
        }