# Datadog

imgproxy can send its metrics to Datadog. To use this feature, do the following:

1. Install & configure the Datadog Trace Agent (>= 5.21.1).
2. Set the `IMGPROXY_DATADOG_ENABLE` environment variable to `true`.
3. Configure the Datadog tracer using `ENV` variables provided by [the package](https://github.com/DataDog/dd-trace-go):

    * `DD_AGENT_HOST`: sets the address to connect to for sending metrics to the Datadog Agent. Default: `localhost`
    * `DD_TRACE_AGENT_PORT`: sets the Datadog Agent Trace port. Default: `8126`
    * `DD_DOGSTATSD_PORT`: set the DogStatsD port. Default: `8125`
    * `DD_SERVICE`: sets the desired application name. Default: `imgproxy`
    * `DD_ENV`: specifies the environment to which all traces will be submitted. Default: empty
    * `DD_TRACE_SOURCE_HOSTNAME`: specifies the hostname with which to mark outgoing traces. Default: empty
    * `DD_TRACE_REPORT_HOSTNAME`: when `true`, sets hostname to `os.Hostname()` with which to mark outgoing traces. Default: `false`
    * `DD_TAGS`: sets a key/value pair which will be set as a tag on all traces. Example: `DD_TAGS=datacenter:njc,key2:value2`. Default: empty
    * `DD_TRACE_ANALYTICS_ENABLED`: allows specifying whether Trace Search & Analytics should be enabled for integrations. Default: `false`
    * `DD_RUNTIME_METRICS_ENABLED`: enables automatic collection of runtime metrics every 10 seconds. Default: `false`
    * `DD_TRACE_STARTUP_LOGS`: causes various startup info to be written when the tracer starts. Default: `true`
    * `DD_TRACE_DEBUG`: enables detailed logs. Default: `false`
4. _(optional)_ Set the `IMGPROXY_DATADOG_ENABLE_ADDITIONAL_METRICS` environment variable to `true` to collect the [additional metrics](#additional-metrics).

imgproxy will send the following info to Datadog:

* Response time
* Queue time
* Image downloading time
* Image processing time
* Errors that occurred while downloading and processing image

## Additional metrics

When the `IMGPROXY_DATADOG_ENABLE_ADDITIONAL_METRICS` environment variable is set to `true`, imgproxy will send the following additional metrics to Datadog:

* `imgproxy.workers`: the configured number of imgproxy workers
* `imgproxy.requests_in_progress`: the number of requests currently in progress
* `imgproxy.images_in_progress`: the number of images currently in progress
* `imgproxy.workers_utilization`: the percentage of imgproxy's workers utilization. Calculated as `imgproxy.requests_in_progress / imgproxy.workers * 100`
* `imgproxy.buffer.size`: a histogram of the download buffers sizes (in bytes)
* `imgproxy.buffer.default_size`: calibrated default buffer size (in bytes)
* `imgproxy.buffer.max_size`: calibrated maximum buffer size (in bytes)
* `imgproxy.vips.memory`: libvips memory usage (in bytes)
* `imgproxy.vips.max_memory`: libvips maximum memory usage (in bytes)
* `imgproxy.vips.allocs`: the number of active vips allocations

---

## Navigation

- [Getting started](/3.31.x/getting_started)
- [imgproxy Pro](https://imgproxy.net#pro)
- [Installation](/3.31.x/installation)
- [Configuration](/3.31.x/category/configuration)
  - [Configuration options](/3.31.x/configuration/options)
  - [Loading environment variables](/3.31.x/configuration/loading_environment_variables)
- [Usage](/3.31.x/category/usage)
  - [Processing an image](/3.31.x/usage/processing)
  - [Getting an image info](/3.31.x/usage/getting_info)
  - [Signing a URL](/3.31.x/usage/signing_url)
  - [Encrypting a source URL](/3.31.x/usage/encrypting_source_url)
  - [Presets](/3.31.x/usage/presets)
- [Features](/3.31.x/category/features)
  - [Watermark](/3.31.x/features/watermark)
  - [Object detection](/3.31.x/features/object_detection)
  - [Autoquality](/3.31.x/features/autoquality)
  - [Best format](/3.31.x/features/best_format)
  - [Chained pipelines](/3.31.x/features/chained_pipelines)
- [Image sources](/3.31.x/category/image-sources)
  - [Serving local files](/3.31.x/image_sources/local_files)
  - [Serving files from Amazon S3](/3.31.x/image_sources/amazon_s3)
  - [Serving files from Google Cloud Storage](/3.31.x/image_sources/google_cloud_storage)
  - [Serving files from Azure Blob Storage](/3.31.x/image_sources/azure_blob_storage)
  - [Serving files from OpenStack Object Storage ("Swift")](/3.31.x/image_sources/openstack_swift)
- [Monitoring](/3.31.x/category/monitoring)
  - [New Relic](/3.31.x/monitoring/new_relic)
  - [Prometheus](/3.31.x/monitoring/prometheus)
  - [Datadog](/3.31.x/monitoring/datadog)
  - [OpenTelemetry](/3.31.x/monitoring/open_telemetry)
  - [Amazon CloudWatch](/3.31.x/monitoring/cloud_watch)
- [Image formats support](/3.31.x/image_formats_support)
- [About the processing pipeline](/3.31.x/about_processing_pipeline)
- [Health check](/3.31.x/healthcheck)
- [Memory usage tweaks](/3.31.x/memory_usage_tweaks)

## Other versions

- [4.0.x (current)](/monitoring/datadog)
- [latest (unstable)](/latest/monitoring/datadog)
- [3.30.x](/3.30.x/monitoring/datadog)
- [3.29.x](/3.29.x/monitoring/datadog)
- [3.28.x](/3.28.x/monitoring/datadog)
- [3.27.x](/3.27.x/monitoring/datadog)
- [3.26.x](/3.26.x/monitoring/datadog)
- [3.25.x](/3.25.x/monitoring/datadog)
- [3.24.x](/3.24.x/monitoring/datadog)
- [3.23.x](/3.23.x/monitoring/datadog)
- [3.22.x](/3.22.x/monitoring/datadog)
- [3.21.x](/3.21.x/monitoring/datadog)
- [3.20.x](/3.20.x/monitoring/datadog)
- [3.19.x](/3.19.x/monitoring/datadog)
