通用包
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
utils/sls/producer_test.go

94 lines
2.5 KiB

package sls
import (
"testing"
"time"
"gitea.drugeyes.vip/pharnexbase/utils/enum"
)
var pd *Producer
func init() {
pd = NewSLSProducer(
WithEndpoint("cn-hangzhou.log.aliyuncs.com"),
WithAccessKey("LTAI5t8H6fmyMPfZ8JsBmcwS"), // 传入阿里云sls的key
WithAccessSecret("EyWWwT2pOYRVWueYkc9Nnwy3RisYqC"), // 传入阿里云sls的Secret
)
}
func TestProducer(t *testing.T) {
err := pd.SendRequestLog(enum.Env_develop, &Request{
Time: time.Now(),
RemoteAddr: "118.112.98.208",
QueryString: "test001",
RequestMethod: "POST",
RequestUri: "/dc/analyse/senior_aggregation",
Host: "intsynth-server.drugeyes.vip",
RequestBody: "{}",
HttpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 OPR/99.0.0.0",
HttpFinger: "59246b1e1639f4753bcd010bac2ddb01",
HttpReferrer: "http://intsynth-web.drugeyes.vip:7031/",
HttpTraceId: "0121",
XAppId: "LtEolTiV",
XUserData: &UserData{
ID: 1075,
Username: "用户名_IDdXdk4xSU",
OrganizeID: 223,
OrganizeName: "新数据-机构06-权限",
Email: "",
Phone: "17800000051",
},
XDsmData: &DSMData{
AppKey: "ce2f8bcc2f64466d",
PageType: "LIST",
DataCount: 1,
DBData: make([]*DBCount, 0),
},
XCustomData: nil,
ResponseData: nil,
})
if err != nil {
t.Fail()
}
err = pd.SendRequestLog(enum.Env_preview, &Request{
Time: time.Now(),
RemoteAddr: "118.112.98.208",
QueryString: "test001",
RequestMethod: "POST",
RequestUri: "/dc/analyse/senior_aggregation",
Host: "intsynth-server.drugeyes.vip",
RequestBody: "{}",
HttpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 OPR/99.0.0.0",
HttpFinger: "59246b1e1639f4753bcd010bac2ddb01",
HttpReferrer: "http://intsynth-web.drugeyes.vip:7031/",
HttpTraceId: "0121",
XAppId: "LtEolTiV",
XUserData: &UserData{
ID: 1075,
Username: "用户名_IDdXdk4xSU",
OrganizeID: 223,
OrganizeName: "新数据-机构06-权限",
Email: "",
Phone: "17800000051",
},
XDsmData: &DSMData{
AppKey: "ce2f8bcc2f64466d",
PageType: "LIST",
DataCount: 1,
DBData: make([]*DBCount, 0),
},
XCustomData: nil,
ResponseData: nil,
})
if err != nil {
t.Fail()
}
err = pd.Close()
if err != nil {
t.Fail()
}
}