All Projects → asppj → lolita

asppj / lolita

Licence: MIT License
基于gin 微服务opentrace集成

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to lolita

protop
protobufs, packaged. https://protop.io
Stars: ✭ 68 (+423.08%)
Mutual labels:  grpc
grpc-spring-boot-starter
No description or website provided.
Stars: ✭ 16 (+23.08%)
Mutual labels:  grpc
httpbook
Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
Stars: ✭ 18 (+38.46%)
Mutual labels:  grpc
waypoint-plugin-examples
An example repository that demonstrates how to create and run an external Waypoint plugin
Stars: ✭ 16 (+23.08%)
Mutual labels:  grpc
jmeter-grpc-plugin
A JMeter plugin supports load test gRPC
Stars: ✭ 36 (+176.92%)
Mutual labels:  grpc
go-grpc-pg
Simple service exposing a gRPC interface, with a connection to PostgreSQL on the backend
Stars: ✭ 33 (+153.85%)
Mutual labels:  grpc
dashboard
Project for managing ML model and deploying ML module. It can deploy the Rekcurd service to Kubernetes cluster.
Stars: ✭ 27 (+107.69%)
Mutual labels:  grpc
mnemosyne
Session management service with RPC API based on protobuf.
Stars: ✭ 15 (+15.38%)
Mutual labels:  grpc
Book-Finder
Book Finder application is a client-server application (gRPC) for educational purposes.
Stars: ✭ 20 (+53.85%)
Mutual labels:  grpc
actix-web-opentelemetry
OpenTelemetry integration for Actix Web
Stars: ✭ 45 (+246.15%)
Mutual labels:  jaeger
exdgraph
gRPC based Elixir Dgraph client. Under development.
Stars: ✭ 112 (+761.54%)
Mutual labels:  grpc
go-zipkin-demo
Laravel + go-micro + grpc + Zipkin
Stars: ✭ 65 (+400%)
Mutual labels:  grpc
liftbridge-api
Protobuf definitions for the Liftbridge gRPC API. https://github.com/liftbridge-io/liftbridge
Stars: ✭ 15 (+15.38%)
Mutual labels:  grpc
vscode-csharp-snippets
Extension of C# Snippets for Visual Studio Code
Stars: ✭ 22 (+69.23%)
Mutual labels:  grpc
meshRPC
Automatic Service Mesh and RPC generation for Go micro services, it's a humble alternative to gRPC with Istio.
Stars: ✭ 69 (+430.77%)
Mutual labels:  grpc
go-grpc-bidirectional-streaming-example
gRPC bidirectional streaming example written in golang
Stars: ✭ 83 (+538.46%)
Mutual labels:  grpc
thinkgo
Public libraries and components for glang development.
Stars: ✭ 14 (+7.69%)
Mutual labels:  grpc
dalal-street-server
Server for Pragyan's Dalal Street
Stars: ✭ 65 (+400%)
Mutual labels:  grpc
tron-rpc
波场钱包节点对接
Stars: ✭ 58 (+346.15%)
Mutual labels:  grpc
pulseha
PulseHA is a active-passive high availability cluster daemon that uses GRPC and is written in GO.
Stars: ✭ 15 (+15.38%)
Mutual labels:  grpc

Build Status

  1. Logging - 用于记录离散的事件。例如,应用程序的调试信息或错误信息。它是我们诊断问题的依据。
  2. Metrics - 用于记录可聚合的数据。例如,队列的当前深度可被定义为一个度量值,在元素入队或出队时被更新;HTTP 请求个数可被定义为一个计数器,新请求到来时进行累加。
  3. Tracing - 用于记录请求范围内的信息。例如,一次远程方法调用的执行过程和耗时。它是我们排查系统性能问题的利器。

Opentrace

  1. 埋点:gin-web,http 请求,grpc 请求封装并埋点;
  2. 收集:zipkin,AppDash,jaeger 选择其一(阿里云日志服务优先)
  3. 展示:

埋点

  1. Inject 请求方注入
    • http header
    • grpc with 接口
  2. Extract 服务方提取
    • http header
    • grpc with 接口

1. gin-web 服务方 埋点(完成,待测)

添加中间件的方式

2. requests 请求 埋点(完成,待测)

封装 GET、POST、DELET、PUT 等 http 请求方法

3. grpc 埋点(完成,待测)

grpc 使用 grpc 提供的钩子函数

4. DB 驱动埋点

  1. mongodb 埋点 (完成)
  2. redis 埋点 (未开始)
  3. es 埋点 (完成)

opentrance-go 介绍

1. Trace 调用链

2. Span 调用链节点

1. Span-Tag 调用链节点标签

ext.PeerHostname.Set(sp, c.Request.Host)
ext.PeerAddress.Set(sp, c.Request.RemoteAddr)
ext.PeerService.Set(sp, c.ClientIP())
ext.HTTPStatusCode.Set(sp, uint16(statusCode))
ext.HTTPMethod.Set(sp, c.Request.Method)
ext.HTTPUrl.Set(sp, c.Request.URL.Path)

2. Span-Log 调用链节点日志

span.LogKV("Request:", ctx.Request)
span.LogFields("Request:", ctx.Request)

3. Baggage item 全局范围不属于 span

// set
span.SetBaggageItem("greeting", greeting)
// get
greeting := span.BaggageItem("greeting")

4. Sampling,采样[0,1]

sampling.priority - integer

1. const,全量采集,采样率设置0,1 分别对应打开和关闭
2. probabilistic ,概率采集,默认万份之一,0~1之间取值,
3. rateLimiting ,限速采集,每秒只能采集一定量的数据
4. remote ,一种动态采集策略,根据当前系统的访问量调节采集策略

inject/extract

childOf、followOf

1. opentracing.GlobalTracer().Extract 方法提取HTTP头中的spanContexts
2. opentracing.ChildOf 方法基于提取出来的spanContexts生成新的child spanContexts
3. opentracing.GlobalTracer().StartSpan 方法生成一个新的span
4. github.com/opentracing/opentracing-go/ext 通过ext可以为追踪添加一些tag来展示更多信息,比如URL,请求类型(GET,POST...), 返回码
5. sp.Finish() 结束这一个span

context 传递 span

// 存储到 context 中
ctx := context.Background()
ctx = opentracing.ContextWithSpan(ctx, span)
//....

// 其他过程获取并开始子 span
span, ctx := opentracing.StartSpanFromContext(ctx, "newspan")
defer span.Finish()
// StartSpanFromContext 会将新span保存到ctx中更新

context 传递

网络方式传递

Extrect 从 Header 中获取
Extrect 从 grpc Ctx 中提取
inject 注入 Header Inject 注入 grpc Ctx

# 进程中
opentracing.SpanFromContext(ctx)
# 或
span, ctx := opentracing.StartSpanFromContext(ctx, "newspan")
gin.Context:ctx.Request.Context()
gin.Context!=context.Context!=opentracing.SpanContext
mongodb/redis/es:
  • context 不再使用 DefaultContext()
  • 统一使用 gin.request.Context()[因为携带了 span ]
  • 另外添加中间件自定义每个接口的超时时间

jaeger 搭建(本地)

all_in_one 镜像 tools->jaeger->docker-compose.yml

prometheus metrics 统计

prometheus 收集数据

Grafana 展示数据

prometheus 指标类型

  1. Counter 单调增
  2. Guage 可增减
  3. Historygram 直方图
  4. Summary 聚合图(1-10 占比,10-20 占比。。。)

gin-ext web 中间件

  1. 启动时长-uptime
  2. 请求总数-http_request_count_total
  3. 请求延时-http_request_duration_seconds
  4. 请求字节-http_request_size_bytes
  5. 响应字节-http_response_size_bytes

grpc 中间件

kafka golang 驱动封装

消费者
  1. 消费延时-kafka_consumer_duration_seconds
  2. 消费成功数-kafka_consumer_success_total
  3. 消费失败数-kafka_consumer_failed_total
  4. Payload 字节数-kafka_consumer_payload_byte_size
生产者
  1. 生产延时-kafka_product_duration_seconds
  2. 生产成功数-kafka_product_success_total
  3. 生产失败数-kafka_product_failed_total
  4. Payload 字节数-kafka_product_payload_byte_size

kafka exporter 监控

与版本有关参考

官方 sdk

  • github.com/prometheus/client_golang

工具

dem 开发辅助工具 https://github.com/asppj/dem

opentrace 参考资料

  1. 几种分布式调用链监控组件的比较
  2. opentracing 翻译版
  3. grpc-opentracing 中间件
  4. openTracing 讲解
  5. 阿里云日志服务配置 aliyun-log-jaeger

prometheus 参考资料

  1. prometheus 介绍
  2. 【监控】Kafka - 详细指标
  3. Grafana 与数据可视化
  4. 其他参考

Thanks

avatar

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].