Skip to content

Commit

Permalink
fix: jaeger code error (#662)
Browse files Browse the repository at this point in the history
Co-authored-by: seeflood <zhou.qunli@foxmail.com>
  • Loading branch information
LXPWing and seeflood authored Jun 22, 2022
1 parent 34da00a commit c76afc1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
6 changes: 2 additions & 4 deletions configs/config_trace_jaeger.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@
"enable": true,
"driver": "jaeger",
"config": {
"config": {
"service_name": "layotto",
"strategy": "collector"
}
"service_name": "layotto",
"strategy": "collector"
}
},
"metrics": {
Expand Down
26 changes: 7 additions & 19 deletions diagnostics/jaeger/grpc_tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const (
appIDKey = "APP_ID"
defaultCollectorEndpoint = "http://127.0.0.1:14268/api/traces"
defaultStrategy = "collector"
configs = "config"
)

type grpcJaegerTracer struct {
Expand Down Expand Up @@ -114,11 +113,8 @@ func NewGrpcJaegerTracer(traceCfg map[string]interface{}) (api.Tracer, error) {
}

func getAgentHost(traceCfg map[string]interface{}) string {
if cfg, ok := traceCfg[configs]; ok {
host := cfg.(map[string]interface{})
if agentHost, ok := host[agentHost]; ok {
return agentHost.(string)
}
if agentHost, ok := traceCfg[agentHost]; ok {
return agentHost.(string)
}

//if TRACE is not set, get it from the env variable
Expand All @@ -130,9 +126,7 @@ func getAgentHost(traceCfg map[string]interface{}) string {
}

func getStrategy(traceCfg map[string]interface{}) (string, error) {
if cfg, ok := traceCfg[configs]; ok {
str := cfg.(map[string]interface{})
k, ok := str[strategy]
if k, ok := traceCfg[strategy]; ok {
if ok && (k.(string) == defaultStrategy || k.(string) == "agent") {
return k.(string), nil
} else if ok {
Expand All @@ -144,22 +138,16 @@ func getStrategy(traceCfg map[string]interface{}) (string, error) {
}

func getCollectorEndpoint(traceCfg map[string]interface{}) string {
if cfg, ok := traceCfg[configs]; ok {
endpoint := cfg.(map[string]interface{})
if collectorEndpoint, ok := endpoint[collectorEndpoint]; ok {
return collectorEndpoint.(string)
}
if collectorEndpoint, ok := traceCfg[collectorEndpoint]; ok {
return collectorEndpoint.(string)
}

return defaultCollectorEndpoint
}

func getServiceName(traceCfg map[string]interface{}) string {
if cfg, ok := traceCfg[configs]; ok {
name := cfg.(map[string]interface{})
if service, ok := name[serviceName]; ok {
return service.(string)
}
if service, ok := traceCfg[serviceName]; ok {
return service.(string)
}

//if service_name is not set, get it from the env variable
Expand Down
4 changes: 1 addition & 3 deletions docs/zh/start/trace/jaeger.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"enable": true,
"driver": "jaeger",
"config": {
"config": {
"service_name": "layotto"
}
"service_name": "layotto"
}
}
}
Expand Down

0 comments on commit c76afc1

Please sign in to comment.