|
|
|
@ -25,22 +25,22 @@ type apiMongolLog struct {
|
|
|
|
|
RequestMethod string `json:"request_method,omitempty" bson:"request_method,omitempty"` //【请求】方式
|
|
|
|
|
RequestParams interface{} `json:"request_params,omitempty" bson:"request_params,omitempty"` //【请求】参数
|
|
|
|
|
RequestHeader interface{} `json:"request_header,omitempty" bson:"request_header,omitempty"` //【请求】头部
|
|
|
|
|
RequestIp string `json:"request_ip,omitempty" bson:"request_ip,omitempty"` //【请求】请求Ip
|
|
|
|
|
ResponseHeader interface{} `json:"response_header,omitempty" bson:"response_header,omitempty"` //【返回】头部
|
|
|
|
|
ResponseStatusCode int `json:"response_status_code,omitempty" bson:"response_status_code,omitempty"` //【返回】状态码
|
|
|
|
|
ResponseBody interface{} `json:"response_body,omitempty" bson:"response_body,omitempty"` //【返回】内容
|
|
|
|
|
ResponseContentLength int64 `json:"response_content_length,omitempty" bson:"response_content_length,omitempty"` //【返回】大小
|
|
|
|
|
ResponseTime dorm.BsonTime `json:"response_time,omitempty" bson:"response_time,omitempty"` //【返回】时间
|
|
|
|
|
System struct {
|
|
|
|
|
HostName string `json:"host_name,omitempty" bson:"host_name,omitempty"` //【系统】主机名
|
|
|
|
|
InsideIp string `json:"inside_ip,omitempty" bson:"inside_ip,omitempty"` //【系统】内网ip
|
|
|
|
|
Os string `json:"os,omitempty" bson:"os,omitempty"` //【系统】系统类型
|
|
|
|
|
Arch string `json:"arch,omitempty" bson:"arch,omitempty"` //【系统】系统架构
|
|
|
|
|
} `json:"system,omitempty" bson:"system,omitempty"` //【系统】信息
|
|
|
|
|
HostName string `json:"host_name" bson:"host_name"` //【系统】主机名
|
|
|
|
|
InsideIp string `json:"inside_ip" bson:"inside_ip"` //【系统】内网ip
|
|
|
|
|
OutsideIp string `json:"outside_ip" bson:"outside_ip"` //【系统】外网ip
|
|
|
|
|
Os string `json:"os" bson:"os"` //【系统】系统类型
|
|
|
|
|
Arch string `json:"arch" bson:"arch"` //【系统】系统架构
|
|
|
|
|
} `json:"system" bson:"system"` //【系统】信息
|
|
|
|
|
Version struct {
|
|
|
|
|
Go string `json:"go,omitempty" bson:"go,omitempty"` //【程序】Go版本
|
|
|
|
|
Sdk string `json:"sdk,omitempty" bson:"sdk,omitempty"` //【程序】Sdk版本
|
|
|
|
|
} `json:"version,omitempty" bson:"version,omitempty"` //【程序】版本信息
|
|
|
|
|
Go string `json:"go" bson:"go"` //【程序】Go版本
|
|
|
|
|
Sdk string `json:"sdk" bson:"sdk"` //【程序】Sdk版本
|
|
|
|
|
} `json:"version" bson:"version"` //【程序】版本信息
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建时间序列集合
|
|
|
|
@ -74,15 +74,15 @@ func (c *ApiClient) MongoDelete(ctx context.Context, hour int64) (*mongo.DeleteR
|
|
|
|
|
// 记录日志
|
|
|
|
|
func (c *ApiClient) mongoRecord(ctx context.Context, data apiMongolLog, sdkVersion string) {
|
|
|
|
|
|
|
|
|
|
data.LogId = primitive.NewObjectID() //【记录】编号
|
|
|
|
|
data.System.HostName = c.config.systemHostName //【系统】主机名
|
|
|
|
|
data.System.InsideIp = c.config.systemInsideIp //【系统】内网ip
|
|
|
|
|
data.System.OutsideIp = c.config.systemOutsideIp //【系统】外网ip
|
|
|
|
|
data.System.Os = c.config.systemOs //【系统】系统类型
|
|
|
|
|
data.System.Arch = c.config.systemArch //【系统】系统架构
|
|
|
|
|
data.Version.Go = c.config.goVersion //【程序】Go版本
|
|
|
|
|
data.Version.Sdk = sdkVersion //【程序】Sdk版本
|
|
|
|
|
data.TraceId = gotrace_id.GetTraceIdContext(ctx) //【记录】跟踪编号
|
|
|
|
|
data.RequestIp = c.config.systemOutsideIp //【请求】请求Ip
|
|
|
|
|
data.LogId = primitive.NewObjectID() //【记录】编号
|
|
|
|
|
|
|
|
|
|
_, err := c.mongoClient.Database(c.mongoConfig.databaseName).Collection(c.mongoConfig.collectionName).InsertOne(ctx, data)
|
|
|
|
|
if err != nil {
|
|
|
|
|