Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename log field traceid to traceID #2324

Merged
merged 1 commit into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/tracing/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Once the operation is finished, the open span should be finished:
span.Finish()

The tracing package also provides a function for creating a logger which will
inject a "traceid" field entry to the log line, which helps in finding out which
inject a "traceID" field entry to the log line, which helps in finding out which
log lines belong to a specific trace.

To create a logger with trace just wrap an existing logger:
Expand All @@ -46,6 +46,6 @@ To create a logger with trace just wrap an existing logger:
Which will result in following log line (if the context contains tracing
information):

time="2015-09-07T08:48:33Z" level=info msg="some message" traceid=ed65818cc1d30c
time="2015-09-07T08:48:33Z" level=info msg="some message" traceID=ed65818cc1d30c
*/
package tracing
6 changes: 3 additions & 3 deletions pkg/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var (
type contextKey struct{}

// LogField is the key in log message field that holds tracing id value.
const LogField = "traceid"
const LogField = "traceID"

const (
// TraceContextHeaderName is the http header name used to propagate tracing context.
Expand Down Expand Up @@ -91,7 +91,7 @@ func NewTracer(o *Options) (*Tracer, io.Closer, error) {

// StartSpanFromContext starts a new tracing span that is either a root one or a
// child of existing one from the provided Context. If logger is provided, a new
// log Entry will be returned with "traceid" log field.
// log Entry will be returned with "traceID" log field.
func (t *Tracer) StartSpanFromContext(ctx context.Context, operationName string, l logging.Logger, opts ...opentracing.StartSpanOption) (opentracing.Span, *logrus.Entry, context.Context) {
if t == nil {
t = noopTracer
Expand Down Expand Up @@ -239,7 +239,7 @@ func FromContext(ctx context.Context) opentracing.SpanContext {
return c
}

// NewLoggerWithTraceID creates a new log Entry with "traceid" field added if it
// NewLoggerWithTraceID creates a new log Entry with "traceID" field added if it
// exists in tracing span context stored from go context.
func NewLoggerWithTraceID(ctx context.Context, l logging.Logger) *logrus.Entry {
return loggerWithTraceID(FromContext(ctx), l)
Expand Down