From 8e3fe4b46ddc5309a3ef1fd98ebdfd6768c60619 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 24 Feb 2026 07:14:26 -0800 Subject: [PATCH 1/2] [memorylimiter] Use ChainUnaryInterceptor instead of UnaryInterceptor Signed-off-by: Bogdan Drutu --- .chloggen/fix-memorylimiter.yaml | 25 +++++++++++++++++++ .chloggen/fix-memorylimiter_interceptor.yaml | 25 +++++++++++++++++++ .../memorylimiterextension/memorylimiter.go | 24 ++++++++++++------ 3 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 .chloggen/fix-memorylimiter.yaml create mode 100644 .chloggen/fix-memorylimiter_interceptor.yaml diff --git a/.chloggen/fix-memorylimiter.yaml b/.chloggen/fix-memorylimiter.yaml new file mode 100644 index 00000000000..948b36b91a8 --- /dev/null +++ b/.chloggen/fix-memorylimiter.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp) +component: extension/memorylimiter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Add support for streaming services. + +# One or more tracking issues or pull requests related to the change +issues: [14634] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/.chloggen/fix-memorylimiter_interceptor.yaml b/.chloggen/fix-memorylimiter_interceptor.yaml new file mode 100644 index 00000000000..7dec40d71bd --- /dev/null +++ b/.chloggen/fix-memorylimiter_interceptor.yaml @@ -0,0 +1,25 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: bug_fix + +# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp) +component: extension/memorylimiter + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Use ChainUnaryInterceptor instead of UnaryInterceptor to allow multiple interceptors. + +# One or more tracking issues or pull requests related to the change +issues: [14634] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: If multiple extensions that use the UnaryInterceptor are set the binary panics at start time. + +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/extension/memorylimiterextension/memorylimiter.go b/extension/memorylimiterextension/memorylimiter.go index b2a795fe392..319c2741d82 100644 --- a/extension/memorylimiterextension/memorylimiter.go +++ b/extension/memorylimiterextension/memorylimiter.go @@ -60,12 +60,20 @@ func (ml *memoryLimiterExtension) GetHTTPHandler(base http.Handler) (http.Handle } func (ml *memoryLimiterExtension) GetGRPCServerOptions() ([]grpc.ServerOption, error) { - return []grpc.ServerOption{grpc.UnaryInterceptor( - func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { - if ml.MustRefuse() { - return nil, status.Errorf(codes.ResourceExhausted, "RESOURCE_EXHAUSTED") - } - return handler(ctx, req) - }, - )}, nil + return []grpc.ServerOption{ + grpc.ChainUnaryInterceptor( + func(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) { + if ml.MustRefuse() { + return nil, status.Errorf(codes.ResourceExhausted, "RESOURCE_EXHAUSTED") + } + return handler(ctx, req) + }), + grpc.ChainStreamInterceptor( + func(srv any, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + if ml.MustRefuse() { + return status.Errorf(codes.ResourceExhausted, "RESOURCE_EXHAUSTED") + } + return handler(srv, ss) + }), + }, nil } From d40827c90afc07f706c2fed8186bb6136de8869f Mon Sep 17 00:00:00 2001 From: Evan Bradley <11745660+evan-bradley@users.noreply.github.com> Date: Tue, 24 Feb 2026 13:07:54 -0500 Subject: [PATCH 2/2] Apply suggestions from code review --- .chloggen/fix-memorylimiter.yaml | 2 +- .chloggen/fix-memorylimiter_interceptor.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.chloggen/fix-memorylimiter.yaml b/.chloggen/fix-memorylimiter.yaml index 948b36b91a8..a64c48e8563 100644 --- a/.chloggen/fix-memorylimiter.yaml +++ b/.chloggen/fix-memorylimiter.yaml @@ -4,7 +4,7 @@ change_type: bug_fix # The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp) -component: extension/memorylimiter +component: extension/memory_limiter # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). note: Add support for streaming services. diff --git a/.chloggen/fix-memorylimiter_interceptor.yaml b/.chloggen/fix-memorylimiter_interceptor.yaml index 7dec40d71bd..b8ab31138fe 100644 --- a/.chloggen/fix-memorylimiter_interceptor.yaml +++ b/.chloggen/fix-memorylimiter_interceptor.yaml @@ -4,7 +4,7 @@ change_type: bug_fix # The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp) -component: extension/memorylimiter +component: extension/memory_limiter # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). note: Use ChainUnaryInterceptor instead of UnaryInterceptor to allow multiple interceptors.