Skip to main content

Sync metrics to Eppo

Project description

Eppo Metrics Sync

PyPI version Tests

A Python package for syncing metric definitions with Eppo's API. Manage your Eppo metrics as code using YAML files. Documentation is available in Eppo's documentation page.

Features

  • Sync metrics and fact sources to Eppo
  • Validate metric definitions locally
  • Support for dbt models
  • Dry-run capability for testing
  • Prefix support for testing in shared workspaces

Installation

pip install eppo-metrics-sync

Usage

Basic usage

  1. Set required environment variables:
export EPPO_API_KEY="your-api-key"

export EPPO_SYNC_TAG="your-sync-tag" # optional

export EPPO_REFERENCE_URL="your-reference-url" # optional
  1. Create your metrics YAML files (see Documentation)

  2. Run the sync:

python -m eppo_metrics_sync path/to/yaml/directory

CLI Options

python -m eppo_metrics_sync [OPTIONS] DIRECTORY

Options:

  • --dryrun Validate files without syncing to Eppo
  • --schema Schema type: eppo (default) or dbt-model
  • --sync-prefix Prefix for fact/metric names (useful for testing)
  • --dbt-model-prefix Warehouse/schema prefix for dbt models
  • --allow-upgrades Allow existing non-certified metrics/fact sources to become certified

When to use --allow-upgrades

The --allow-upgrades flag is useful in the following scenarios:

  • Promoting existing metrics to certified status: If you have existing metrics or fact sources in Eppo that are not currently certified, this flag allows them to be upgraded to certified status during the sync process.
  • Migrating from manual to code-managed metrics: When transitioning from manually created metrics in the Eppo UI to managing them through YAML files, this flag enables the promotion of those metrics to certified status.
  • Avoiding conflicts during migration: Without this flag, attempting to sync metrics that already exist in a non-certified state may result in conflicts or the sync process not upgrading their certification status.

Validation Rules & Constraints

The following validation rules are enforced when syncing metrics. Understanding these constraints upfront can help avoid validation errors during development:

Winsorization Constraints

Winsorization parameters (winsorization_lower_percentile, winsorization_upper_percentile) can only be used with these aggregation operations:

  • sum
  • count
  • count_distinct
  • last_value
  • first_value

Not supported for:

  • distinct_entity - Binary metrics don't need winsorization
  • threshold - Threshold logic handles outliers differently
  • retention - Binary retention metrics don't need winsorization
  • conversion - Binary conversion metrics don't need winsorization

Advanced Aggregation Parameters

Each advanced aggregation type requires its specific parameter and cannot use others:

Threshold Metrics

  • Required: threshold_metric_settings object with:
    • comparison_operator: "gt" or "gte"
    • aggregation_type: "sum" or "count" (not count_distinct)
    • breach_value: numeric threshold value
  • Cannot use: retention_threshold_days, conversion_threshold_days
  • Cannot use: Timeframe parameters (aggregation_timeframe_start_value, aggregation_timeframe_end_value, aggregation_timeframe_unit)

Retention Metrics

  • Required: retention_threshold_days (numeric)
  • Cannot use: threshold_metric_settings, conversion_threshold_days

Conversion Metrics

  • Required: conversion_threshold_days (numeric)
  • Cannot use: threshold_metric_settings, retention_threshold_days
  • Cannot use: Timeframe parameters (aggregation_timeframe_start_value, aggregation_timeframe_end_value)

Timeframe Parameters

When using aggregation timeframe parameters:

  • Required: aggregation_timeframe_unit must be specified if any timeframe parameters are used
  • Supported units: "minutes", "hours", "days", "weeks", "calendar_days"
  • Not supported for: conversion operations (use conversion_threshold_days instead)

Denominator Constraints

For ratio metrics, denominators can only use these operations:

  • sum, count, count_distinct, distinct_entity, last_value, first_value
  • ❌ Cannot use: threshold, retention, conversion

Guardrail Cutoff Signs

When using guardrail metrics (is_guardrail: true with guardrail_cutoff):

  • If desired_change: "increase"guardrail_cutoff must be negative
  • If desired_change: "decrease"guardrail_cutoff must be positive

Note: The validation uses the metric's desired_change if specified, otherwise it falls back to the fact's desired_change. This allows you to override the fact-level direction when creating guardrail metrics.

Documentation

For detailed information about metric configuration, available options and constraints, see Eppo's documentation page.

Example YAML Configuration

fact_sources:
    - name: Revenue
      sql: |
          SELECT ts, user_id, amount
          FROM revenue_table
      timestamp_column: ts
      entities:
          - entity_name: User
            column: user_id
      facts:
          - name: Revenue
            column: amount

metrics:
    - name: Total Revenue
      description: Sum of Total Purchase Value in Purchases Fact Table
      entity: User
      numerator:
          fact_name: Revenue
          operation: sum
      desired_change: increase

Development

Setup

Create a virtual environment

python -m venv .venv
source .venv/bin/activate

Install dependencies

pip install -r requirements.txt

Running the tests

pytest tests

Running the package

export EPPO_API_KEY="your-api-key"
export EPPO_SYNC_TAG="your-sync-tag"
export EPPO_REFERENCE_URL="your-reference-url"
python -m eppo_metrics_sync path/to/yaml/directory

Building and Publishing

For package maintainers:

  1. Update version in pyproject.toml
  2. Build the package:
python -m build
  1. The package will be automatically published to PyPI when a new release is created on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eppo_metrics_sync-0.1.15.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eppo_metrics_sync-0.1.15-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file eppo_metrics_sync-0.1.15.tar.gz.

File metadata

  • Download URL: eppo_metrics_sync-0.1.15.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for eppo_metrics_sync-0.1.15.tar.gz
Algorithm Hash digest
SHA256 7edab4104bfe76ec705ed726471c75f65b339db3a49258797144252d7a59f31f
MD5 9f85e5d2cf91b1b639fa9ad113d6e06b
BLAKE2b-256 371f1a2c61465dd57843f66ce3e954ffea4beb0c3d732d6d9d2cb382af289719

See more details on using hashes here.

Provenance

The following attestation bundles were made for eppo_metrics_sync-0.1.15.tar.gz:

Publisher: publish.yml on Eppo-exp/eppo-metrics-sync

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file eppo_metrics_sync-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for eppo_metrics_sync-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 3ec068ab11ca1b04b043c8fe26ecd862cc11ac8ffef90a30c4a9c602da9b1ffd
MD5 fb049144009ba8321caebebdab7cd859
BLAKE2b-256 7de5c82654ccadd3b9a626a6dfddee3b82461fefe23c8df1b1c870a46c09fa0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for eppo_metrics_sync-0.1.15-py3-none-any.whl:

Publisher: publish.yml on Eppo-exp/eppo-metrics-sync

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page