Exemple #1
0
        /// <summary>
        /// Records an annotation with the current timestamp and the provided value in the span.
        /// </summary>
        /// <param name="span">The span where the annotation will be recorded.</param>
        /// <param name="value">The value of the annotation to be recorded. If this parameter is omitted
        /// (or its value set to null), the method caller member name will be automatically passed.</param>
        public void Record(Span span, [CallerMemberName] string value = null)
        {
            if (!IsTraceOn)
            {
                return;
            }

            try
            {
                spanTracer.Record(span, value);
            }
            catch (Exception ex)
            {
            }
        }
        public void Record_WithSpanAndValue_AddsNewAnnotation()
        {
            // Arrange
            var expectedDescription = "Description";
            var expectedSpan        = new Span();
            var domain     = new Uri("http://server.com");
            var spanTracer = new SpanTracer(spanCollectorStub, zipkinEndpointStub, zipkinNotToBeDisplayedDomainList, domain);

            // Act
            spanTracer.Record(expectedSpan, expectedDescription);

            // Assert
            Assert.IsNotNull(
                expectedSpan.GetAnnotationsByType <Annotation>().SingleOrDefault(a => (string)a.Value == expectedDescription),
                "The record is not found in the Annotations."
                );
        }