# Using compact span metric

## Overview

Compact span metric is an optimized metric type designed to improve the performance of the APM [Service Catalog](https://coralogix.com/docs/user-guides/apm/features/service-catalog/index.md) and [Database Catalog](https://coralogix.com/docs/user-guides/apm/features/database-monitoring/index.md) pages, especially in large-scale environments. Traditional [Span Metrics](https://coralogix.com/docs/user-guides/apm/getting-started/span-metrics/index.md) can carry very high cardinality, leading to slow load times and limited scalability. Compact span metric addresses this by keeping only the most essential dimensions, reducing metric cardinality while delivering the core insights needed for monitoring and troubleshooting.

Note

- The compact span metric is enabled by default only for Span Metrics users.
- This setup is additive-compact metrics are sent alongside the existing Span Metrics, not as a replacement. This is relevant for both Service and Database Catalogs.
- When you enable the compact metric, data in the main catalog pages will appear only from the moment you start sending it. Drilldowns will continue to use the full span metrics as before.

## Key benefits

- **Uses essential labels only:**
  - Service Catalog: `service_name`, `status_code`, `k8s_cluster_name`, `span_kind`, `host.name`
  - Database Catalog: `service_name`, `status_code`, `k8s_cluster_name`, `db_namespace`, `db_system`, `host.name`
- **Optional histogram control:** the `le` histogram can be disabled to further reduce load.
- **Reduction in cardinality:** lowers metric permutations.
- **Low-latency performance:** enables much faster load times in large environments.
- **Backward compatibility:** compact metrics are sent in addition to existing span metrics, ensuring no breakage in drilldowns.

## Enabling compact span metrics

### With Coralogix OTel integration

Using the Coralogix latest integration is strongly recommended, as it’s continuously updated and aligned with the latest OpenTelemetry releases. To benefit from compact span metric, make sure to upgrade your otel-integration to version `v0.0.230` or higher.

The following metrics are enabled by default:

- Service catalog:

  - `compact_calls_total`
  - `compact_duration_ms_count`
  - `compact_duration_ms_sum`
  - `compact_duration_ms_bucket`

- Databases catalog:

  - `db_compact_calls_total`
  - `db_compact_duration_ms_count`
  - `db_compact_duration_ms_sum`
  - `db_compact_duration_ms_bucket`

### Without Coralogix OTel integration

If you are not using one of the Coralogix integrations (Kubernetes or ECS on EC2) and instead run your own [OpenTelemetry](https://coralogix.com/docs/opentelemetry/getting-started/) collector, you can generate a working example configuration directly from the Coralogix UI and adapt it to your setup.

Follow the steps below to generate a baseline configuration using the Kubernetes integration UI:

1. If the Kubernetes integration is not yet configured, follow the instructions [here](https://coralogix.com/docs/external/telemetry-shippers/otel-integration/k8s-helm/kubernetes-observability/kubernetes-complete-observability-basic-configuration/). If the integration is configured, skip this step and proceed to the next one.
1. From the **Kubernetes Complete Observability** page, Select **Actions**, then **Update**.
1. Navigate to **Review values.yaml and Deploy** and select **Download content.** Download the Kubernetes manifest.
1. Use the downloaded manifest as a reference configuration. It includes a fully configured setup and reflects the latest supported settings. You can adapt this configuration for your own OpenTelemetry collector if needed.

Note

Whenever possible, use the Coralogix integrations for Kubernetes or ECS on EC2. They provide ongoing updates, feature compatibility, and streamlined support, while still allowing you to inspect and reuse the underlying configuration when customization is required.

## UI changes with compact metric

The following fields are affected when compact metric is enabled:

- Unsupported filters are hidden in the main service catalog and db catalog pages.
- Service and Database drilldown pages remain unchanged and continue to use all dimensions from the full span metrics.

## Disabling compact span metric

To disable compact span metric, update and configure your OpenTelemetry collector:

1. Update to the latest otel-integration: `v0.0.230` or higher.
1. Apply the following preset in your Helm chart configuration:

```yaml
otel-integration:
  opentelemetry-agent:
    presets:
      spanMetrics:
        enabled: true
        compactMetrics:
          enabled: false
          dropHistogram: true
```

```yaml
opentelemetry-agent:
  presets:
    spanMetrics:
      enabled: true
      dbMetrics:
        enabled: true
        compactMetrics:
          enabled: false
          dropHistogram: true
```

## Next steps

Already running Events2Metrics? See [Migration from Events2Metrics to Span Metrics](https://coralogix.com/docs/user-guides/apm/getting-started/migration-from-e2m/index.md) for the recommended switchover path.

For per-service visibility into APM volume and cardinality after compact metrics are enabled, use [Service Governance](https://coralogix.com/docs/user-guides/account-management/payment-and-billing/metrics-usage-analyzer/apm/index.md) in the Metrics Usage Analyzer.
