Skip to content

Commit 9c64b4e

Browse files
committed
[#noissue] merge with v1.4.6, v1.4.7
1 parent 0eafb1a commit 9c64b4e

File tree

8 files changed

+160
-54
lines changed

8 files changed

+160
-54
lines changed

agent.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package pinpoint
22

33
import (
44
"errors"
5+
"fmt"
56
"io"
67
"strconv"
78
"sync"
@@ -97,6 +98,7 @@ type exception struct {
9798
const (
9899
cacheSize = 1024
99100
defaultQueueSize = 1024
101+
maxSqlSize = 64 * 1024
100102
)
101103

102104
var globalAgent Agent
@@ -515,6 +517,13 @@ func (agent *agent) cacheError(errorName string) int32 {
515517
return id
516518
}
517519

520+
func abbreviateString(str string, length int) string {
521+
if len(str) <= length {
522+
return str
523+
}
524+
return str[:length] + "...(" + fmt.Sprint(length) + ")"
525+
}
526+
518527
func (agent *agent) cacheSql(sql string) int32 {
519528
if !agent.enable {
520529
return 0
@@ -527,13 +536,14 @@ func (agent *agent) cacheSql(sql string) int32 {
527536
id := atomic.AddInt32(&agent.sqlIdGen, 1)
528537
agent.sqlCache.Add(sql, id)
529538

539+
aSql := abbreviateString(sql, maxSqlSize)
530540
md := sqlMeta{
531541
id: id,
532-
sql: sql,
542+
sql: aSql,
533543
}
534544
agent.tryEnqueueMeta(md)
535545

536-
Log("agent").Infof("cache sql id: %d, %s", id, sql)
546+
Log("agent").Infof("cache sql id: %d, %s", id, aSql)
537547
return id
538548
}
539549

@@ -551,13 +561,14 @@ func (agent *agent) cacheSqlUid(sql string) []byte {
551561
uid := hash.Sum(nil)
552562
agent.sqlUidCache.Add(sql, uid)
553563

564+
aSql := abbreviateString(sql, maxSqlSize)
554565
md := sqlUidMeta{
555566
uid: uid,
556-
sql: sql,
567+
sql: aSql,
557568
}
558569
agent.tryEnqueueMeta(md)
559570

560-
Log("agent").Infof("cache sql uid: %#v, %s", uid, sql)
571+
Log("agent").Infof("cache sql uid: %#v, %s", uid, aSql)
561572
return uid
562573
}
563574

errors.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ func (span *span) addCauserCallStack(err error, eid int64) {
9595
if !ok {
9696
break
9797
}
98+
if !span.canAddErrorChain() {
99+
break
100+
}
98101

99102
e = c.Cause()
100103
if t := span.findError(e); t == nil {

0 commit comments

Comments
 (0)