Skip to content

Is it better to move ErrorOccurred into TracingContext #542

@inversionhourglass

Description

@inversionhourglass

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
  • Question or discussion
  • Bug
  • Requirement
  • Feature or performance improvement

Question

  • What do you want to know?
    Currently, when calling SegmentSpan.ErrorOccurred(Exception, TracingConfig), you need to pass in the TracingConfig parameter. Is it better to move the logic of ErrorOccurred into TracingContext? TracingContext can hold a TracingConfig object, which is much more convenient than getting a TracingConfig every time ErrorOccurred is called.
    现在我们调用SegmentSpan.ErrorOccurred(Exception, TracingConfig)方法的时候需要传入TracingConfig参数,将ErrorOccurred的逻辑移动到TracingContext中是否更好?TracingContext可以持有一个TracingConfig对象,相比每次调用ErrorOccurred都去获取一个TracingConfig会方便很多。
public interface ITracingContext
{
    // ...

    void ErrorOccurred(SegmentContext context, Exception exception);
}

public class TracingContext : ITracingContext
{
    // ....

    public void ErrorOccurred(SegmentContext context, Exception exception)
    {
        if (context == null || context.Span == null)
            return;

        context.Span.IsError = true;

        if (exception == null)
            return;

        var stackTrace = exception.HasInnerExceptions() ? exception.ToDemystifiedString(_tracingConfig.ExceptionMaxDepth) : exception.StackTrace;
        context.Span.AddLog(LogEvent.Event("error"),
            LogEvent.ErrorKind(exception.GetType().FullName),
            LogEvent.Message(exception.Message),
            LogEvent.ErrorStack(stackTrace));
    }
}

Bug

  • Which version of SkyWalking, OS and .NET Runtime?

  • Which company or project?

  • What happen?
    If possible, provide a way for reproducing the error. e.g. demo application, component version.


Requirement or improvement

  • Please describe about your requirements or improvement suggestions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions