Пример #1
0
        public static void SetStatus(this Activity activity, Status status)
        {
            Debug.Assert(activity != null, "Activity should not be null");

            activity.SetTag(SpanAttributeConstants.StatusCodeKey, SpanHelper.GetCachedCanonicalCodeString(status.CanonicalCode));
            if (!string.IsNullOrEmpty(status.Description))
            {
                activity.SetTag(SpanAttributeConstants.StatusDescriptionKey, status.Description);
            }
        }
Пример #2
0
        public static Status GetStatus(this Activity activity)
        {
            Debug.Assert(activity != null, "Activity should not be null");

            var statusCanonicalCode = activity.Tags.FirstOrDefault(k => k.Key == SpanAttributeConstants.StatusCodeKey).Value;
            var statusDescription   = activity.Tags.FirstOrDefault(d => d.Key == SpanAttributeConstants.StatusDescriptionKey).Value;

            var status = SpanHelper.ResolveCanonicalCodeToStatus(statusCanonicalCode);

            if (status.IsValid && !string.IsNullOrEmpty(statusDescription))
            {
                return(status.WithDescription(statusDescription));
            }

            return(status);
        }
        public static Status GetStatus(this Activity activity)
        {
            Debug.Assert(activity != null, "Activity should not be null");

            ActivityStatusTagEnumerator state = default;

            ActivityTagObjectsEnumeratorFactory <ActivityStatusTagEnumerator> .Enumerate(activity, ref state);

            var status = SpanHelper.ResolveCanonicalCodeToStatus(state.StatusCode);

            if (status.IsValid && !string.IsNullOrEmpty(state.StatusDescription))
            {
                return(status.WithDescription(state.StatusDescription));
            }

            return(status);
        }