Debian Codegraph @

config/configmiddleware/README.md

raw
1 # OpenTelemetry Collector Middleware Configuration
2
3 This package implements a configuration struct for referring to
4 [middleware extensions](../../extension/extensionmiddleware/README.md).
5
6 ## Overview
7
8 The `configmiddleware` package defines a `Config` type that
9 allows components to configure middleware extensions, typically as
10 an ordered list.
11 This support is built in for push-based receivers configured through
12 `confighttp` and `configgrpc`, as for example in the OTLP receiver:
13
14 ```yaml
15 receivers:
16 otlp:
17 protocols:
18 http:
19 middlewares:
20 - id: limitermiddleware
21 ```
22
23 ## Methods
24
25 The package provides four key methods to retrieve appropriate middleware handlers:
26
27 1. **GetHTTPClientRoundTripper**: Obtains a function to wrap an HTTP client with a middleware extension via a `http.RoundTripper`.
28
29 2. **GetHTTPServerHandler**: Obtains a function to wrap an HTTP server with a middleware extension via a `http.Handler`.
30
31 3. **GetGRPCClientOptions**: Obtains a `[]grpc.DialOption` that configure a middleware extension for gRPC clients.
32
33 4. **GetGRPCServerOptions**: Obtains a `[]grpc.ServerOption` that configure a middleware extension for gRPC servers.
34
35 These functions are typically called during Start() by a component,
36 passing the `component.Host` extensions.
37 An error is returned if the named extension cannot be found.