| 1 |
# HTTP Configuration Settings |
| 2 |
|
| 3 |
HTTP exposes a [variety of settings](https://golang.org/pkg/net/http/). |
| 4 |
Several of these settings are available for configuration within individual |
| 5 |
receivers or exporters. |
| 6 |
|
| 7 |
## Client Configuration |
| 8 |
|
| 9 |
[Exporters](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/README.md) |
| 10 |
leverage client configuration. |
| 11 |
|
| 12 |
Note that client configuration supports TLS configuration, the |
| 13 |
configuration parameters are also defined under `tls` like server |
| 14 |
configuration. For more information, see [configtls |
| 15 |
README](../configtls/README.md). |
| 16 |
|
| 17 |
- `endpoint`: address:port |
| 18 |
- [`tls`](../configtls/README.md) |
| 19 |
- [`headers`](https://pkg.go.dev/net/http#Request): name/value pairs added to the HTTP request headers |
| 20 |
- certain headers such as Content-Length and Connection are automatically written when needed and values in Header may be ignored. |
| 21 |
- `Host` header is automatically derived from `endpoint` value. However, this automatic assignment can be overridden by explicitly setting the Host field in the headers field. |
| 22 |
- if `Host` header is provided then it overrides `Host` field in [Request](https://pkg.go.dev/net/http#Request) which results as an override of `Host` header value. |
| 23 |
- [`read_buffer_size`](https://golang.org/pkg/net/http/#Transport) |
| 24 |
- [`timeout`](https://golang.org/pkg/net/http/#Client) |
| 25 |
- [`write_buffer_size`](https://golang.org/pkg/net/http/#Transport) |
| 26 |
- `compression`: Compression type to use among `gzip`, `zstd`, `snappy`, `zlib`, `deflate`, and `lz4`. |
| 27 |
- look at the documentation for the server-side of the communication. |
| 28 |
- `none` will be treated as uncompressed, and any other inputs will cause an error. |
| 29 |
- `compression_params` : Configure advanced compression options |
| 30 |
- `level`: Configure compression level for `compression` type |
| 31 |
- The following are valid combinations of `compression` and `level` |
| 32 |
- `gzip` |
| 33 |
- BestSpeed: `1` |
| 34 |
- BestCompression: `9` |
| 35 |
- DefaultCompression: `-1` |
| 36 |
- `zlib` |
| 37 |
- BestSpeed: `1` |
| 38 |
- BestCompression: `9` |
| 39 |
- DefaultCompression: `-1` |
| 40 |
- `deflate` |
| 41 |
- BestSpeed: `1` |
| 42 |
- BestCompression: `9` |
| 43 |
- DefaultCompression: `-1` |
| 44 |
- `zstd` |
| 45 |
- SpeedFastest: `1` |
| 46 |
- SpeedDefault: `3` |
| 47 |
- SpeedBetterCompression: `6` |
| 48 |
- SpeedBestCompression: `11` |
| 49 |
- `snappy` |
| 50 |
No compression levels supported yet |
| 51 |
- `x-snappy-framed` (When feature gate `confighttp.framedSnappy` is enabled) |
| 52 |
No compression levels supported yet |
| 53 |
- [`max_idle_conns`](https://golang.org/pkg/net/http/#Transport) |
| 54 |
- [`max_idle_conns_per_host`](https://golang.org/pkg/net/http/#Transport) |
| 55 |
- [`max_conns_per_host`](https://golang.org/pkg/net/http/#Transport) |
| 56 |
- [`idle_conn_timeout`](https://golang.org/pkg/net/http/#Transport) |
| 57 |
- [`auth`](../configauth/README.md) |
| 58 |
- [`disable_keep_alives`](https://golang.org/pkg/net/http/#Transport) |
| 59 |
- [`force_attempt_http2`](https://golang.org/pkg/net/http/#Transport) |
| 60 |
- [`http2_read_idle_timeout`](https://pkg.go.dev/golang.org/x/net/http2#Transport) |
| 61 |
- [`http2_ping_timeout`](https://pkg.go.dev/golang.org/x/net/http2#Transport) |
| 62 |
- [`cookies`](https://pkg.go.dev/net/http#CookieJar) |
| 63 |
- [`enabled`] if enabled, the client will store cookies from server responses and reuse them in subsequent requests. |
| 64 |
- [`middlewares`](../configmiddleware/README.md) |
| 65 |
|
| 66 |
Example: |
| 67 |
|
| 68 |
```yaml |
| 69 |
exporter: |
| 70 |
otlphttp: |
| 71 |
endpoint: otelcol2:55690 |
| 72 |
auth: |
| 73 |
authenticator: some-authenticator-extension |
| 74 |
tls: |
| 75 |
ca_file: ca.pem |
| 76 |
cert_file: cert.pem |
| 77 |
key_file: key.pem |
| 78 |
headers: |
| 79 |
test1: "value1" |
| 80 |
"test 2": "value 2" |
| 81 |
compression: gzip |
| 82 |
compression_params: |
| 83 |
level: 1 |
| 84 |
cookies: |
| 85 |
enabled: true |
| 86 |
``` |
| 87 |
|
| 88 |
## Server Configuration |
| 89 |
|
| 90 |
[Receivers](https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/README.md) |
| 91 |
leverage server configuration. |
| 92 |
|
| 93 |
- [`cors`](https://github.com/rs/cors#parameters): Configure [CORS][cors], |
| 94 |
allowing the receiver to accept traces from web browsers, even if the receiver |
| 95 |
is hosted at a different [origin][origin]. If left blank or set to `null`, CORS |
| 96 |
will not be enabled. |
| 97 |
- `allowed_origins`: A list of [origins][origin] allowed to send requests to |
| 98 |
the receiver. An origin may contain a wildcard (`*`) to replace 0 or more |
| 99 |
characters (e.g., `https://*.example.com`). **Do not use** a plain wildcard |
| 100 |
`["*"]`, as our CORS response includes `Access-Control-Allow-Credentials: true`, which makes browsers to **disallow a plain wildcard** (this is a security standard). To allow any origin, you can specify at least the protocol, for example `["https://*", "http://*"]`. If no origins are listed, CORS will not be enabled. |
| 101 |
- `allowed_headers`: Allow CORS requests to include headers outside the |
| 102 |
[default safelist][cors-headers]. By default, safelist headers and |
| 103 |
`X-Requested-With` will be allowed. To allow any request header, set to |
| 104 |
`["*"]`. |
| 105 |
- `max_age`: Sets the value of the [`Access-Control-Max-Age`][cors-cache] |
| 106 |
header, allowing clients to cache the response to CORS preflight requests. If |
| 107 |
not set, browsers use a default of 5 seconds. |
| 108 |
- `endpoint`: Valid value syntax available [here](https://github.com/grpc/grpc/blob/master/doc/naming.md) |
| 109 |
- `max_request_body_size`: configures the maximum allowed body size in bytes for a single request. Default: `20971520` (20MiB) |
| 110 |
- `compression_algorithms`: configures the list of compression algorithms the server can accept. Default: ["", "gzip", "zstd", "zlib", "snappy", "deflate", "lz4"] |
| 111 |
- `x-snappy-framed` can be used if feature gate `confighttp.snappyFramed` is enabled. |
| 112 |
- [`tls`](../configtls/README.md) |
| 113 |
- [`auth`](../configauth/README.md) |
| 114 |
- `request_params`: a list of query parameter names to add to the auth context, along with the HTTP headers |
| 115 |
- [`middlewares`](../configmiddleware/README.md) |
| 116 |
|
| 117 |
You can enable [`attribute processor`][attribute-processor] to append any http header to span's attribute using custom key. You also need to enable the "include_metadata" |
| 118 |
|
| 119 |
Example: |
| 120 |
|
| 121 |
```yaml |
| 122 |
receivers: |
| 123 |
otlp: |
| 124 |
protocols: |
| 125 |
http: |
| 126 |
include_metadata: true |
| 127 |
auth: |
| 128 |
request_params: |
| 129 |
- token |
| 130 |
authenticator: some-authenticator-extension |
| 131 |
cors: |
| 132 |
allowed_origins: |
| 133 |
- https://foo.bar.com |
| 134 |
- https://*.test.com |
| 135 |
allowed_headers: |
| 136 |
- Example-Header |
| 137 |
max_age: 7200 |
| 138 |
endpoint: 0.0.0.0:55690 |
| 139 |
compression_algorithms: ["", "gzip"] |
| 140 |
processors: |
| 141 |
attributes: |
| 142 |
actions: |
| 143 |
- key: http.client_ip |
| 144 |
from_context: metadata.x-forwarded-for |
| 145 |
action: upsert |
| 146 |
``` |
| 147 |
|
| 148 |
[cors]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS |
| 149 |
[cors-headers]: https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header |
| 150 |
[cors-cache]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age |
| 151 |
[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin |
| 152 |
[attribute-processor]: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/attributesprocessor/README.md |