Documentation ¶
Overview ¶
Package tingyun3 听云性能采集探针(sdk)
Copyright 2021 冯立强 fenglq@tingyun.com. All rights reserved.
Copyright 2021 冯立强 fenglq@tingyun.com. All rights reserved.
Index ¶
- Constants
- func AppendListenAddress(address string)
- func CatchRequestHeaders() []string
- func ConfigRead(name string) (interface{}, bool)
- func Enabled() bool
- func FindCallerName(skip int, tempStacks []uintptr, isNative func(string) bool) (callerName string)
- func GetCallerName(layer int) string
- func GetCallerPC(layer int) (l int, pc uintptr)
- func GetGID() int64
- func GetRootCallerName(layer int) string
- func GetTrackToken() (string, string)
- func HttpClientDo(ptr *http.Client, req *http.Request) (*http.Response, error)
- func HttpServerServe(srv *http.Server, l net.Listener) error
- func LocalClear()
- func LocalDelete(id int) interface{}
- func LocalGet(id int) interface{}
- func LocalSet(id int, object interface{})
- func Log() *log.Logger
- func MatchCallerName(layer int, funcname string) bool
- func ReadLocalConfigInteger(id int, defaultValue int64) int64
- func ReadServerConfigBool(id int, defaultValue bool) bool
- func Register(p uintptr)
- func ServerMuxHandle(ptr *http.ServeMux, pattern string, handler http.Handler)
- func ServerMuxHandler(ptr *http.ServeMux, r *http.Request) (h http.Handler, pattern string)
- func SetAction(action *Action)
- func SetComponent(c *Component)
- func WrapHttpClientDo(ptr *http.Client, req *http.Request) (*http.Response, error)
- func WrapHttpServerServe(srv *http.Server, l net.Listener) error
- func WrapServerMuxHandle(ptr *http.ServeMux, pattern string, handler http.Handler)
- func WrapServerMuxHandler(ptr *http.ServeMux, r *http.Request) (h http.Handler, pattern string)
- func WraphttpNotFound(w http.ResponseWriter, r *http.Request)
- func WraphttpTransportroundTrip(t *http.Transport, req *http.Request) (*http.Response, error)
- func WraphttputilReverseProxyServeHTTP(p *httputil.ReverseProxy, rw http.ResponseWriter, req *http.Request)
- 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) Duration() time.Duration
- func (a *Action) Finish()
- func (a *Action) FixBegin(begin time.Time)
- func (a *Action) GetMethod() string
- func (a *Action) GetName() string
- func (a *Action) GetTransactionID() string
- func (a *Action) GetTxData() string
- func (a *Action) GetURL() string
- func (a *Action) HasError() bool
- func (a *Action) Ignore()
- func (a *Action) IsTask() bool
- func (a *Action) OnEnd(cb func())
- func (a *Action) SetBackEnabled(enabled bool)
- func (a *Action) SetConsumer(vender string, host, queue string)
- func (a *Action) SetError(e interface{})
- func (a *Action) SetException(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 ClientDoFunc
- 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) FixStackEnd(skip int, checkRemovedFunction func(string) bool)
- func (c *Component) GetAction() *Action
- func (c *Component) SetError(e interface{}, errType string, skipStack int)
- func (c *Component) SetException(e interface{}, errType string, skipStack int)
- func (c *Component) SetMethod(method string)
- func (c *Component) SetStatusCode(statusCode int)
- func (c *Component) SetTxData(txData string)
- func (c *Component) SetURL(url string)
- type NetConnWrapper
- func (c *NetConnWrapper) Close() error
- func (c *NetConnWrapper) LocalAddr() net.Addr
- func (c *NetConnWrapper) Read(b []byte) (n int, err error)
- func (c *NetConnWrapper) RemoteAddr() net.Addr
- func (c *NetConnWrapper) SetDeadline(t time.Time) error
- func (c *NetConnWrapper) SetReadDeadline(t time.Time) error
- func (c *NetConnWrapper) SetWriteDeadline(t time.Time) error
- func (c *NetConnWrapper) Url() string
- func (c *NetConnWrapper) Write(b []byte) (n int, err error)
- type RequestHandler
- type RoutineLocal
- type RuntimeSnap
- type Unit
Constants ¶
const ( ComponentDefault = 0 ComponentDefaultDB = 32 ComponentMysql = 33 ComponentPostgreSQL = 34 ComponentMSSQL = 35 ComponentSQLite = 36 ComponentOracle = 37 ComponentMongo = 48 ComponentMemCache = 49 ComponentRedis = 50 ComponentMQC = 56 ComponentMQP = 57 ComponentExternal = 64 )
* 组件类型定义
const ( StorageIndexDatabase = 1 + 8*0 StorageIndexRedis = 1 + 8*1 StorageIndexEcho = 1 + 8*2 StorageIndexMongo = 1 + 8*3 StorageIndexMgo = 2 + 8*3 StorageIndexBeego = 1 + 8*4 StorageIndexIris = 1 + 8*5 StorageIndexGin = 1 + 8*6 StorageGorillaWS = 1 + 8*7 StorageMQKafka = 1 + 8*8 )
const ( ConfigLocalIntegerWebsocketIgnore = 12 ConfigLocalIntegerRestfulUUIDMinSize = 13 ServerConfigBoolAutoActionNaming = 2 ServerConfigBoolMQEnabled = 17 ServerConfigBoolErrorCollectorStackEnabled = 21 ServerConfigBoolKafkaTracingEnabled = 22 )
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 = "v1.0.0"
Variables ¶
This section is empty.
Functions ¶
func AppendListenAddress ¶ added in v1.6.2
func AppendListenAddress(address string)
func CatchRequestHeaders ¶ added in v1.6.0
func CatchRequestHeaders() []string
func FindCallerName ¶ added in v1.8.1
func GetRootCallerName ¶ added in v0.2.1
func GetTrackToken ¶ added in v1.8.0
return token_name, token_value
func MatchCallerName ¶ added in v0.2.1
func ReadLocalConfigInteger ¶ added in v1.1.1
func ReadServerConfigBool ¶ added in v1.6.0
func ServerMuxHandle ¶
func ServerMuxHandler ¶
func WrapHttpClientDo ¶
func WrapHttpServerServe ¶ added in v1.0.0
func WrapServerMuxHandle ¶
func WrapServerMuxHandler ¶
func WraphttpNotFound ¶
func WraphttpNotFound(w http.ResponseWriter, r *http.Request)
func WraphttpTransportroundTrip ¶ added in v1.3.0
func WraphttputilReverseProxyServeHTTP ¶ added in v1.3.0
func WraphttputilReverseProxyServeHTTP(p *httputil.ReverseProxy, rw http.ResponseWriter, req *http.Request)
Types ¶
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
Action : 事务对象
func CreateAction ¶
CreateAction : 在方法method中调用并 创建一个名为 name的事务,
func CreateTask ¶
func (*Action) AddCustomParam ¶
AddCustomParam : 添加自定义参数
func (*Action) AddRequestParam ¶
AddRequestParam : 添加请求参数
func (*Action) AddResponseParam ¶
AddResponseParam : 添加应答参数
func (*Action) CreateComponent ¶
CreateComponent : 创建函数/方法类型的组件 参数
method : 类名.方法名, 例如 main.user.login
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 ¶
CreateMongoComponent 创建 Mongo 组件
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) GetTransactionID ¶ added in v1.3.1
func (*Action) GetTxData ¶
GetTxData : 跨应用追踪接口,用于被调用端,获取当前事务的执行性能信息,通过http头或者自定义协议传回调用端
返回值: 事务的性能数据
func (*Action) SetBackEnabled ¶ added in v1.6.0
func (*Action) SetConsumer ¶ added in v1.8.0
func (*Action) SetError ¶
func (a *Action) SetError(e interface{})
SetError : 事务发生错误或异常时调用,记录事务的运行时错误信息
func (*Action) SetException ¶
func (a *Action) SetException(e interface{})
SetException : 事务发生错误或异常时调用,记录事务的运行时错误信息
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时刻 当时长超出堆栈阈值时,记录当前组件的代码堆栈
func (*Component) FixStackEnd ¶
End : 内部使用, skip为跳过的调用栈数
func (*Component) SetException ¶
SetException : 组件异常捕获
func (*Component) SetStatusCode ¶ added in v1.3.0
type NetConnWrapper ¶ added in v1.1.0
type NetConnWrapper struct {
// contains filtered or unexported fields
}
func (*NetConnWrapper) Close ¶ added in v1.1.0
func (c *NetConnWrapper) Close() error
func (*NetConnWrapper) LocalAddr ¶ added in v1.1.0
func (c *NetConnWrapper) LocalAddr() net.Addr
func (*NetConnWrapper) Read ¶ added in v1.1.0
func (c *NetConnWrapper) Read(b []byte) (n int, err error)
func (*NetConnWrapper) RemoteAddr ¶ added in v1.1.0
func (c *NetConnWrapper) RemoteAddr() net.Addr
func (*NetConnWrapper) SetDeadline ¶ added in v1.1.0
func (c *NetConnWrapper) SetDeadline(t time.Time) error
func (*NetConnWrapper) SetReadDeadline ¶ added in v1.1.0
func (c *NetConnWrapper) SetReadDeadline(t time.Time) error
func (*NetConnWrapper) SetWriteDeadline ¶ added in v1.1.0
func (c *NetConnWrapper) SetWriteDeadline(t time.Time) error
func (*NetConnWrapper) Url ¶ added in v1.1.0
func (c *NetConnWrapper) Url() string
type RequestHandler ¶ added in v1.0.4
type RequestHandler struct {
// contains filtered or unexported fields
}
type RoutineLocal ¶
type RoutineLocal struct {
// contains filtered or unexported fields
}
RoutineLocal : 事务线程局部存储对象
type RuntimeSnap ¶ added in v1.4.0
type RuntimeSnap struct { CountOfGoRoutine uint64 CountOfCgoCall uint64 CountOfGC uint64 CountOfFrees uint64 CountOfMallocs uint64 CountOfLookups uint64 CountOfFD uint32 CountOfThreads uint32 TimeOfGC_ns uint64 SizeOfMemTotalSys uint64 SizeOfMemStackSys uint64 SizeOfMSpanSys uint64 SizeOfMemHeapSys uint64 SizeOfMCacheSys uint64 SizeOfBuckHashSys uint64 SizeOfMemHeapInuse uint64 SizeOfMemStackInuse uint64 SizeOfMSpanInuse uint64 SizeOfMCacheInuse uint64 SizeOfMemVM uint64 SizeOfMemRss uint64 CpuProcess cpuInfo CpuSystem cpuInfo }
func (*RuntimeSnap) Snap ¶ added in v1.4.0
func (snap *RuntimeSnap) Snap()
func (*RuntimeSnap) Sub ¶ added in v1.4.0
func (snap *RuntimeSnap) Sub(lastSnap *RuntimeSnap) *runtimeBlock
Source Files ¶
- api-action.go
- api-application.go
- api-component.go
- cgo.go
- clink_amd64.go
- common.go
- config.go
- control-application.go
- localstorage.go
- main.go
- private-action.go
- private-application.go
- runtimeinfo.go
- service-dc_interface.go
- struct-appdata.go
- struct-errorinfo.go
- struct-performance.go
- sysinfo.go
- tingyun.go
- util.go
Directories ¶
Path | Synopsis |
---|---|
frameworks
|
|
libs
|
|
list
Package list : a list
|
Package list : a list |
pool
Package pool 无锁消息池,多读多写, 用于goroutine 间收发消息
|
Package pool 无锁消息池,多读多写, 用于goroutine 间收发消息 |
mq
|
|
nosql
|
|
cache_config
配置信息缓存的性能优化版本,无锁访问, array存储
|
配置信息缓存的性能优化版本,无锁访问, array存储 |
config
无锁模式的配置信息读写
|
无锁模式的配置信息读写 |
httprequest
Post请求异步封装
|
Post请求异步封装 |
logger
日志功能模块。
|
日志功能模块。 |
service
类线程封装
|
类线程封装 |
zip
zip封装
|
zip封装 |