Skip to main content

Plugin for Vedro framework for measuring resource usage of tests

Project description

Vedro profiling

PyPI PyPI - Downloads Python Version

Vedro profiling - plugin for Vedro framework for measuring resource usage of tests

The plugin measures CPU and memory usage during test execution and exports metrics in k6-compatible NDJSON format, making it easy to integrate with performance monitoring tools like Grafana, InfluxDB, and other observability platforms.

Installation

Quick

For a quick installation, you can use a plugin manager as follows:

$ vedro plugin install vedro-profiling

Manual

To install manually, follow these steps:

  1. Install the package using pip:
$ pip3 install vedro-profiling
  1. Next, activate the plugin in your vedro.cfg.py configuration file:
# ./vedro.cfg.py
import vedro
import vedro_profiling


class Config(vedro.Config):
    class Plugins(vedro.Config.Plugins):
        class VedroProfiling(vedro_profiling.VedroProfiling):
            enabled = True

Usage

Basic Usage

Enable profiling for your test run:

$ vedro run --enable-profiling

This will create a .profiling/profiling.ndjson file with CPU and memory metrics in k6-compatible format.

With Custom Run ID

$ vedro run --enable-profiling --run-id load-test-2026-01-26

With Visualization

Generate matplotlib plots alongside the metrics:

$ vedro run --enable-profiling --draw-plots

Configuration

Advanced Configuration

# ./vedro.cfg.py
import vedro
import vedro_profiling


class Config(vedro.Config):
    class Plugins(vedro.Config.Plugins):
        class VedroProfiling(vedro_profiling.VedroProfiling):
            enabled = True
            enable_profiling = True
            
            # Profiling methods: "default" (psutil), "docker" (containers)
            profiling_methods = ["default", "docker"]
            
            # Polling interval in seconds
            poll_time = 1.0
            
            # Generate plots
            draw_plots = True
            
            # Docker Compose project name for container monitoring
            docker_compose_project_name = "my-project"
            
            # Custom run identifier
            profiling_run_id = "staging-load-test"
            
            # Additional tags for metrics
            additional_tags = {
                "env": "staging",
                "team": "performance",
                "region": "us-east-1"
            }

Output Format

The plugin generates metrics in NDJSON (newline-delimited JSON) format compatible with k6 and other performance monitoring tools.

File Location

  • Metrics: .profiling/profiling.ndjson
  • Plots (if enabled): .profiling/*.png

NDJSON Structure

The output file contains metric definitions followed by data points:

{"type":"Metric","metric":"cpu_percent","data":{"type":"gauge","unit":"percent"}}
{"type":"Metric","metric":"memory_usage","data":{"type":"gauge","unit":"megabytes"}}
{"type":"Point","metric":"cpu_percent","data":{"time":"2026-01-26T10:00:00.123Z","value":25.5,"tags":{"target":"app-1","method":"docker","run":"my-test-123"}}}
{"type":"Point","metric":"memory_usage","data":{"time":"2026-01-26T10:00:00.123Z","value":512.3,"tags":{"target":"app-1","method":"docker","run":"my-test-123"}}}

Metrics

  • cpu_percent - CPU usage percentage (gauge)
  • memory_usage - Memory usage in megabytes (gauge)

Tags

Each data point includes the following tags:

  • target - Container name or process name
  • method - Profiling method (docker or default)
  • run - Unique run identifier
  • Custom tags from configuration

Processing Data

Extract Data Points Only

cat .profiling/profiling.ndjson | jq -c 'select(.type=="Point")'

Filter by Tags

cat .profiling/profiling.ndjson | jq -c 'select(.type=="Point" and .data.tags.env=="staging")'

Convert to InfluxDB Line Protocol

cat .profiling/profiling.ndjson | jq -r '
  select(.type=="Point") | 
  "\(.metric),target=\(.data.tags.target),method=\(.data.tags.method) value=\(.data.value) \(.data.time | fromdate * 1000000000)"
'

Aggregate Metrics

# Average CPU by target
cat .profiling/profiling.ndjson | jq -s '
  [.[] | select(.type=="Point" and .metric=="cpu_percent")] |
  group_by(.data.tags.target) |
  map({target: .[0].data.tags.target, avg_cpu: ([.[].data.value] | add / length)})
'

Features

  • Multiple Profiling Methods: Monitor both system-level metrics (via psutil) and Docker container metrics
  • k6-Compatible Format: Export metrics in NDJSON format for easy integration with monitoring tools
  • Custom Tags: Add custom tags for filtering and grouping metrics
  • Visualization: Generate matplotlib plots for quick visual analysis
  • Non-Blocking: Uses background threads to minimize impact on test execution
  • Flexible Configuration: Configure via code or command-line arguments

Integration Examples

Grafana + InfluxDB

  1. Convert NDJSON to InfluxDB Line Protocol
  2. Import into InfluxDB:
influx write --bucket performance --file profiling.influx
  1. Create Grafana dashboard using InfluxDB as data source

Custom Analysis

import json

# Read and process metrics
with open('.profiling/profiling.ndjson') as f:
    for line in f:
        point = json.loads(line)
        if point['type'] == 'Point':
            metric = point['metric']
            value = point['data']['value']
            tags = point['data']['tags']
            # Process metrics...

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

vedro_profiling-0.2.0.tar.gz (124.0 kB view details)

Uploaded Source

Built Distribution

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

vedro_profiling-0.2.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file vedro_profiling-0.2.0.tar.gz.

File metadata

  • Download URL: vedro_profiling-0.2.0.tar.gz
  • Upload date:
  • Size: 124.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vedro_profiling-0.2.0.tar.gz
Algorithm Hash digest
SHA256 56f164b89dbf42e8c57ba33822baeb4b4b0a096e94be984cae3bfc0bfdbcdaed
MD5 481e41b78ebd86483e7fa72fd4e6abde
BLAKE2b-256 aa4fbf86d5aed96ad19ba319cc3a08781a3dd337caae30d40807bab906498770

See more details on using hashes here.

File details

Details for the file vedro_profiling-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: vedro_profiling-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for vedro_profiling-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf00c716e9796c2fd982711bb9f922c58207bb4ccc4a7581ddba59312d16bd3
MD5 0e6cb9c7f8c15c94b35998d0b1ccd8cc
BLAKE2b-256 963c5602c19add5081158cbe2fc868f420d89f13fb4849ea7dacc496b1137369

See more details on using hashes here.

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