@@ -2,6 +2,7 @@ package pinpoint
22
33import (
44 "errors"
5+ "fmt"
56 "io"
67 "strconv"
78 "sync"
@@ -97,6 +98,7 @@ type exception struct {
9798const (
9899 cacheSize = 1024
99100 defaultQueueSize = 1024
101+ maxSqlSize = 64 * 1024
100102)
101103
102104var 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+
518527func (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
0 commit comments