config/configmiddleware/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:
| 1 | receivers: |
| 2 | otlp: |
| 3 | protocols: |
| 4 | http: |
| 5 | middlewares: |
| 6 | - id: limitermiddleware |
Methods
The package provides four key methods to retrieve appropriate middleware handlers:
GetHTTPClientRoundTripper: Obtains a function to wrap an HTTP client with a middleware extension via a
http.RoundTripper.GetHTTPServerHandler: Obtains a function to wrap an HTTP server with a middleware extension via a
http.Handler.GetGRPCClientOptions: Obtains a
[]grpc.DialOptionthat configure a middleware extension for gRPC clients.GetGRPCServerOptions: Obtains a
[]grpc.ServerOptionthat configure a middleware extension for gRPC servers.GetDialer: Obtains a function that overrides the default network connection
DialContext.
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.