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_ENABLEenvironment variable totrueto enable sending request traces to the collector. Default:false. -
(optional) Set the
IMGPROXY_OPEN_TELEMETRY_ENABLE_METRICSenvironment variable totrueto enable sending metrics to the collector. Default:false. -
(optional) Specify the collector protocol with
OTEL_EXPORTER_OTLP_PROTOCOLenvironment variable.tipYou can specify different protocols for traces and metrics by using the
OTEL_EXPORTER_OTLP_TRACES_PROTOCOLandOTEL_EXPORTER_OTLP_METRICS_PROTOCOLenvironment variables.Supported protocols are:
grpc(default)http/protobuf(aliases:http,https)
-
(optional) Specify the collector endpoint with
OTEL_EXPORTER_OTLP_ENDPOINTenvironment variable.tipUse
https://scheme for secure connections (you may need to configure TLS certificates) andhttp://for insecure connections.infoThe
OTEL_EXPORTER_OTLP_ENDPOINTpath should not contain signal-specific paths like/v1/tracesor/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_ENDPOINTandOTEL_EXPORTER_OTLP_METRICS_ENDPOINTenvironment variables. If thehttp/protobufprotocol is used, these signal-specific endpoints should include the signal-specific paths like/v1/tracesor/v1/metrics.Defaults are:
- For the
grpcprotocol:https://localhost:4317 - For the
http/protobufprotocol:https://localhost:4318
- For the
-
(optional) Set the
OTEL_SERVICE_NAMEenvironment variable to be the desired service name. Default:imgproxy. -
(optional) Set up TLS certificates.
-
(optional) Set the
IMGPROXY_OPEN_TELEMETRY_TRACE_ID_GENERATORenvironment 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/jsonprotocol` is not supported.OTEL_TRACES_EXPORTERandOTEL_METRICS_EXPORTERenvironment 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_ENDPOINTinstead and explicitly enable OpenTelemetry support withIMGPROXY_OPEN_TELEMETRY_ENABLEenvironment variable.warningUnlike
IMGPROXY_OPEN_TELEMETRY_ENDPOINT,OTEL_EXPORTER_OTLP_ENDPOINTshould contain a URL scheme (http://orhttps://).IMGPROXY_OPEN_TELEMETRY_PROTOCOL: useOTEL_EXPORTER_OTLP_PROTOCOLinstead.IMGPROXY_OPEN_TELEMETRY_GRPC_INSECURE: useOTEL_EXPORTER_OTLP_ENDPOINTwithhttp://scheme instead.IMGPROXY_OPEN_TELEMETRY_SERVICE_NAME: useOTEL_SERVICE_NAMEinstead.IMGPROXY_OPEN_TELEMETRY_PROPAGATORS: useOTEL_PROPAGATORSinstead.IMGPROXY_OPEN_TELEMETRY_CONNECTION_TIMEOUT: useOTEL_EXPORTER_OTLP_TIMEOUTinstead.warningUnlike
IMGPROXY_OPEN_TELEMETRY_CONNECTION_TIMEOUT,OTEL_EXPORTER_OTLP_TIMEOUTshould be specified in milliseconds instead of seconds.