Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 新增上报 client metrics 数据 #2863

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

Ambition9186
Copy link
Contributor

  1. 客户端上报连接、心跳、变更、拉取事件到 feed-server
  2. cache-service 定时同步 client metrics 数据到 data-service
  3. data-service 定时更新客户端离线状态

@Ambition9186 Ambition9186 reopened this Dec 25, 2023
@Ambition9186 Ambition9186 force-pushed the client_metric branch 5 times, most recently from c609957 to f07b478 Compare December 26, 2023 09:00
@Ambition9186 Ambition9186 force-pushed the client_metric branch 6 times, most recently from 4f1ea16 to 36d1946 Compare January 8, 2024 07:44
@Ambition9186 Ambition9186 force-pushed the client_metric branch 2 times, most recently from a098109 to 78ff81e Compare January 17, 2024 10:52
@Ambition9186 Ambition9186 force-pushed the client_metric branch 3 times, most recently from e953dec to 31e27fc Compare January 31, 2024 03:07
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件在项目中已存在:
pkg/thirdparty/protobuf/google/protobuf/timestamp.proto

return values, nil
}

// RPop 移出并获取列表的第一个元素
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前面 LPush 是插入到头部,那这里就应该是从尾部移出并获取一个元素

logs.Infof("start handle client metric data")

if !cm.state.IsMaster() {
logs.V(2).Infof("this is slave, do not need to purge, skip. rid: %s", kt.Rid)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个日志不对

return jsoni.Marshal(v)
}

// Decode the VersionChangePayload to bytes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Decode the VersionChangePayload from bytes.

return jsoni.Marshal(p)
}

// Decode the PullStatusPayload to bytes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Decode the PullStatusPayload from bytes.

@@ -196,6 +197,99 @@ func (s *Service) Messaging(ctx context.Context, msg *pbfs.MessagingMeta) (*pbfs
return nil, status.Errorf(codes.PermissionDenied, "no permission to access bscp server")
}

vc := new(sfs.VersionChangePayload)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这几个变量都只是在对应的 case 中才被引用,不需要提前声明,在对应的 case 中声明就行了

// ClientMetric xxx
type ClientMetric struct {
mc *metric
client gcache.Cache
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcache 是一个内存缓存库,这里客户端数据不需要在 feed_server 内存缓存,它不会被客户端读取,只用往 cache-service 写入就行了。

所以这里去掉这个 client

}

// VersionChangePayload defines sdk version change to send payload to feed server.
type VersionChangePayload struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image image image image

这几个 Payload 结构都是一样或者相近的,看到这几个 payload 在 bscp-go 上报的时机也都差不多,可不可以合成一个上报呢

}

// ListClientByTuple Query the client list according to multiple fields in
func (dao *clientDao) ListClientByTuple(kit *kit.Kit, data [][]interface{}) ([]*table.Client, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个注释给全一点,不然传入一个二维 interface{} 数组作为入参有点迷惑

}

// Run the sync client online state task
func (c *ClientOnlineState) Run() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数也需要支持主从,只有主服务负责定时同步客户端状态

@Ambition9186 Ambition9186 force-pushed the client_metric branch 2 times, most recently from dcd7ad3 to 9793f68 Compare February 23, 2024 02:42
2. 新增客户端上报连接、心跳、变更、拉取事件到feed-server
3. 新增cache-service定时同步客户端metrics数据到data-service
4. 新增data-service定时更新客户端离线状态
5. 新增客户端类型字段
@AlkaidChan AlkaidChan merged commit 905ae27 into TencentBlueKing:master Mar 4, 2024
10 of 11 checks passed
wenxinlee2015 added a commit that referenced this pull request Mar 5, 2024
* github-bk-bcs/master:
  集群apiserver证书支持直接配置IP和域名 (#3002)
  1. 新增客户端metrics (#2863)
@Ambition9186 Ambition9186 deleted the client_metric branch June 3, 2024 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants