opentelemetry-collector/config/confighttp
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
..
internal [chore]: fix staticcheck exclusions (#12792) 2025-04-02 20:07:55 +00:00
testdata [configmiddleware] middleware->middlewares (#13525) 2025-07-30 18:32:28 +00:00
xconfighttp [chore] Prepare release v1.38.0/v0.132.0 (#13623) 2025-08-12 05:17:22 +00:00
Makefile split configgrpc, confighttp, and config/internal (#7921) 2023-06-17 12:07:13 -07:00
README.md [confighttp] - Expose an option to set ForceAttemptHttp2 setting (#13426) 2025-07-30 20:49:34 +00:00
client_middleware_test.go [chore]: enable-all rules from go-critic (#13433) 2025-07-24 10:34:03 +00:00
clientinfohandler.go [chore]: enable contextcheck linter (#13485) 2025-08-05 10:24:04 +00:00
clientinfohandler_test.go [chore] small test improvements (#11211) 2024-09-18 13:47:25 -07:00
compress_readcloser.go Improving memory performance when it comes to snappy (#11177) 2024-09-25 16:44:12 -07:00
compress_readcloser_test.go fix(deps): update module github.com/golangci/golangci-lint to v1.61.0 (#10935) 2024-10-12 16:13:55 -07:00
compression.go [confighttp] Reuse zstd reader objects (#13396) 2025-08-01 20:44:53 +00:00
compression_test.go [confighttp] Move `confighttp.framedSnappy` feature gate to beta. (#13491) 2025-07-28 15:40:26 +00:00
compressor.go Fix snappy/framed-snappy encoding/decoding (#12911) 2025-05-05 16:18:42 +00:00
compressor_test.go [chore]: use testify instead of testing.Fatal or testing.Error (#11896) 2024-12-16 23:15:33 +00:00
confighttp.go [chore][confighttp] Rename receiver variables (#13576) 2025-08-06 16:13:06 +00:00
confighttp_example_test.go [chore] cleanup confighttp tests (#11176) 2024-09-19 10:10:12 +02:00
confighttp_test.go [chore][confighttp] Rename receiver variables (#13576) 2025-08-06 16:13:06 +00:00
doc.go [chore][configgrpc,confighttp] Clarify that config structs are to be used for a single protocol and receiver (#12256) 2025-02-04 10:24:59 +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 All golang.org/x packages (#13605) 2025-08-11 06:20:39 +00:00
package_test.go [chore] remove unused opencensus code (#9108) 2024-01-30 10:19:42 -08:00
server_middleware_test.go [chore]: enable-all rules from go-critic (#13433) 2025-07-24 10:34:03 +00:00

README.md

HTTP Configuration Settings

HTTP exposes a variety of settings. Several of these settings are available for configuration within individual receivers or exporters.

Client Configuration

Exporters leverage client configuration.

Note that client configuration supports TLS configuration, the configuration parameters are also defined under tls like server configuration. For more information, see configtls README.

  • endpoint: address:port
  • tls
  • headers: name/value pairs added to the HTTP request headers
    • certain headers such as Content-Length and Connection are automatically written when needed and values in Header may be ignored.
    • 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.
    • if Host header is provided then it overrides Host field in Request which results as an override of Host header value.
  • read_buffer_size
  • timeout
  • write_buffer_size
  • compression: Compression type to use among gzip, zstd, snappy, zlib, deflate, and lz4.
    • look at the documentation for the server-side of the communication.
    • none will be treated as uncompressed, and any other inputs will cause an error.
  • compression_params : Configure advanced compression options
    • level: Configure compression level for compression type
    • The following are valid combinations of compression and level
      • gzip
        • BestSpeed: 1
        • BestCompression: 9
        • DefaultCompression: -1
      • zlib
        • BestSpeed: 1
        • BestCompression: 9
        • DefaultCompression: -1
      • deflate
        • BestSpeed: 1
        • BestCompression: 9
        • DefaultCompression: -1
      • zstd
        • SpeedFastest: 1
        • SpeedDefault: 3
        • SpeedBetterCompression: 6
        • SpeedBestCompression: 11
      • snappy No compression levels supported yet
      • x-snappy-framed (When feature gate confighttp.framedSnappy is enabled) No compression levels supported yet
  • max_idle_conns
  • max_idle_conns_per_host
  • max_conns_per_host
  • idle_conn_timeout
  • auth
  • disable_keep_alives
  • force_attempt_http2
  • http2_read_idle_timeout
  • http2_ping_timeout
  • cookies
    • [enabled] if enabled, the client will store cookies from server responses and reuse them in subsequent requests.
  • middlewares

Example:

exporter:
  otlphttp:
    endpoint: otelcol2:55690
    auth:
      authenticator: some-authenticator-extension
    tls:
      ca_file: ca.pem
      cert_file: cert.pem
      key_file: key.pem
    headers:
      test1: "value1"
      "test 2": "value 2"
    compression: gzip
    compression_params:
      level: 1
    cookies:
      enabled: true

Server Configuration

Receivers leverage server configuration.

  • cors: Configure CORS, allowing the receiver to accept traces from web browsers, even if the receiver is hosted at a different origin. If left blank or set to null, CORS will not be enabled.
    • allowed_origins: A list of origins allowed to send requests to the receiver. An origin may contain a wildcard (*) to replace 0 or more characters (e.g., https://*.example.com). Do not use a plain wildcard ["*"], 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.
    • allowed_headers: Allow CORS requests to include headers outside the default safelist. By default, safelist headers and X-Requested-With will be allowed. To allow any request header, set to ["*"].
    • max_age: Sets the value of the Access-Control-Max-Age header, allowing clients to cache the response to CORS preflight requests. If not set, browsers use a default of 5 seconds.
  • endpoint: Valid value syntax available here
  • max_request_body_size: configures the maximum allowed body size in bytes for a single request. Default: 20971520 (20MiB)
  • compression_algorithms: configures the list of compression algorithms the server can accept. Default: ["", "gzip", "zstd", "zlib", "snappy", "deflate", "lz4"]
    • x-snappy-framed can be used if feature gate confighttp.snappyFramed is enabled.
  • tls
  • auth
    • request_params: a list of query parameter names to add to the auth context, along with the HTTP headers
  • middlewares

You can enable attribute processor to append any http header to span's attribute using custom key. You also need to enable the "include_metadata"

Example:

receivers:
  otlp:
    protocols:
      http:
        include_metadata: true
        auth:
          request_params:
          - token
          authenticator: some-authenticator-extension
        cors:
          allowed_origins:
            - https://foo.bar.com
            - https://*.test.com
          allowed_headers:
            - Example-Header
          max_age: 7200
        endpoint: 0.0.0.0:55690
        compression_algorithms: ["", "gzip"]
processors:
  attributes:
    actions:
      - key: http.client_ip
        from_context: metadata.x-forwarded-for
        action: upsert