From 6780703a64ecef59055ea405f8e019ad96bae853 Mon Sep 17 00:00:00 2001 From: rite7sh Date: Fri, 27 Feb 2026 05:05:07 +0530 Subject: [PATCH 1/3] ottl: improve Len() unsupported type error diagnostics --- pkg/ottl/ottlfuncs/func_len.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/ottl/ottlfuncs/func_len.go b/pkg/ottl/ottlfuncs/func_len.go index e9c7c912aebb0..fed1868d78b23 100644 --- a/pkg/ottl/ottlfuncs/func_len.go +++ b/pkg/ottl/ottlfuncs/func_len.go @@ -6,6 +6,7 @@ package ottlfuncs // import "github.com/open-telemetry/opentelemetry-collector-c import ( "context" "errors" + "fmt" "reflect" "go.opentelemetry.io/collector/pdata/pcommon" @@ -55,7 +56,7 @@ func computeLen[K any](target ottl.Getter[K]) ottl.ExprFunc[K] { case pcommon.ValueTypeMap: return int64(valType.Map().Len()), nil } - return nil, errors.New(typeError) + return nil, fmt.Errorf("Len: unsupported target type %T. %s", val, typeError) case pcommon.Map: return int64(valType.Len()), nil case pcommon.Slice: @@ -105,6 +106,6 @@ func computeLen[K any](target ottl.Getter[K]) ottl.ExprFunc[K] { return int64(v.Len()), nil } - return nil, errors.New(typeError) + return nil, fmt.Errorf("Len: unsupported target type %T. %s", val, typeError) } } From ff8fd728b7d94a01aa1ce746c3d7ac0b3cae7f8c Mon Sep 17 00:00:00 2001 From: rite7sh Date: Fri, 27 Feb 2026 05:15:58 +0530 Subject: [PATCH 2/3] chloggen: add Len() error diagnostics entry --- .chloggen/enhancement_len_error_diagnostics.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .chloggen/enhancement_len_error_diagnostics.yaml diff --git a/.chloggen/enhancement_len_error_diagnostics.yaml b/.chloggen/enhancement_len_error_diagnostics.yaml new file mode 100644 index 0000000000000..785d6a85b2c8d --- /dev/null +++ b/.chloggen/enhancement_len_error_diagnostics.yaml @@ -0,0 +1,9 @@ +change_type: enhancement + +component: ottl + +note: Improve unsupported type error diagnostics in the Len() OTTL function by including the runtime type in error messages. + +issues: [46476] + +change_logs: [user] \ No newline at end of file From bf39069af91f266fe98c1978215064b1feebdaa3 Mon Sep 17 00:00:00 2001 From: rite7sh Date: Fri, 27 Feb 2026 13:25:45 +0530 Subject: [PATCH 3/3] chloggen: fix Len() error diagnostics entry --- .chloggen/enhancement_len_error_diagnostics.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.chloggen/enhancement_len_error_diagnostics.yaml b/.chloggen/enhancement_len_error_diagnostics.yaml index 785d6a85b2c8d..029a29b254bac 100644 --- a/.chloggen/enhancement_len_error_diagnostics.yaml +++ b/.chloggen/enhancement_len_error_diagnostics.yaml @@ -1,9 +1,9 @@ -change_type: enhancement +change_type: "enhancement" -component: ottl +component: "pkg/ottl" -note: Improve unsupported type error diagnostics in the Len() OTTL function by including the runtime type in error messages. +note: "Improve unsupported type error diagnostics in the Len() OTTL function by including the runtime type in error messages." issues: [46476] -change_logs: [user] \ No newline at end of file +change_logs: ["user"] \ No newline at end of file