From 63fa678ab8cf038cfc557fd2b7ead434f3b636f8 Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Tue, 23 Jan 2024 08:15:57 -0700 Subject: [PATCH] review comments --- plugins/inputs/gnmi/handler.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/inputs/gnmi/handler.go b/plugins/inputs/gnmi/handler.go index 0533ef0174dd3..be2140f3cecd3 100644 --- a/plugins/inputs/gnmi/handler.go +++ b/plugins/inputs/gnmi/handler.go @@ -240,10 +240,11 @@ func (h *handler) handleSubscribeResponseUpdate(acc telegraf.Accumulator, respon key = parts[1] } } else { - // If the origis are the same and the alias is shorter than the - // full path to avoid an empty key, then strip the common part if - // the field is prefixed with the alias path. - if aliasInfo.origin == field.path.origin && aliasInfo.isSubPathOf(field.path) && len(aliasInfo.segments) < len(field.path.segments) { + // If the alias is a subpath of the field path and the alias is + // shorter than the full path to avoid an empty key, then strip the + // common part of the field is prefixed with the alias path. Note + // the origins can match or be empty and be considered equal. + if aliasInfo.isSubPathOf(field.path) && len(aliasInfo.segments) < len(field.path.segments) { relative := field.path.segments[len(aliasInfo.segments):len(field.path.segments)] key = strings.Join(relative, "/") } else {