refactor(project): 重构项目并更新依赖
- 更新 README.md 中的项目结构说明 - 添加 pprof 性能分析工具的使用说明 - 更新 build.bat 文件,增加 proto 文件编译命令 - 升级 go-logr/logr 依赖至 v1.3.0 - 降级 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc 依赖至 v1.16.0 - 降级 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp 依赖至 v1.16.0 - 升级 go.opentelemetry.io/otel/trace 依赖至 v1.20.0 - 移除 logic/main.go 中的冗余代码 - 重构 logic/server.go 中的 Start 函数 - 更新 login/main.go 文件
This commit is contained in:
45
common/serialize/go-jsonrpc/metrics/metrics.go
Normal file
45
common/serialize/go-jsonrpc/metrics/metrics.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"go.opencensus.io/stats"
|
||||
"go.opencensus.io/stats/view"
|
||||
"go.opencensus.io/tag"
|
||||
)
|
||||
|
||||
// Global Tags
|
||||
var (
|
||||
RPCMethod, _ = tag.NewKey("method")
|
||||
)
|
||||
|
||||
// Measures
|
||||
var (
|
||||
RPCInvalidMethod = stats.Int64("rpc/invalid_method", "Total number of invalid RPC methods called", stats.UnitDimensionless)
|
||||
RPCRequestError = stats.Int64("rpc/request_error", "Total number of request errors handled", stats.UnitDimensionless)
|
||||
RPCResponseError = stats.Int64("rpc/response_error", "Total number of responses errors handled", stats.UnitDimensionless)
|
||||
)
|
||||
|
||||
var (
|
||||
// All RPC related metrics should at the very least tag the RPCMethod
|
||||
RPCInvalidMethodView = &view.View{
|
||||
Measure: RPCInvalidMethod,
|
||||
Aggregation: view.Count(),
|
||||
TagKeys: []tag.Key{RPCMethod},
|
||||
}
|
||||
RPCRequestErrorView = &view.View{
|
||||
Measure: RPCRequestError,
|
||||
Aggregation: view.Count(),
|
||||
TagKeys: []tag.Key{RPCMethod},
|
||||
}
|
||||
RPCResponseErrorView = &view.View{
|
||||
Measure: RPCResponseError,
|
||||
Aggregation: view.Count(),
|
||||
TagKeys: []tag.Key{RPCMethod},
|
||||
}
|
||||
)
|
||||
|
||||
// DefaultViews is an array of OpenCensus views for metric gathering purposes
|
||||
var DefaultViews = []*view.View{
|
||||
RPCInvalidMethodView,
|
||||
RPCRequestErrorView,
|
||||
RPCResponseErrorView,
|
||||
}
|
||||
Reference in New Issue
Block a user