Documentation ¶
Overview ¶
Package tingyun3 听云性能采集探针(sdk)
Index ¶
- Constants
- func ConfigRead(name string) (interface{}, bool)
- func GetCallerName(layer int) string
- func GetCallerPC(layer int) (l int, pc uintptr)
- func GetGID() int64
- func HttpClientDo(ptr uintptr, req *http.Request) (*http.Response, error)
- func LocalDelete(id int) interface{}
- func LocalGet(id int) interface{}
- func LocalSet(id int, object interface{})
- func Log() *log.Logger
- func Register(p uintptr)
- func ServerMuxHandle(ptr uintptr, pattern string, handler http.Handler)
- func ServerServe(srv *http.Server, l net.Listener) error
- func SetAction(action *Action)
- func SetComponent(c *Component)
- func WrapHttpClientDo(ptr uintptr, req *http.Request) (*http.Response, error)
- func WrapServerMuxHandle(ptr uintptr, pattern string, handler http.Handler)
- func WrapServerServe(srv *http.Server, l net.Listener) error
- type Action
- func (a *Action) AddCustomParam(k string, v string)
- func (a *Action) AddRequestParam(k string, v string)
- func (a *Action) AddResponseParam(k string, v string)
- func (a *Action) CreateComponent(method string) *Component
- func (a *Action) CreateDBComponent(dbType uint8, host string, dbname string, table string, op string, ...) *Component
- func (a *Action) CreateExternalComponent(url string, method string) *Component
- func (a *Action) CreateMQComponent(vender string, isConsumer bool, host, queue string) *Component
- func (a *Action) CreateMongoComponent(host, database, collection, op, method string) *Component
- func (a *Action) CreateRedisComponent(host, cmd, key, method string) *Component
- func (a *Action) CreateSQLComponent(dbType uint8, host string, dbname string, sql string, method string) *Component
- func (a *Action) Finish()
- func (a *Action) GetName() string
- func (a *Action) GetTxData() string
- func (a *Action) GetURL() string
- func (a *Action) HasError() bool
- func (a *Action) Ignore()
- func (a *Action) OnEnd(cb func())
- func (a *Action) SetError(e interface{})
- func (a *Action) SetHTTPMethod(httpMethod string)
- func (a *Action) SetHTTPStatus(code uint16, skip int) int
- func (a *Action) SetName(name string, method string)
- func (a *Action) SetStatusCode(code uint16) int
- func (a *Action) SetTrackID(id string)
- func (a *Action) SetURL(name string)
- func (a *Action) Slow() bool
- type Component
- func (c *Component) AppendSQL(sql string)
- func (c *Component) CreateComponent(method string) *Component
- func (c *Component) CreateTrackID() string
- func (c *Component) End(skip int)
- func (c *Component) Finish()
- func (c *Component) FixBegin(begin time.Time)
- func (c *Component) GetAction() *Action
- func (c *Component) SetError(e interface{}, errType string, skipStack int)
- func (c *Component) SetTxData(txData string)
- type RoutineLocal
- type Unit
Examples ¶
Constants ¶
const ( ComponentDefault = 0 ComponentDefaultDB = 32 ComponentMysql = 33 ComponentPostgreSQL = 34 ComponentMSSQL = 35 ComponentSQLite = 36 ComponentMongo = 48 ComponentMemCache = 49 ComponentRedis = 50 ComponentMQC = 56 ComponentMQP = 57 ComponentExternal = 64 )
* 组件类型定义
const ( LevelOff = log.LevelOff LevelCritical = log.LevelCritical LevelError = log.LevelError LevelWarning = log.LevelWarning LevelInfo = log.LevelInfo LevelVerbos = log.LevelVerbos LevelDebug = log.LevelDebug LevelMask = log.LevelMask Audit = log.Audit )
* 日志级别/审计模式控制
const TINGYUN_GO_AGENT_VERSION = "3.1.0"
Variables ¶
This section is empty.
Functions ¶
func WrapHttpClientDo ¶
func WrapServerMuxHandle ¶
Types ¶
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
Action : 事务对象
func CreateAction ¶
CreateAction : 在方法method中调用并 创建一个名为 name的事务,
Example ¶
action, _ := tingyun3.CreateAction("ROUTER", "main.ExampleCreateAction") time.Sleep(time.Millisecond * 100) action.Finish()
Output:
func (*Action) AddCustomParam ¶
AddCustomParam : 添加自定义参数
func (*Action) AddRequestParam ¶
AddRequestParam : 添加请求参数
func (*Action) AddResponseParam ¶
AddResponseParam : 添加应答参数
func (*Action) CreateComponent ¶
CreateComponent : 创建函数/方法类型的组件 参数
method : 类名.方法名, 例如 main.user.login
Example ¶
action, _ := tingyun3.CreateAction("ROUTER", "main.ExampleAction_CreateComponent") component := action.CreateComponent("ExampleAction_CreateComponent") subComponent := component.CreateComponent("subcomponent") time.Sleep(time.Millisecond * 100) subComponent.Finish() component.Finish() action.Finish()
Output:
func (*Action) CreateDBComponent ¶
func (a *Action) CreateDBComponent(dbType uint8, host string, dbname string, table string, op string, method string) *Component
CreateDBComponent 创建数据库或NOSQL性能分解组件 参数:
dbType : 组件类型 (ComponentMysql, ComponentPostgreSQL, ComponentMongo, ComponentMemCache, ComponentRedis) host : 主机地址,可空 dbname : 数据库名称,可空 table : 数据库表名 op : 操作类型, 关系型数据库("SELECT", "INSERT", "UPDATE", "DELETE" ...), NOSQL("GET", "SET" ...) method : 发起这个数据库调用的类名.方法名, 例如 db.query redis.get
func (*Action) CreateExternalComponent ¶
CreateExternalComponent : 创建Web Service性能分解组件 参数:
url : 调用Web Service的url,格式: http(s)://host/uri, 例如 http://www.baidu.com/ method : 发起这个Web Service调用的类名.方法名, 例如 http.Get
func (*Action) CreateMQComponent ¶
CreateMQComponent : 创建一个消息队列组件
vender : mq类型: kafka/rabbit MQ/ActiveMQ
func (*Action) CreateMongoComponent ¶
func (*Action) CreateRedisComponent ¶
CreateRedisComponent : 创建一个Redis数据库访问组件
func (*Action) CreateSQLComponent ¶
func (a *Action) CreateSQLComponent(dbType uint8, host string, dbname string, sql string, method string) *Component
CreateSQLComponent : 以 SQL语句创建一个数据库组件
func (*Action) Finish ¶
func (a *Action) Finish()
Finish : 事务结束时调用 HTTP请求时长 = Finish时刻 - CreateAction时刻
func (*Action) GetTxData ¶
GetTxData : 跨应用追踪接口,用于被调用端,获取当前事务的执行性能信息,通过http头或者自定义协议传回调用端
返回值: 事务的性能数据
func (*Action) SetError ¶
func (a *Action) SetError(e interface{})
SetError : 事务发生错误或异常时调用,记录事务的运行时错误信息
func (*Action) SetHTTPMethod ¶
SetHTTPMethod : 设置 HTTP请求方法名
func (*Action) SetHTTPStatus ¶
SetHTTPStatus : 内部使用: 添加 http状态, skip为跳过的调用栈
func (*Action) SetName ¶
SetName : 设置HTTP请求的友好名称 参数:
instance : 分类, 例如 loginController method : 方法, 例如 POST
func (*Action) SetStatusCode ¶
SetStatusCode : 正常返回0 无效的Action 返回1 如果状态码是被忽略的错误,返回2 错误的状态码,返回3
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component : 构成事务的组件过程
func (*Component) CreateComponent ¶
CreateComponent : 在函数/方法中调用其他函数/方法时,如果认为有必要,调用此方法测量子过程性能
func (*Component) CreateTrackID ¶
CreateTrackID : 跨应用追踪接口,用于调用端,生成一个跨应用追踪id,通过http头或者私有协议发送到被调用端
返回值: 字符串,一个包含授权id,应用id,实例id,事务id等信息的追踪id
func (*Component) Finish ¶
func (c *Component) Finish()
Finish : 停止组件计时 性能分解组件时长 = Finish时刻 - CreateComponent时刻 当时长超出堆栈阈值时,记录当前组件的代码堆栈
type RoutineLocal ¶
type RoutineLocal struct {
// contains filtered or unexported fields
}
RoutineLocal : 事务线程局部存储对象
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
frameworks
|
|
libs
|
|
list
Package list : a list
|
Package list : a list |
pool
Package pool 无锁消息池,多读多写, 用于goroutine 间收发消息
|
Package pool 无锁消息池,多读多写, 用于goroutine 间收发消息 |
nosql
|
|
utils
|
|
cache_config
配置信息缓存的性能优化版本,无锁访问, array存储
|
配置信息缓存的性能优化版本,无锁访问, array存储 |
config
无锁模式的配置信息读写
|
无锁模式的配置信息读写 |
httprequest
Post请求异步封装
|
Post请求异步封装 |
logger
日志功能模块。
|
日志功能模块。 |
service
类线程封装
|
类线程封装 |
zip
zip封装
|
zip封装 |