Commit 3a61f8d4 authored by Ivan Vandot's avatar Ivan Vandot Committed by GitHub

feat: rename log field traceid to traceID (#2324)

parent 42307cab
...@@ -34,7 +34,7 @@ Once the operation is finished, the open span should be finished: ...@@ -34,7 +34,7 @@ Once the operation is finished, the open span should be finished:
span.Finish() span.Finish()
The tracing package also provides a function for creating a logger which will 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. log lines belong to a specific trace.
To create a logger with trace just wrap an existing logger: To create a logger with trace just wrap an existing logger:
...@@ -46,6 +46,6 @@ To create a logger with trace just wrap an existing logger: ...@@ -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 Which will result in following log line (if the context contains tracing
information): 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 package tracing
...@@ -34,7 +34,7 @@ var ( ...@@ -34,7 +34,7 @@ var (
type contextKey struct{} type contextKey struct{}
// LogField is the key in log message field that holds tracing id value. // LogField is the key in log message field that holds tracing id value.
const LogField = "traceid" const LogField = "traceID"
const ( const (
// TraceContextHeaderName is the http header name used to propagate tracing context. // TraceContextHeaderName is the http header name used to propagate tracing context.
...@@ -91,7 +91,7 @@ func NewTracer(o *Options) (*Tracer, io.Closer, error) { ...@@ -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 // 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 // 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) { func (t *Tracer) StartSpanFromContext(ctx context.Context, operationName string, l logging.Logger, opts ...opentracing.StartSpanOption) (opentracing.Span, *logrus.Entry, context.Context) {
if t == nil { if t == nil {
t = noopTracer t = noopTracer
...@@ -239,7 +239,7 @@ func FromContext(ctx context.Context) opentracing.SpanContext { ...@@ -239,7 +239,7 @@ func FromContext(ctx context.Context) opentracing.SpanContext {
return c 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. // exists in tracing span context stored from go context.
func NewLoggerWithTraceID(ctx context.Context, l logging.Logger) *logrus.Entry { func NewLoggerWithTraceID(ctx context.Context, l logging.Logger) *logrus.Entry {
return loggerWithTraceID(FromContext(ctx), l) return loggerWithTraceID(FromContext(ctx), l)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment