コード例 #1
0
        public void SendServerSpan(Span span, int statusCode, string errorMessage = null)
        {
            if (span == null)
            {
                throw new ArgumentNullException(nameof(span));
            }

            if (span.Annotations == null || !span.Annotations.Any())
            {
                throw new ArgumentException("Invalid server span: Annotations list is invalid.");
            }

            var annotation = new Annotation
            {
                Host  = span.Annotations.First().Host,
                Value = TraceKeys.ServerSend
            };

            span.Annotations.Add(annotation);
            AddBinaryAnnotation(TraceKeys.HttpStatusCode, statusCode.ToString(), span, span.Annotations.First().Host);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                AddBinaryAnnotation(TraceKeys.Error, errorMessage, span, span.Annotations.First().Host);
            }

            _spanCollector.Collect(span);
        }
コード例 #2
0
        public bool SubmitEndAnnotation(string annotationName, ISpanCollector spanCollector)
        {
            Span span = SpanAndEndpoint.Span;

            if (span == null)
            {
                return(false);
            }
            Annotation annotation = new Annotation();

            annotation.Timestamp = Util.CurrentTimeMicroseconds();
            annotation.Host      = SpanAndEndpoint.Endpoint;
            annotation.Value     = annotationName;
            span.Annotations.Add(annotation);
            span.Duration = annotation.Timestamp - span.Timestamp;
            spanCollector.Collect(span);
            return(true);
        }