Package org.microproxy.otel
Class Telemetry.Builder
java.lang.Object
org.microproxy.otel.Telemetry.Builder
- Enclosing class:
Telemetry
Configures a
Telemetry; every setting has OpenTelemetry's default.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Returns the telemetry; its exporters' threads start now.compression(boolean gzip) Gzips the exports (OTEL_EXPORTER_OTLP_COMPRESSION=gzip).enabled(boolean enabled) Turns everything on (the default) or off; off,Telemetry.install(org.microproxy.HttpProxyServerBootstrap)changes nothing.The collector's OTLP/HTTP base URL; each signal goes to<endpoint>/v1/<signal>.forceTraceHeader(String header) Samples every request that hasheader, whatever the sampler says (Envoy'sx-envoy-force-trace); none by default.Adds a header to every export, such asauthorization.logFormat(AccessLogFormat format) The body of exported log records: an access-log format; Envoy's default by default.The log record queue (OTEL_BLRP_*): 2048, 512 and 1 s by default.logs(boolean on) Whether access-log records are exported as log records (OTEL_LOGS_EXPORTER).logsEndpoint(String url) The URL log records go to, as it is.metricInterval(Duration interval) How often metrics are exported (OTEL_METRIC_EXPORT_INTERVAL, 60 s).metricPrefix(String prefix) The prefix of exported metric names; the registry's (envoy) by default.metrics(boolean on) Whether the proxy's stats are exported as metrics (OTEL_METRICS_EXPORTER).metricsEndpoint(String url) The URL metrics go to, as it is.propagators(List<Propagator> propagators) The propagators, as OpenTelemetry's composite propagator: they extract in order, so the last that finds a valid context in a request gives the parent, and all write the proxy's context upstream; W3C Trace Context by default.protocol(Telemetry.Protocol protocol) How OTLP is sent: protobuf (the default) or JSON.What happens toX-Request-Id: kept, or made when missing (the default), always made, or left alone.resourceAttribute(String key, String value) A resource attribute (OTEL_RESOURCE_ATTRIBUTES), besidesservice.*,host.name,process.*andtelemetry.sdk.*, which it may override.How failed exports are retried: attempts in all (5 by default), and the backoff between them, growing by half each time frominitial(1 s) up tomax(5 s), with jitter, and never shorter than aRetry-After.The sampler;parentbased_always_onby default.serviceName(String name) service.name(OTEL_SERVICE_NAME);microproxyby default.spanLimits(SpanLimits limits) The span limits.The span queue (OTEL_BSP_*): its size (2048), the largest batch (512) and how long a span waits for its batch to fill (5 s).How long one export attempt may take, connecting included (10 seconds by default).traces(boolean on) Whether spans are exported (OTEL_TRACES_EXPORTER); without them the proxy still propagates.tracesEndpoint(String url) The URL spans go to, as it is (OTEL_EXPORTER_OTLP_TRACES_ENDPOINT).trustIncoming(boolean trust) Whether to continue the traces clients send (the default), or start a new trace for every request, as a trust boundary.What goes upstream when the proxy strips tracing headers: the proxy's own context (the default) or nothing.
-
Method Details
-
enabled
Turns everything on (the default) or off; off,Telemetry.install(org.microproxy.HttpProxyServerBootstrap)changes nothing.- Parameters:
enabled- whether to trace and export- Returns:
- this builder
-
endpoint
The collector's OTLP/HTTP base URL; each signal goes to<endpoint>/v1/<signal>.- Parameters:
endpoint- such ashttp://otel-collector:4318- Returns:
- this builder
-
tracesEndpoint
The URL spans go to, as it is (OTEL_EXPORTER_OTLP_TRACES_ENDPOINT).- Parameters:
url- the full URL, such ashttp://collector:4318/v1/traces- Returns:
- this builder
-
metricsEndpoint
The URL metrics go to, as it is.- Parameters:
url- the full URL- Returns:
- this builder
-
logsEndpoint
The URL log records go to, as it is.- Parameters:
url- the full URL- Returns:
- this builder
-
protocol
How OTLP is sent: protobuf (the default) or JSON.- Parameters:
protocol- the protocol- Returns:
- this builder
-
header
Adds a header to every export, such asauthorization.- Parameters:
name- the header's namevalue- its value- Returns:
- this builder
-
compression
Gzips the exports (OTEL_EXPORTER_OTLP_COMPRESSION=gzip).- Parameters:
gzip- whether to compress- Returns:
- this builder
-
timeout
How long one export attempt may take, connecting included (10 seconds by default).- Parameters:
timeout- the timeout- Returns:
- this builder
-
retry
How failed exports are retried: attempts in all (5 by default), and the backoff between them, growing by half each time frominitial(1 s) up tomax(5 s), with jitter, and never shorter than aRetry-After.- Parameters:
maxAttempts- the attempts per batch, at least 1initial- the first waitmax- the longest wait- Returns:
- this builder
-
serviceName
service.name(OTEL_SERVICE_NAME);microproxyby default.- Parameters:
name- the service's name- Returns:
- this builder
-
resourceAttribute
A resource attribute (OTEL_RESOURCE_ATTRIBUTES), besidesservice.*,host.name,process.*andtelemetry.sdk.*, which it may override.- Parameters:
key- the attributevalue- its value- Returns:
- this builder
-
sampler
The sampler;parentbased_always_onby default.- Parameters:
sampler- the sampler- Returns:
- this builder
-
forceTraceHeader
Samples every request that hasheader, whatever the sampler says (Envoy'sx-envoy-force-trace); none by default.- Parameters:
header- the header's name, ornullfor none- Returns:
- this builder
-
propagators
The propagators, as OpenTelemetry's composite propagator: they extract in order, so the last that finds a valid context in a request gives the parent, and all write the proxy's context upstream; W3C Trace Context by default.- Parameters:
propagators- the propagators, possibly none- Returns:
- this builder
-
trustIncoming
Whether to continue the traces clients send (the default), or start a new trace for every request, as a trust boundary.- Parameters:
trust- whether to read the clients' trace context- Returns:
- this builder
-
whenStripped
What goes upstream when the proxy strips tracing headers: the proxy's own context (the default) or nothing.- Parameters:
mode- the mode- Returns:
- this builder
-
requestId
What happens toX-Request-Id: kept, or made when missing (the default), always made, or left alone.- Parameters:
mode- the mode- Returns:
- this builder
-
traces
Whether spans are exported (OTEL_TRACES_EXPORTER); without them the proxy still propagates.- Parameters:
on- whether to export spans- Returns:
- this builder
-
metrics
Whether the proxy's stats are exported as metrics (OTEL_METRICS_EXPORTER).- Parameters:
on- whether to export metrics- Returns:
- this builder
-
logs
Whether access-log records are exported as log records (OTEL_LOGS_EXPORTER).- Parameters:
on- whether to export logs- Returns:
- this builder
-
metricInterval
How often metrics are exported (OTEL_METRIC_EXPORT_INTERVAL, 60 s).- Parameters:
interval- the interval- Returns:
- this builder
-
metricPrefix
The prefix of exported metric names; the registry's (envoy) by default.- Parameters:
prefix- the prefix, or an empty string for none- Returns:
- this builder
-
spanQueue
The span queue (OTEL_BSP_*): its size (2048), the largest batch (512) and how long a span waits for its batch to fill (5 s).- Parameters:
maxQueue- spans waiting at most; more are droppedmaxBatch- spans per export at mostdelay- the wait- Returns:
- this builder
-
logQueue
The log record queue (OTEL_BLRP_*): 2048, 512 and 1 s by default.- Parameters:
maxQueue- log records waiting at most; more are droppedmaxBatch- log records per export at mostdelay- the wait- Returns:
- this builder
-
spanLimits
The span limits.- Parameters:
limits- the limits- Returns:
- this builder
-
logFormat
The body of exported log records: an access-log format; Envoy's default by default.- Parameters:
format- the format- Returns:
- this builder
-
build
Returns the telemetry; its exporters' threads start now.- Returns:
- the telemetry; its exporters' threads start now
-