in tools/go-agent/instrument/logger/context.go [109:136]
func GetLogContext(withEndpoint bool) *SkyWalkingLogContext {
operator := GetOperator()
var activeSpan TracingSpan = noopContext
var serviceName, instanceName, endpoint string
if operator != nil {
tracingOperator := operator.Tracing().(TracingOperator)
if s, ok := tracingOperator.ActiveSpan().(TracingSpan); ok && s != nil {
activeSpan = s
if withEndpoint {
endpoint = findEndpointNameBySpan(s)
}
}
entity := operator.Entity()
if entity != nil {
if e, ok := entity.(Entity); ok && e != nil {
serviceName, instanceName = e.GetServiceName(), e.GetInstanceName()
}
}
}
return &SkyWalkingLogContext{
ServiceName: serviceName,
InstanceName: instanceName,
TraceID: activeSpan.GetTraceID(),
TraceSegmentID: activeSpan.GetSegmentID(),
SpanID: activeSpan.GetSpanID(),
EndPoint: endpoint,
}
}