1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jaeger-client-goでZipkinトランスポートを使う方法

Last updated at Posted at 2017-12-02

transport/zipkin/example_test.goを参考に、以下のようにZipkinへのReporterをTracerに設定する。

transport, err := zipkin.NewHTTPTransport(
    "http://169.254.123.123:9411/api/v1/spans",
    zipkin.HTTPBatchSize(10),
    zipkin.HTTPLogger(jlog.StdLogger),
)
if err != nil {
    log.Fatalf("Cannot initialize Zipkin HTTP transport: %v", err)
    }
tracer, closer := jaeger.NewTracer(
    "my-service-name",
    jaeger.NewConstSampler(true),
    jaeger.NewRemoteReporter(transport, nil),
)
defer closer.Close()
opentracing.SetGlobalTracer(tracer)

ポイントは、

  • jaeger.NewTracerにはReporter(Spanを送るコンポーネント)を設定できる
  • jaeger.NewRemoteReporter(transport, nil)transport経由でネットワーク越しにSpanを送るReporterをつくれる
  • zipkin.NewHTTPTransportでZipkin HTTP Endpoint宛のTransportをつくれる
  • zipkin.NewHTTPTransportの第一引数にZipkin HTTP EndpointのURLを指定する

Zipkin HTTP EndpointのURLは基本的に、http://$ZIPKIN_HOST:9411/api/v1/spans
という形式になるはず。

応用

  • Kubernetesにdd-agent + dd-zipkin-proxyをデプロイする場合、Zipkin HTTP Endpoint URLはhttp://$MAGIC_IP:9411/api/v1/spans のようにする
    • Zipkin HTTP Endpointを各ノードに起き、$MAGIC_IPへアクセスすると各ノードのZipkin HTTP EndpointにDNATされるようにしておく
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?