docker 启动kitex 的opentelemetry

https://github.com/cloudwego/kitex-examples/blob/main/opentelemetry/docker-compose.yaml

下载两个yaml文件:docker-compose.yaml  otel-collector-config.yaml

在该目录下执行

docker-compose up -d   

How To Run

Docker

Ensure Docker has been installed.

Run opentelemetry-collector, jaeger, victoriametrics, grafana

docker-compose up -d

Run Kitex server

go run server/main.go

Run Kitex client

go run client/main.go

Monitoring

监控

You can then navigate to http://localhost:16686 to access the Jaeger UI. (You can visit Monitor Jaeger for details)

查看指标

You can then navigate to http://localhost:3000 to access the Grafana UI. (You can visit Monitor Grafana for metrics)

数据源

Http URL:

http://victoriametrics:8428/
Add A Dashboard And A Panel

增加数据平面

Support Metrics
  • RPC Metrics
  • Runtime Metrics

Tracing Associated Logs

Set Logger Impl

import (
    kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus"
)

func init()  {
    klog.SetLogger(kitexlogrus.NewLogger())
    klog.SetLevel(klog.LevelDebug)

}

Log With Context

// Echo implements the Echo interface.
func (s *EchoImpl) Echo(ctx context.Context, req *api.Request) (resp *api.Response, err error) {
	klog.CtxDebugf(ctx, "echo called: %s", req.GetMessage())
	return &api.Response{Message: req.Message}, nil
}

view log

{"level":"debug","msg":"echo called: my request","span_id":"056e0cf9a8b2cec3","time":"2022-03-09T02:47:28+08:00","trace_flags":"01","trace_id":"33bdd3c81c9eb6cbc0fbb59c57ce088b"}

Work with Jaeger

Introducing native support for OpenTelemetry in Jaeger

Jaeger natively supports OTLP protocol, and we can send data directly to Jaeger without OpenTelemetry Collector

Jaeger Architecture

Image from jaeger

img.png

Demo

Run Jaeger with COLLECTOR_OTLP_ENABLED
version: "3.7"
services:
  # Jaeger
  jaeger-all-in-one:
    image: jaegertracing/all-in-one:latest
    environment:
      - COLLECTOR_OTLP_ENABLED=true
    ports:
      - "4317:4317"   # OTLP gRPC receiver
Config Exporter with Environment
export OTEL_EXPORTER_OTLP_ENDPOINT=http://host.docker.internal:4317
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
Run Exeample App and View Jaeger

img.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值