@@ -662,39 +662,52 @@ func (s *Agent) addBuiltins(nowUnix uint32) {
662662}
663663
664664func (s * Agent ) addBuiltInsHeartbeatsLocked (nowUnix uint32 , count float64 ) {
665- var (
666- owner string
667- uptimeSec = float64 (nowUnix - s .startTimestamp )
668- )
665+ if count <= 0 {
666+ return
667+ }
668+
669+ owner := ""
669670 if s .envLoader != nil {
670671 e := s .envLoader .Load ()
671672 owner = e .Owner
672673 }
673- s .AddValueCounterStringHostAERAExt (nowUnix , & s .builtinMetricMetaHeartbeatVersion ,
674- []int32 {
675- 1 : s .componentTag ,
676- 2 : s .heartBeatEventType ,
677- 4 : int32 (build .CommitTag ()),
678- 6 : int32 (build .CommitTimestamp ()),
679- },
680- []string {
681- 7 : string (s .hostName ),
682- 9 : owner ,
683- },
684- data_model.TagUnion {S : build .Commit ()}, uptimeSec , count , data_model.TagUnionBytes {}, format.AgentEnvRouteArch {})
685- s .AddValueCounterStringHostAERAExt (nowUnix , & s .builtinMetricMetaHeartbeatArgs ,
686- []int32 {
687- 1 : s .componentTag ,
688- 2 : s .heartBeatEventType ,
689- 3 : s .argsHash ,
690- 4 : int32 (build .CommitTag ()),
691- 6 : int32 (build .CommitTimestamp ()),
692- },
693- []string {
694- 7 : string (s .hostName ),
695- 9 : owner ,
696- },
697- data_model.TagUnion {S : s .args }, uptimeSec , count , data_model.TagUnionBytes {}, format.AgentEnvRouteArch {})
674+ uptimeSec := float64 (nowUnix - s .startTimestamp )
675+
676+ tags := [48 ]int32 {
677+ 1 : s .componentTag ,
678+ 2 : s .heartBeatEventType ,
679+ 4 : int32 (build .CommitTag ()),
680+ 6 : int32 (build .CommitTimestamp ()),
681+ format .AggHostTag : s .AggregatorHost ,
682+ format .AggShardTag : s .AggregatorShardKey ,
683+ format .AggReplicaTag : s .AggregatorReplicaKey ,
684+ }
685+ sTags := [48 ]string {
686+ 7 : string (s .hostName ),
687+ 9 : owner ,
688+ }
689+
690+ vKey := data_model.Key {
691+ Timestamp : nowUnix ,
692+ Metric : s .builtinMetricMetaHeartbeatVersion .MetricID , // panics if metricInfo nil
693+ Tags : tags ,
694+ STags : sTags ,
695+ }
696+ vShardId , _ , vWeightMul , vResolutionHash := s .shard (& vKey , & s .builtinMetricMetaHeartbeatVersion , nil )
697+ // resolutionHash will be 0 for built-in metrics, we are OK with this
698+ vShard := s .Shards [vShardId ]
699+ vShard .AddValueCounterStringHost (& vKey , vResolutionHash , data_model.TagUnion {S : build .Commit ()}, uptimeSec , count , data_model.TagUnionBytes {}, & s .builtinMetricMetaHeartbeatVersion , vWeightMul )
700+
701+ aKey := data_model.Key {
702+ Timestamp : nowUnix ,
703+ Metric : s .builtinMetricMetaHeartbeatArgs .MetricID , // panics if metricInfo nil
704+ Tags : tags ,
705+ STags : sTags ,
706+ }
707+ aShardId , _ , aWeightMul , aResolutionHash := s .shard (& aKey , & s .builtinMetricMetaHeartbeatArgs , nil )
708+ // resolutionHash will be 0 for built-in metrics, we are OK with this
709+ aShard := s .Shards [aShardId ]
710+ aShard .AddValueCounterStringHost (& aKey , aResolutionHash , data_model.TagUnion {S : s .args }, uptimeSec , count , data_model.TagUnionBytes {}, & s .builtinMetricMetaHeartbeatArgs , aWeightMul )
698711}
699712
700713func (s * Agent ) goFlushIteration (now time.Time ) {
@@ -970,29 +983,6 @@ func (s *Agent) AddValueCounterStringHostAERA(t uint32, metricInfo *format.Metri
970983 shard .AddValueCounterStringHost (& key , resolutionHash , topValue , value , counter , hostTag , metricInfo , weightMul )
971984}
972985
973- func (s * Agent ) AddValueCounterStringHostAERAExt (t uint32 , metricInfo * format.MetricMetaValue , tags []int32 , stags []string , topValue data_model.TagUnion , value float64 , counter float64 , hostTag data_model.TagUnionBytes , aera format.AgentEnvRouteArch ) {
974- if counter <= 0 {
975- return
976- }
977- key := data_model.Key {Timestamp : t , Metric : metricInfo .MetricID } // panics if metricInfo nil
978- copy (key .Tags [:], tags )
979- copy (key .STags [:], stags )
980- if metricInfo .WithAggregatorID {
981- key .Tags [format .AggHostTag ] = s .AggregatorHost
982- key .Tags [format .AggShardTag ] = s .AggregatorShardKey
983- key .Tags [format .AggReplicaTag ] = s .AggregatorReplicaKey
984- }
985- if metricInfo .WithAgentEnvRouteArch {
986- key .Tags [format .AgentEnvTag ] = aera .AgentEnv
987- key .Tags [format .RouteTag ] = aera .Route
988- key .Tags [format .BuildArchTag ] = aera .BuildArch
989- }
990- shardId , _ , weightMul , resolutionHash := s .shard (& key , metricInfo , nil )
991- // resolutionHash will be 0 for built-in metrics, we are OK with this
992- shard := s .Shards [shardId ]
993- shard .AddValueCounterStringHost (& key , resolutionHash , topValue , value , counter , hostTag , metricInfo , weightMul )
994- }
995-
996986func (s * Agent ) MergeItemValue (t uint32 , metricInfo * format.MetricMetaValue , tags []int32 , item * data_model.ItemValue ) {
997987 if item .Count () <= 0 {
998988 return
0 commit comments