gocat.v2
is written in pure golang, which means it's no longer depend on ccat.
And CGO
is not required either.
In gocat
, you have to create an instance like this:
import (
"gocat"
)
cat := gocat.Instance()
cat.LogEvent("foo", "bar")
It is equal to the following codes in gocat.v2
import (
"github.com/Meituan-Dianping/cat-go/cat"
)
cat.LogEvent("foo", "bar")
See case1
The following APIs do not return pointer anymore.
type Cat interface {
func NewTransaction(mtype, name string) *message.Transaction
func NewEvent(mtype, name string) *message.Event
func NewMetricHelper(m_name string) *MetricHelper
}
Have changed to:
type Cat interface {
func NewTransaction(mtype, name string) message.Transactor
func NewEvent(mtype, name string) message.Messeger
func NewMetricHelper(m_name string) MetricHelper
}
No influences if you have used :=
or var
to receive our returned value.
The following APIs requires time.Time or time.Duration as parameter, which used to be int64
(timestampInNanosecond).
type Message interface {
SetTimestamp(timestampInNano int64)
GetTimestamp() int64
}
type Transaction interface {
SetDuration(durationInNano int64)
GetDuration() int64
SetDurationStart(durationStartInNano int64)
}
Have changed to:
type Message interface {
SetTime(time time.Time)
GetTime() time.Time
}
type Transaction interface {
SetDuration(duration time.Duration)
GetDuration() time.Duration
SetDurationStart(time time.Time)
}
If you have used the mentioned APIs above, migrate to gocat.v2
will take you some time.