Merge pull request #219 from bilibili/fix-zipkin-servicename

Fix zipkin servicename
pull/221/head
Tony 6 years ago committed by GitHub
commit b2c257a739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      pkg/net/trace/span.go
  2. 5
      pkg/net/trace/zipkin/zipkin.go
  3. 2
      tool/kratos/template.go

@ -27,7 +27,11 @@ type Span struct {
childs int childs int
} }
func (s *Span) Name() string { func (s *Span) ServiceName() string {
return s.dapper.serviceName
}
func (s *Span) OperationName() string {
return s.operationName return s.operationName
} }

@ -37,11 +37,12 @@ func (r *report) WriteSpan(raw *trace.Span) (err error) {
ID: spanID, ID: spanID,
ParentID: &parentID, ParentID: &parentID,
}, },
Name: raw.Name(), Name: raw.OperationName(),
Timestamp: raw.StartTime(), Timestamp: raw.StartTime(),
Duration: raw.Duration(), Duration: raw.Duration(),
Tags: make(map[string]string, len(tags)+len(logs)), Tags: make(map[string]string, len(tags)+len(logs)),
} }
span.LocalEndpoint = &model.Endpoint{ServiceName: raw.ServiceName()}
for _, tag := range tags { for _, tag := range tags {
switch tag.Key { switch tag.Key {
case trace.TagSpanKind: case trace.TagSpanKind:
@ -55,8 +56,6 @@ func (r *report) WriteSpan(raw *trace.Span) (err error) {
case "consumer": case "consumer":
span.Kind = model.Consumer span.Kind = model.Consumer
} }
case trace.TagPeerService:
span.LocalEndpoint = &model.Endpoint{ServiceName: tag.Value.(string)}
default: default:
v, ok := tag.Value.(string) v, ok := tag.Value.(string)
if ok { if ok {

@ -547,7 +547,7 @@ type Kratos struct {
go 1.12 go 1.12
require ( require (
github.com/bilibili/kratos v0.1.0 github.com/bilibili/kratos v0.2.0
github.com/gogo/protobuf v1.2.1 github.com/gogo/protobuf v1.2.1
github.com/golang/protobuf v1.3.1 github.com/golang/protobuf v1.3.1
golang.org/x/net v0.0.0-20190420063019-afa5a82059c6 golang.org/x/net v0.0.0-20190420063019-afa5a82059c6

Loading…
Cancel
Save