Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.
This repository was archived by the owner on May 23, 2023. It is now read-only.

log field type error: span log displays struct representation than the output of Error method. #199

@bsr203

Description

@bsr203

Hi.

I have a custom error type (which implements Error interface) and use it in log.Error

When I was looking at this error through jaeger-ui, I see it is not the err.Error() I see, but the struct representation.

this may be the culprit of this issue

func (lf Field) String() string {
	return fmt.Sprint(lf.key, ":", lf.Value())
}

Sprint doesn't call the Error() method if the actual interface is an error, but a struct representation. as I see here

I am not sure Marshal formats it differently, but as far as I see, my trace log doesn't have some of the private info I add through Error method.

Please guide me if you think it may be because I use the API wrongly.

        fields := []log.Field {log.Error(myCustomError)}
	fields = append(fields, log.String("message", msg))
	fields = append(fields, log.String("level", "info"))
	span := opentracing.SpanFromContext(ctx) 
         span.LogFields(fields...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions