Module Opentelemetry_client.Http_config

include module type of Exporter_config
type protocol =
  1. | Http_protobuf
  2. | Http_json
type log_level = Opentelemetry.Self_debug.level option

None disables internal diagnostic logging; Some level enables it at that level and above. Maps to OTEL_LOG_LEVEL env var.

type rest

opaque type to force using make while allowing record updates

type t = {
  1. debug : bool;
    (*
    • deprecated

      Use log_level instead. Debug the client itself?

    *)
  2. log_level : log_level;
    (*

    Log level for internal diagnostics. Read from OTEL_LOG_LEVEL or falls back to OTEL_OCAML_DEBUG for compatibility.

    *)
  3. sdk_disabled : bool;
    (*

    If true, the SDK is completely disabled and no-ops. Read from OTEL_SDK_DISABLED. Default false.

    *)
  4. url_traces : string;
    (*

    Url to send traces/spans

    *)
  5. url_metrics : string;
    (*

    Url to send metrics

    *)
  6. url_logs : string;
    (*

    Url to send logs

    *)
  7. headers : (string * string) list;
    (*

    Global API headers sent to all endpoints. Default is none or "OTEL_EXPORTER_OTLP_HEADERS" if set. Signal-specific headers can override these.

    *)
  8. headers_traces : (string * string) list;
    (*

    Headers for traces endpoint. Merges OTEL_EXPORTER_OTLP_HEADERS with OTEL_EXPORTER_OTLP_TRACES_HEADERS (signal-specific takes precedence).

    *)
  9. headers_metrics : (string * string) list;
    (*

    Headers for metrics endpoint. Merges OTEL_EXPORTER_OTLP_HEADERS with OTEL_EXPORTER_OTLP_METRICS_HEADERS (signal-specific takes precedence).

    *)
  10. headers_logs : (string * string) list;
    (*

    Headers for logs endpoint. Merges OTEL_EXPORTER_OTLP_HEADERS with OTEL_EXPORTER_OTLP_LOGS_HEADERS (signal-specific takes precedence).

    *)
  11. protocol : protocol;
    (*

    Wire protocol to use. Read from OTEL_EXPORTER_OTLP_PROTOCOL. Default Http_protobuf.

    *)
  12. timeout_ms : int;
    (*

    General timeout in milliseconds for exporter operations. Read from OTEL_EXPORTER_OTLP_TIMEOUT. Default 10_000.

    *)
  13. timeout_traces_ms : int;
    (*

    Timeout for trace exports. Read from OTEL_EXPORTER_OTLP_TRACES_TIMEOUT, falls back to timeout_ms.

    *)
  14. timeout_metrics_ms : int;
    (*

    Timeout for metric exports. Read from OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, falls back to timeout_ms.

    *)
  15. timeout_logs_ms : int;
    (*

    Timeout for log exports. Read from OTEL_EXPORTER_OTLP_LOGS_TIMEOUT, falls back to timeout_ms.

    *)
  16. traces : Opentelemetry.Provider_config.t;
    (*

    Per-provider batching config for traces. Default: batch=400, timeout=2s. The batch size is read from OTEL_BSP_MAX_EXPORT_BATCH_SIZE if set.

    *)
  17. metrics : Opentelemetry.Provider_config.t;
    (*

    Per-provider batching config for metrics. Default: batch=200, timeout=2s. The batch size is read from OTEL_METRIC_EXPORT_INTERVAL if set.

    *)
  18. logs : Opentelemetry.Provider_config.t;
    (*

    Per-provider batching config for logs. Default: batch=400, timeout=2s.

    *)
  19. self_trace : bool;
    (*

    If true, the OTEL library will perform some self-instrumentation. Default false.

    • since 0.7
    *)
  20. self_metrics : bool;
    (*

    If true, the OTEL library will regularly emit metrics about itself. Default false.

    • since 0.90
    *)
  21. http_concurrency_level : int option;
    (*

    How many HTTP requests can be done simultaneously (at most)? This can be used to represent the size of a pool of workers where each worker gets a batch to send, send it, and repeats.

    • since 0.90
    *)
  22. retry_max_attempts : int;
    (*

    Maximum number of retry attempts for failed exports. 0 means no retry, 1 means one retry after initial failure. Default 3.

    *)
  23. retry_initial_delay_ms : float;
    (*

    Initial delay in milliseconds before first retry. Default 100ms.

    *)
  24. retry_max_delay_ms : float;
    (*

    Maximum delay in milliseconds between retries. Default 5000ms.

    *)
  25. retry_backoff_multiplier : float;
    (*

    Multiplier for exponential backoff. Default 2.0.

    *)
  26. _rest : rest;
}

Configuration.

To build one, use make below. This might be extended with more fields in the future.

val default_url : string

The default base URL for the config.

val pp : Stdlib.Format.formatter -> t -> unit
type 'k make = ?debug:bool -> ?log_level:log_level -> ?sdk_disabled:bool -> ?url:string -> ?url_traces:string -> ?url_metrics:string -> ?url_logs:string -> ?batch_traces:int -> ?batch_metrics:int -> ?batch_logs:int -> ?batch_timeout_ms:int -> ?traces:Opentelemetry.Provider_config.t -> ?metrics:Opentelemetry.Provider_config.t -> ?logs:Opentelemetry.Provider_config.t -> ?headers:(string * string) list -> ?headers_traces:(string * string) list -> ?headers_metrics:(string * string) list -> ?headers_logs:(string * string) list -> ?protocol:protocol -> ?timeout_ms:int -> ?timeout_traces_ms:int -> ?timeout_metrics_ms:int -> ?timeout_logs_ms:int -> ?self_trace:bool -> ?self_metrics:bool -> ?http_concurrency_level:int -> ?retry_max_attempts:int -> ?retry_initial_delay_ms:float -> ?retry_max_delay_ms:float -> ?retry_backoff_multiplier:float -> 'k

A function that gathers all the values needed to construct a t, and produces a 'k. 'k is typically a continuation used to construct a configuration that includes a t.

  • parameter url

    base url used to construct per-signal urls. Per-signal url options take precedence over this base url. If not provided, this defaults to "OTEL_EXPORTER_OTLP_ENDPOINT" if set, or if not default_url.

Example of constructed per-signal urls with the base url http://localhost:4318

  • Traces: http://localhost:4318/v1/traces
  • Metrics: http://localhost:4318/v1/metrics
  • Logs: http://localhost:4318/v1/logs

Use per-signal url options if different urls are needed for each signal type.

  • parameter url_traces

    url to send traces, or "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT" if set. The url is used as-is without any modification.

  • parameter url_metrics

    url to send metrics, or "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT" if set. The url is used as-is without any modification.

  • parameter url_logs

    url to send logs, or "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT" if set. The url is used as-is without any modification.

module type ENV = sig ... end

Construct, inspect, and update t configurations, drawing defaults from the environment

module Env () : ENV

A generative functor that produces a state-space that can read configuration values from the environment, provide stateful configuration setting and accessing operations, and a way to make a new t configuration record