Skip to main content

A library for monitoring and reporting resource usage in containerized applications

Project description

Resource Reporter

A Python library for monitoring and reporting resource usage in containerized applications, with support for asynchronous event reporting and command listening.

Features

  • Regular resource usage reporting (CPU, memory, network, GPU)
  • Asynchronous event reporting
  • Command listening via Google PubSub for remote control of containers
  • Support for graceful shutdown and restart

Installation

Basic Installation

pip install resource-reporter

With GPU Support

pip install resource-reporter[gpu]

Quick Start

from resource_reporter import ResourceReporter

# Initialize the reporter
reporter = ResourceReporter(
    metrics_endpoint_url="http://monitoring-service/api/metrics",
    events_endpoint_url="http://monitoring-service/api/events",
    interval=30,
    consumer_id="consumer-1",
    group_consumer="production"
)

# Start reporting
reporter.start()

# Report an event
reporter.async_report_event({
    "status": 200,
    "error_code": 0,
    "error_message": "",
    "result": {"processed": True},
    "stats_data": {"duration_ms": 120},
    "task_id": "task-123"
})

# Update job stats
reporter.update_job_stats({
    "processed": 1000,
    "errors": 5
})

# Stop the reporter when done
reporter.stop()

Documentation

Environment Variables

The Resource Reporter library uses several environment variables for configuration. While most parameters can be passed directly to the constructor, environment variables provide a convenient way to configure the reporter, especially in containerized environments.

Required Environment Variables

None of the environment variables are strictly required, as all configuration can be passed directly to the constructor. However, the following are commonly used:

Optional Environment Variables

Variable Description Default
GROUP_CONSUMER Group identifier for the consumer "default"
API_KEY API key for authentication with metrics and events endpoints None
GOOGLE_APPLICATION_CREDENTIALS Path to Google Cloud credentials JSON file None

Google Cloud Authentication

For PubSub command listening functionality, the reporter requires Google Cloud authentication. There are several ways to provide this:

  1. Service Account JSON (recommended for non-GCP environments):
    export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account-key.json
    

License MIT

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

resource_reporter-0.1.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

resource_reporter-0.1.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file resource_reporter-0.1.2.tar.gz.

File metadata

  • Download URL: resource_reporter-0.1.2.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for resource_reporter-0.1.2.tar.gz
Algorithm Hash digest
SHA256 68cb90a34bbe27c0950129671ec5cace48a0c044227d3be566b263a26e8e4139
MD5 11179c849004e6301803f9f98e63ce97
BLAKE2b-256 e58cbee5d9a543fed240bf984e03349b250bcd52878143b9541b1f347d46e9f9

See more details on using hashes here.

File details

Details for the file resource_reporter-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for resource_reporter-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c10638271e20d612a2ca31e0c3735b312b5f40d505367484a46cee7e5ce9f32b
MD5 1ddb1bc19091a2dc0687f2dadc5de67a
BLAKE2b-256 77224e6eceff869a79702f96ce8cd02bad10757e898b3c9c49a1dab4fcace598

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