OpenTelemetry
imgproxy can send request traces to an OpenTelemetry collector. To use this feature, do the following:
-
Install & configure the OpenTelemetry collector.
-
Set the
IMGPROXY_OPEN_TELEMETRY_ENABLE
environment variable totrue
to enable sending request traces to the collector. Default:false
. -
(optional) Set the
IMGPROXY_OPEN_TELEMETRY_ENABLE_METRICS
environment variable totrue
to enable sending metrics to the collector. Default:false
. -
(optional) Specify the collector protocol with
OTEL_EXPORTER_OTLP_PROTOCOL
environment variable.tipYou can specify different protocols for traces and metrics by using the
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL
andOTEL_EXPORTER_OTLP_METRICS_PROTOCOL
environment variables.Supported protocols are:
grpc
(default)http/protobuf
(aliases:http
,https
)
-
(optional) Specify the collector endpoint with
OTEL_EXPORTER_OTLP_ENDPOINT
environment variable.tipUse
https://
scheme for secure connections (you may need to configure TLS certificates) andhttp://
for insecure connections.infoThe
OTEL_EXPORTER_OTLP_ENDPOINT
path should not contain signal-specific paths like/v1/traces
or/v1/metrics
. The signal-specific paths are added automatically.tipYou can specify different endpoints for traces and metrics by using the
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
andOTEL_EXPORTER_OTLP_METRICS_ENDPOINT
environment variables. If thehttp/protobuf
protocol is used, these signal-specific endpoints should include the signal-specific paths like/v1/traces
or/v1/metrics
.Defaults are:
- For the
grpc
protocol:https://localhost:4317
- For the
http/protobuf
protocol:https://localhost:4318
- For the
-
(optional) Set the
OTEL_SERVICE_NAME
environment variable to be the desired service name. Default:imgproxy
. -
(optional) Set up TLS certificates.
-
(optional) Set the
IMGPROXY_OPEN_TELEMETRY_TRACE_ID_GENERATOR
environment variable to be the desired trace ID generator. Supported values are:xray
: (default) Amazon X-Ray compatible trace ID generatorrandom
: random trace ID generator
-
(optional) Use OpenTelemetry configuration environment variables to further customize the behavior.
imgproxy will send the following info to the collector:
- Response time
- Queue time
- Image downloading time
- Image processing time
- Errors that occurred while downloading and processing an image
If IMGPROXY_OPEN_TELEMETRY_ENABLE_METRICS
is set to true
, imgproxy will also send the following metrics to the collector:
requests_in_progress
: the number of requests currently in progressimages_in_progress
: the number of images currently in progressbuffer_size_bytes
: a histogram of buffer sizes (in bytes)buffer_default_size_bytes
: calibrated default buffer size (in bytes)buffer_max_size_bytes
: calibrated maximum buffer size (in bytes)vips_memory_bytes
: libvips memory usagevips_max_memory_bytes
: libvips maximum memory usagevips_allocs
: the number of active vips allocations- Some useful Go metrics like memstats and goroutines count
Configuration
imgproxy supports the standard general and OTLP exporter-specific environment variables with the following specifics:
http/json
protocol` is not supported.OTEL_TRACES_EXPORTER
andOTEL_METRICS_EXPORTER
environment variables are ignored as imgproxy always uses the OTLP exporter.- Logs-related environment variables are ignored as imgproxy does not support sending logs to OpenTelemetry.
Also, imgproxy supports the following environment variables:
IMGPROXY_OPEN_TELEMETRY_TRACE_ID_GENERATOR
: the desired trace ID generator. Supported values are:xray
: (default) Amazon X-Ray compatible trace ID generatorrandom
: random trace ID generator
- TLS configuration environment variables.
TLS Configuration
If your OpenTelemetry collector is secured with TLS, you may need to specify the collector's certificate on the imgproxy side. You can do this by either providing a path to the certificate file or by specifying the certificate itself:
IMGPROXY_OPEN_TELEMETRY_SERVER_CERT
: OpenTelemetry collector TLS certificate, PEM-encoded (you can replace line breaks with\n
). Default: blank
If your collector uses mTLS for mutual authentication, you'll also need to specify the client's certificate/key pair:
IMGPROXY_OPEN_TELEMETRY_CLIENT_CERT
: OpenTelemetry client TLS certificate, PEM-encoded (you can replace line breaks with\n
). Default: blankIMGPROXY_OPEN_TELEMETRY_CLIENT_KEY
: OpenTelemetry client TLS key, PEM-encoded (you can replace line breaks with\n
). Default: blank
If IMGPROXY_OPEN_TELEMETRY_SERVER_CERT
is set and the grpc
protocol is used, imgproxy will try to establish a secure connection to the collector even if the collector's endpoint scheme is http://
.
Deprecated Environment Variables
The following environment variables are deprecated and will be removed in the future:
IMGPROXY_OPEN_TELEMETRY_ENDPOINT
: useOTEL_EXPORTER_OTLP_ENDPOINT
instead and explicitly enable OpenTelemetry support withIMGPROXY_OPEN_TELEMETRY_ENABLE
environment variable.warningUnlike
IMGPROXY_OPEN_TELEMETRY_ENDPOINT
,OTEL_EXPORTER_OTLP_ENDPOINT
should contain a URL scheme (http://
orhttps://
).IMGPROXY_OPEN_TELEMETRY_PROTOCOL
: useOTEL_EXPORTER_OTLP_PROTOCOL
instead.IMGPROXY_OPEN_TELEMETRY_GRPC_INSECURE
: useOTEL_EXPORTER_OTLP_ENDPOINT
withhttp://
scheme instead.IMGPROXY_OPEN_TELEMETRY_SERVICE_NAME
: useOTEL_SERVICE_NAME
instead.IMGPROXY_OPEN_TELEMETRY_PROPAGATORS
: useOTEL_PROPAGATORS
instead.IMGPROXY_OPEN_TELEMETRY_CONNECTION_TIMEOUT
: useOTEL_EXPORTER_OTLP_TIMEOUT
instead.warningUnlike
IMGPROXY_OPEN_TELEMETRY_CONNECTION_TIMEOUT
,OTEL_EXPORTER_OTLP_TIMEOUT
should be specified in milliseconds instead of seconds.