Alanxtl commented on code in PR #3685:
URL: https://github.com/apache/dubbo-go/pull/3685#discussion_r3818849769
##########
registry/servicediscovery/service_instances_changed_listener_impl.go:
##########
@@ -277,8 +281,23 @@ func GetMetadataInfo(app string, instance
registry.ServiceInstance, revision str
initCache(app)
})
cacheKey := metadataCacheKey(app, registryId, revision)
- if metadataInfo, ok := metaCache.Get(cacheKey); ok {
- return metadataInfo.(*info.MetadataInfo), nil
+ if cached, ok := metaCache.Get(cacheKey); ok {
+ logger.Debugf("[Metadata][Cache] hit app=%s registry=%s
revision=%s host=%s",
+ app, registryId, revision, instance.GetHost())
+ event :=
metricsMetadata.NewMetadataMetricTimeEvent(metricsMetadata.MetadataCache)
+ event.Succ = true
+ event.Attachment[metricsMetadata.TagProviderApp] = app
+ metrics.Publish(event)
+ metadataInfo := cached.(*info.MetadataInfo)
+ if metadataInfo == nil {
+ publishMetadataFetchEvent(app, registryId, revision,
instance.GetHost(),
+ metricsMetadata.SourceCache,
metricsMetadata.StorageTypeCache, metricsMetadata.ResultFailure,
+ perrors.New("typed nil metadata in cache"))
+ return nil, nil
+ }
+ publishMetadataFetchEvent(app, registryId, revision,
instance.GetHost(),
+ metricsMetadata.SourceCache,
metricsMetadata.StorageTypeCache, metricsMetadata.ResultSuccess, nil)
+ return metadataInfo, nil
Review Comment:
`OnEvent` 会先读取 `lstn.revisionToMetadata`。同一 revision 的后续实例命中这个 map 后,不会调用
`GetMetadataInfo`,因此不会上报 `MetadataCache`
hit。多实例场景下,`dubbo_metadata_cache_hit_total / total`
会明显低估真实命中率。建议在这层缓存也埋点,或明确该指标只代表 `metaCache`(磁盘/LRU)缓存。
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]