@@ -662,13 +662,38 @@ func (s *Agent) addBuiltins(nowUnix uint32) {
662662}
663663
664664func (s * Agent ) addBuiltInsHeartbeatsLocked (nowUnix uint32 , count float64 ) {
665- uptimeSec := float64 (nowUnix - s .startTimestamp )
666-
667- s .AddValueCounterString (nowUnix , & s .builtinMetricMetaHeartbeatVersion ,
668- []int32 {0 , s .componentTag , s .heartBeatEventType },
665+ var (
666+ owner string
667+ uptimeSec = float64 (nowUnix - s .startTimestamp )
668+ )
669+ if s .envLoader != nil {
670+ e := s .envLoader .Load ()
671+ owner = e .Owner
672+ }
673+ s .AddValueCounterStringV2 (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+ },
669684 build .Commit (), uptimeSec , count )
670- s .AddValueCounterString (nowUnix , & s .builtinMetricMetaHeartbeatArgs ,
671- []int32 {0 , s .componentTag , s .heartBeatEventType , s .argsHash , 0 , 0 , 0 , 0 , 0 , s .argsLen },
685+ s .AddValueCounterStringV2 (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+ },
672697 s .args , uptimeSec , count )
673698}
674699
@@ -945,6 +970,33 @@ func (s *Agent) AddValueCounterStringHostAERA(t uint32, metricInfo *format.Metri
945970 shard .AddValueCounterStringHost (& key , resolutionHash , topValue , value , counter , hostTag , metricInfo , weightMul )
946971}
947972
973+ func (s * Agent ) AddValueCounterStringV2 (t uint32 , metricInfo * format.MetricMetaValue , tags []int32 , stags []string , str string , value float64 , counter float64 ) {
974+ s .AddValueCounterStringV2HostAERA (t , metricInfo , tags , stags , data_model.TagUnion {S : str , I : 0 }, value , counter , data_model.TagUnionBytes {}, format.AgentEnvRouteArch {})
975+ }
976+
977+ func (s * Agent ) AddValueCounterStringV2HostAERA (t uint32 , metricInfo * format.MetricMetaValue , tags []int32 , stags []string , topValue data_model.TagUnion , value float64 , counter float64 , hostTag data_model.TagUnionBytes , aera format.AgentEnvRouteArch ) {
978+ if counter <= 0 {
979+ return
980+ }
981+ key := data_model.Key {Timestamp : t , Metric : metricInfo .MetricID } // panics if metricInfo nil
982+ copy (key .Tags [:], tags )
983+ copy (key .STags [:], stags )
984+ if metricInfo .WithAggregatorID {
985+ key .Tags [format .AggHostTag ] = s .AggregatorHost
986+ key .Tags [format .AggShardTag ] = s .AggregatorShardKey
987+ key .Tags [format .AggReplicaTag ] = s .AggregatorReplicaKey
988+ }
989+ if metricInfo .WithAgentEnvRouteArch {
990+ key .Tags [format .AgentEnvTag ] = aera .AgentEnv
991+ key .Tags [format .RouteTag ] = aera .Route
992+ key .Tags [format .BuildArchTag ] = aera .BuildArch
993+ }
994+ shardId , _ , weightMul , resolutionHash := s .shard (& key , metricInfo , nil )
995+ // resolutionHash will be 0 for built-in metrics, we are OK with this
996+ shard := s .Shards [shardId ]
997+ shard .AddValueCounterStringHost (& key , resolutionHash , topValue , value , counter , hostTag , metricInfo , weightMul )
998+ }
999+
9481000func (s * Agent ) MergeItemValue (t uint32 , metricInfo * format.MetricMetaValue , tags []int32 , item * data_model.ItemValue ) {
9491001 if item .Count () <= 0 {
9501002 return
0 commit comments