mirror of https://github.com/grpc/grpc-go.git
gcp/observability: Switch hex encoding to string() method (#6138)
This commit is contained in:
parent
70c5291509
commit
78099db03f
|
@ -327,14 +327,14 @@ func (bml *binaryMethodLogger) buildGCPLoggingEntry(ctx context.Context, c iblog
|
||||||
// client side span, populated through opencensus trace package.
|
// client side span, populated through opencensus trace package.
|
||||||
if span := trace.FromContext(ctx); span != nil {
|
if span := trace.FromContext(ctx); span != nil {
|
||||||
sc := span.SpanContext()
|
sc := span.SpanContext()
|
||||||
gcploggingEntry.Trace = "projects/" + bml.projectID + "/traces/" + fmt.Sprintf("%x", sc.TraceID)
|
gcploggingEntry.Trace = "projects/" + bml.projectID + "/traces/" + sc.TraceID.String()
|
||||||
gcploggingEntry.SpanID = fmt.Sprintf("%x", sc.SpanID)
|
gcploggingEntry.SpanID = sc.SpanID.String()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// server side span, populated through stats/opencensus package.
|
// server side span, populated through stats/opencensus package.
|
||||||
if tID, sID, ok := opencensus.GetTraceAndSpanID(ctx); ok {
|
if tID, sID, ok := opencensus.GetTraceAndSpanID(ctx); ok {
|
||||||
gcploggingEntry.Trace = "projects/" + bml.projectID + "/traces/" + fmt.Sprintf("%x", tID)
|
gcploggingEntry.Trace = "projects/" + bml.projectID + "/traces/" + tID.String()
|
||||||
gcploggingEntry.SpanID = fmt.Sprintf("%x", sID)
|
gcploggingEntry.SpanID = sID.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gcploggingEntry
|
return gcploggingEntry
|
||||||
|
|
|
@ -121,12 +121,11 @@ type traceAndSpanIDString struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// idsToString is a helper that converts from generated trace and span IDs to
|
// idsToString is a helper that converts from generated trace and span IDs to
|
||||||
// the string version stored in trace message events. (hex 16 lowercase encoded,
|
// the string version stored in trace message events.
|
||||||
// and extra data attached to trace id).
|
|
||||||
func idsToString(tasi traceAndSpanID, projectID string) traceAndSpanIDString {
|
func idsToString(tasi traceAndSpanID, projectID string) traceAndSpanIDString {
|
||||||
return traceAndSpanIDString{
|
return traceAndSpanIDString{
|
||||||
traceID: "projects/" + projectID + "/traces/" + fmt.Sprintf("%x", tasi.traceID),
|
traceID: "projects/" + projectID + "/traces/" + tasi.traceID.String(),
|
||||||
spanID: fmt.Sprintf("%x", tasi.spanID),
|
spanID: tasi.spanID.String(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue