Debian Codegraph @

extension/extensionmiddleware/README.md

raw
1 # OpenTelemetry Collector Middleware Extension API
2
3 This package implements interfaces for injecting middleware behavior
4 in OpenTelemetry Collector exporters and receivers. See the
5 [associated `configmiddleware` package](../../config/configmiddleware/README.md)
6 for referring to middleware
7 extensions in component configurations.
8
9 ## Overview
10
11 Middleware extensions can be configured on gRPC and HTTP connections,
12 on both the client and server side. The term "middleware" is defined
13 broadly to cover many ways of intercepting, acting on, and observing
14 requests as they enter and exit and RPC system.
15
16 Middleware details and capabilities are specific to each protocol. In
17 some cases, these interfaces permit configuring behavior other than
18 middleware. Users have to place a trust in the extensions they
19 configure, since they are capable of subverting security and other RPC
20 configuration.
21
22 Middleware is generally configured at a level in the code where:
23
24 1. the identity of the calling component is not known, because
25 `confighttp` and `configgrpc` interfaces likewise are not configured
26 with the identify of the calling component.
27 2. the signal type in use is not known, because a single connection
28 serves multiple signals.
29
30 ## Interfaces
31
32 Each interface has a single function to configure middleware for a
33 protocol on the client or server side. An error is returned if the
34 extension cannot be configured.
35
36 New protocols and new ways to configure middleware can be introduced
37 by adding new interfaces. Note that for each interface, there is a
38 corresponding method to locate a named middleware extension that
39 satisfies the interface in
40 [the `configmiddleware` package](../../config/configmiddleware/README.md) .
41
42 ### HTTP
43
44 Interface methods are called once per request to construct a client-
45 or server-side middleware object.
46
47 - **HTTPClient**: The extension returns a function to create new `http.RoundTripper`s.
48 - **HTTPServer**: The extension returns a function to create new `http.Handler`s.
49
50 ### GRPC
51
52 Interface methods are called once at setup to configure the client- or
53 server-side middleware object.
54
55 - **GRPCClient**: The extension returns `[]grpc.DialOption`.
56 - **GRPCServer**: The extension returns `[]grpc.ServerOption`.