Git Product home page Git Product logo

go-sdk's People

Contributors

sunzeyu16832 avatar thinkingdataanalytics avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-sdk's Issues

NewBatchConsumer参数问题

NewBatchConsumer参数问题
可以的话加一个所有参数手动指定的构造函数吧
现在这样没办法同时修改某些配置

停服调用close后 导致panic

在游戏停服时, 在main函数里 使用defer 调用 TDAnalytics::Close 函数,但是在log里发现有 panic 发生,最终定位到是这行

c.ch <- parseTime(bdata)

往一个close的channel里写数据导致的panic

github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*LogConsumer).Add(0xc0000bb8c0, {{0xc0006220c8, 0x7}, {0x0, 0x0}, {0x2aa5e2f, 0x5}, {0xc0009e0048, 0x17}, {0x2aa64ce, ...}, ...})
       ......省略部分.........../github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/consumer_log.go:84 +0xb1
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*TDAnalytics).add(0x46ed720, {0xc0006220c8, 0x7}, {0x0, 0x0}, {0x2aa5e2f, 0x5}, {0x2aa64ce, 0x6}, {0x0, ...}, ...)
        ......省略部分.........../github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/thinkingdata.go:246 +0x33b
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*TDAnalytics).track(0xc001068000, {0xc0006220c8, 0x7}, {0x0, 0x0}, {0x2aa5e2f, 0x5}, {0x2aa64ce, 0xc00013f530}, {0x0, ...}, ...)
       ......省略部分.........../github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/thinkingdata.go:144 +0x21e
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*TDAnalytics).Track(0x263fde0, {0xc0006220c8, 0x2aa5c45}, {0x0, 0xc0012e77a0}, {0x2aa64ce, 0xc0012e77e0}, 0xc0012e7800)
       ......省略部分.........../github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/thinkingdata.go:103 +0x4b

所以这里是不是要加一个 判断,如果channel已经关闭了,后续在有数据进来 直接丢掉,或者加一些同步机制,保证不会出现提前close的情况

close之后直接return疑问

for {
			flush := false
			select {
			case rec, ok := <-c.ch:
				if !ok {
					return
				}

channel发现close之后直接return,buffer里面还有数据没法送,是不是就丢了

SDK 日志格式有问题

通过 logbus 打日志时,如果日志类型为设置用户属性,则会报错。
原因:

  • sdk 打的日志序列化后,必定带上 #event_name, 不管有没有值,导致logbus 检查日志格式时,报错 设置用户属性事件 不能带#event_name

解决方案:

EventName  string                 `json:"#event_name, omitempty"`

对BatchConsumer的buffer访问存在data race

WARNING: DATA RACE
Read at 0x00c000429660 by goroutine 73:
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*BatchConsumer).Add()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/consumer_batch.go:163 +0x43c
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*TDAnalytics).add()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/thinkingdata.go:202 +0x554
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*TDAnalytics).track()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/thinkingdata.go:108 +0x54f
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*TDAnalytics).Track()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/thinkingdata.go:82 +0x18e

Previous write at 0x00c000429660 by goroutine 18:
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.(*BatchConsumer).Flush()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/consumer_batch.go:197 +0xaa8
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.initBatchConsumer.func1()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/consumer_batch.go:151 +0x12f

Goroutine 18 (running) created at:
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.initBatchConsumer()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/consumer_batch.go:146 +0x8e5
github.com/ThinkingDataAnalytics/go-sdk/thinkingdata.NewBatchConsumerWithConfig()
C:/Server/vendor/github.com/ThinkingDataAnalytics/go-sdk/thinkingdata/consumer_batch.go:90 +0x109

parseTime() allocs with more heap

Every time data is written to a file, parseTime() must be called, and the regexp in the method must be initialized.
The more data is written, the greater the cumulative consumption.
Suggest initializing regexp and processing it globally.

thinkingdata2_17132513372866

`
func parseTime(input []byte) string {

var re = regexp.MustCompile(`"((\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(?:\.(\d{3}))\d*)(Z|[\+-]\d{2}:\d{2})"`)
var substitution = "\"$2 $3.$4\""

for re.Match(input) {
	input = re.ReplaceAll(input, []byte(substitution))
}
return string(input)

}
`

LogBus是什么

sdk把数据写到本地文件之后, LogBus会把文件传输到服务器?LogBus是什么咋没介绍?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.