File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
extension/memorylimiterextension Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package memorylimiterextension // import "go.opentelemetry.io/collector/extensio
55
66import (
77 "context"
8+ "net/http"
89
910 "go.uber.org/zap"
1011
@@ -38,3 +39,13 @@ func (ml *memoryLimiterExtension) Shutdown(ctx context.Context) error {
3839func (ml * memoryLimiterExtension ) MustRefuse () bool {
3940 return ml .memLimiter .MustRefuse ()
4041}
42+
43+ func (ml * memoryLimiterExtension ) GetHTTPHandler (base http.Handler ) (http.Handler , error ) {
44+ return http .HandlerFunc (func (resp http.ResponseWriter , req * http.Request ) {
45+ if ml .MustRefuse () {
46+ http .Error (resp , http .StatusText (http .StatusTooManyRequests ), http .StatusTooManyRequests )
47+ return
48+ }
49+ base .ServeHTTP (resp , req )
50+ }), nil
51+ }
You can’t perform that action at this time.
0 commit comments