You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/01/11 09:24:10 UTC

[GitHub] [servicecomb-service-center] tianxiaoliang commented on a change in pull request #617: add framework info in prometheus

tianxiaoliang commented on a change in pull request #617: add framework info in prometheus
URL: https://github.com/apache/servicecomb-service-center/pull/617#discussion_r365510541
 
 

 ##########
 File path: server/service/event/instance_event_handler.go
 ##########
 @@ -44,14 +44,26 @@ func (h *InstanceEventHandler) OnEvent(evt discovery.KvEvent) {
 	providerId, providerInstanceId, domainProject := apt.GetInfoFromInstKV(evt.KV.Key)
 	idx := strings.Index(domainProject, "/")
 	domainName := domainProject[:idx]
+	projectName := domainProject[idx+1:]
+
+	var add float64 = 1
 	switch action {
 	case pb.EVT_INIT:
-		metrics.ReportInstances(domainName, 1)
+		metrics.ReportInstances(domainName, add)
+		ms := serviceUtil.GetServiceFromCache(domainProject, providerId)
+		if ms == nil {
+			log.Warnf("caught [%s] instance[%s/%s] event, endpoints %v, get cached provider's file failed",
+				action, providerId, providerInstanceId, instance.Endpoints)
+			return
+		}
+		frameworkName, frameworkVersion := getFramework(ms)
+		metrics.ReportFramework(domainName, projectName, frameworkName, frameworkVersion, add)
 		return
 	case pb.EVT_CREATE:
-		metrics.ReportInstances(domainName, 1)
 
 Review comment:
   这个magic number搞成const

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services