コード例 #1
0
        /// <inheritdoc />
        public RemoveMessageStatus Remove(IMessageId id, RemoveMessageReason reason)
        {
            var header = _getHeader.GetHeaders(id);

            if (header != null)
            {
                var spanContext = header.Extract(_tracer, _headers);
                if (spanContext != null)
                {
                    using (IScope scope = _tracer.BuildSpan("Remove").AddReference(References.FollowsFrom, spanContext).StartActive(finishSpanOnDispose: true))
                    {
                        scope.Span.SetTag("RemovedBecause", reason.ToString());
                        return(_handler.Remove(id, reason));
                    }
                }
                else
                {
                    using (IScope scope = _tracer.BuildSpan("Remove").StartActive(finishSpanOnDispose: true))
                    {
                        scope.Span.AddMessageIdTag(id);
                        scope.Span.SetTag("RemovedBecause", reason.ToString());
                        return(_handler.Remove(id, reason));
                    }
                }
            }
            else
            {
                using (IScope scope = _tracer.BuildSpan("Remove").StartActive(finishSpanOnDispose: true))
                {
                    scope.Span.AddMessageIdTag(id);
                    scope.Span.SetTag("RemovedBecause", reason.ToString());
                    return(_handler.Remove(id, reason));
                }
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public void Handle(IMessageContext context, PoisonMessageException exception)
        {
            var header = _getHeader.GetHeaders(context.MessageId);

            if (header != null)
            {
                var activityContext = header.Extract(_tracer, _headers);
                using (var scope = _tracer.StartActivity("PoisonMessage", ActivityKind.Internal, activityContext))
                {
                    scope?.AddMessageIdTag(context);
                    scope?.RecordException(exception);
                    scope?.SetStatus(Status.Error);
                    _handler.Handle(context, exception);
                }
            }
            else
            {
                using (var scope = _tracer.StartActivity("PoisonMessage"))
                {
                    scope?.AddMessageIdTag(context);
                    scope?.RecordException(exception);
                    _handler.Handle(context, exception);
                }
            }
        }
コード例 #3
0
        /// <inheritdoc />
        public RemoveMessageStatus Remove(IMessageId id, RemoveMessageReason reason)
        {
            var header = _getHeader.GetHeaders(id);

            if (header != null)
            {
                var activityContext = header.Extract(_tracer, _headers);
                using (var scope = _tracer.StartActivity("Remove", ActivityKind.Internal, parentContext: activityContext))
                {
                    scope?.AddMessageIdTag(id);
                    scope?.SetTag("RemovedBecause", reason.ToString());
                    return(_handler.Remove(id, reason));
                }
            }
            using (var scope = _tracer.StartActivity("Remove"))
            {
                scope?.AddMessageIdTag(id);
                scope?.SetTag("RemovedBecause", reason.ToString());
                return(_handler.Remove(id, reason));
            }
        }
コード例 #4
0
        /// <inheritdoc />
        public void Handle(IMessageContext context, PoisonMessageException exception)
        {
            var header = _getHeader.GetHeaders(context.MessageId);

            if (header != null)
            {
                var spanContext = header.Extract(_tracer, _headers);
                if (spanContext != null)
                {
                    using (IScope scope = _tracer.BuildSpan("PoisonMessage").AddReference(References.FollowsFrom, spanContext).StartActive(finishSpanOnDispose: true))
                    {
                        scope.Span.Log(exception.ToString());
                        Tags.Error.Set(scope.Span, true);
                        _handler.Handle(context, exception);
                    }
                }
                else
                {
                    using (IScope scope = _tracer.BuildSpan("PoisonMessage").StartActive(finishSpanOnDispose: true))
                    {
                        scope.Span.AddMessageIdTag(context);
                        scope.Span.Log(exception.ToString());
                        Tags.Error.Set(scope.Span, true);
                        _handler.Handle(context, exception);
                    }
                }
            }
            else
            {
                using (IScope scope = _tracer.BuildSpan("PoisonMessage").StartActive(finishSpanOnDispose: true))
                {
                    scope.Span.AddMessageIdTag(context);
                    scope.Span.Log(exception.ToString());
                    _handler.Handle(context, exception);
                }
            }
        }