opentelemetry-collector/config/configmiddleware
Antoine Toulme eaa1a6e812
[chore] Prepare release v1.38.0/v0.132.0 (#13623)
I am opening this PR as a copy of #13620

---------

Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
2025-08-12 05:17:22 +00:00
..
Makefile Middleware: config struct (part 2/4) (#12844) 2025-04-17 17:51:13 +00:00
README.md Middleware: config struct (part 2/4) (#12844) 2025-04-17 17:51:13 +00:00
configmiddleware.go [chore] add checkapi to tools (#12954) 2025-05-05 15:52:16 +00:00
configmiddleware_test.go Middleware: config struct (part 2/4) (#12844) 2025-04-17 17:51:13 +00:00
go.mod [chore] Prepare release v1.38.0/v0.132.0 (#13623) 2025-08-12 05:17:22 +00:00
go.sum Update module google.golang.org/protobuf to v1.36.7 (#13604) 2025-08-11 01:38:42 +00:00

README.md

OpenTelemetry Collector Middleware Configuration

This package implements a configuration struct for referring to middleware extensions.

Overview

The configmiddleware package defines a Config type that allows components to configure middleware extensions, typically as an ordered list. This support is built in for push-based receivers configured through confighttp and configgrpc, as for example in the OTLP receiver:

receivers:
  otlp:
    protocols:
	  http:
	    middlewares:
		- id: limitermiddleware

Methods

The package provides four key methods to retrieve appropriate middleware handlers:

  1. GetHTTPClientRoundTripper: Obtains a function to wrap an HTTP client with a middleware extension via a http.RoundTripper.

  2. GetHTTPServerHandler: Obtains a function to wrap an HTTP server with a middleware extension via a http.Handler.

  3. GetGRPCClientOptions: Obtains a []grpc.DialOption that configure a middleware extension for gRPC clients.

  4. GetGRPCServerOptions: Obtains a []grpc.ServerOption that configure a middleware extension for gRPC servers.

These functions are typically called during Start() by a component, passing the component.Host extensions. An error is returned if the named extension cannot be found.