给jaeger加个ENV配置呗 (#660)

Add custom environment configurations to Jeager
pull/663/head
weisd 4 years ago committed by GitHub
parent f391a62211
commit 5f8a93a410
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      pkg/net/trace/jaeger/config.go

@ -1,11 +1,33 @@
package jaeger package jaeger
import ( import (
"flag"
"os"
"github.com/go-kratos/kratos/pkg/conf/env" "github.com/go-kratos/kratos/pkg/conf/env"
"github.com/go-kratos/kratos/pkg/net/trace" "github.com/go-kratos/kratos/pkg/net/trace"
) )
var (
_jaegerAppID = env.AppID
_jaegerEndpoint = "http://127.0.0.1:9191"
)
func init() {
if v := os.Getenv("JAEGER_ENDPOINT"); v != "" {
_jaegerEndpoint = v
}
if v := os.Getenv("JAEGER_APPID"); v != "" {
_jaegerAppID = v
}
flag.StringVar(&_jaegerEndpoint, "jaeger_endpoint", _jaegerEndpoint, "jaeger report endpoint, or use JAEGER_ENDPOINT env.")
flag.StringVar(&_jaegerAppID, "jaeger_appid", _jaegerAppID, "jaeger report appid, or use JAEGER_APPID env.")
}
// Init Init
func Init() { func Init() {
c := &Config{Endpoint: "http://127.0.0.1:9191", BatchSize: 120} c := &Config{Endpoint: _jaegerEndpoint, BatchSize: 120}
trace.SetGlobalTracer(trace.NewTracer(env.AppID, newReport(c), true)) trace.SetGlobalTracer(trace.NewTracer(_jaegerAppID, newReport(c), true))
} }

Loading…
Cancel
Save