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) Set the
IMGPROXY_OPEN_TELEMETRY_ENABLE_LOGSenvironment variable totrueto enable sending logs to the collector. Default:false. -
(optional) Specify the collector protocol with
OTEL_EXPORTER_OTLP_PROTOCOLenvironment variable.tipYou can specify different protocols for traces, metrics, and logs by using the
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL,OTEL_EXPORTER_OTLP_METRICS_PROTOCOL, andOTEL_EXPORTER_OTLP_LOGS_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, metrics, and logs by using the
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, andOTEL_EXPORTER_OTLP_LOGS_ENDPOINTenvironment variables. If thehttp/protobufprotocol is used, these signal-specific endpoints should include the signal-specific paths like/v1/traces,/v1/metrics, or/v1/logs.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:
workers: the configured number of imgproxy workersrequests_in_progress: the number of requests currently in progressimages_in_progress: the number of images currently in progressworkers_utilization: the percentage of imgproxy's workers utilization. Calculated asrequests_in_progress / workers * 100buffer_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_EXPORTER,OTEL_METRICS_EXPORTER, andOTEL_LOGS_EXPORTERenvironment variables are ignored as imgproxy always uses the OTLP exporter.
Also, imgproxy supports the following environment variables:
IMGPROXY_OPEN_TELEMETRY_PROPAGATE_EXTERNAL: whentrue, imgproxy will propagate OpenTelemetry tracing headers to external requests such as image downloads. Default:falseIMGPROXY_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://.