Skip to main content

Cross-language lightweight SDK for Carbon Live / GreenRefactor dashboard

Project description

GreenRefactor Python SDK

WS öncelikli, HTTP fallback’li Python istemcisi. pycarbon.dashboard.server ile konuşur.

Kurulum (yerel pip)

cd /Users/aligokkaya/Desktop/Carbon/code-carbon/sdks/greenrefactor-python
python -m venv .venv
source .venv/bin/activate
pip install -e .

Bu sayede greenrefactor modülünü import edebilirsin.

Örnekler

Tüm örnekler examples/ altında. Ortak adımlar:

cd /Users/aligokkaya/Desktop/Carbon/code-carbon/sdks/greenrefactor-python/examples
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt   # -e .. içerir

Basit Span (simple_span.py)

CARBON_HOST=127.0.0.1 python simple_span.py

Script CarbonClient ile bir session başlatır ve @carbon_span dekoratörüyle CPU-yoğun işi dashboard’a gönderir.

SDK artık span başlangıç/bitiş mesajlarına otomatik olarak ts (timestamp) ekler ve decorator/context manager'lara meta sözlüğü geçebilirsin.

Örnek kullanım:

from greenrefactor import carbon_span, send_heartbeat

send_heartbeat(
    agent="python-simple",
    version="1.0.0",
    interval=30,
    meta={"lang": "python", "env": "local"},
)

@carbon_span("python-demo.work", meta=lambda: {"phase": "warmup"})
def heavy_python_work():
    ...

send_heartbeat sadece HTTP üzerinden /api/v1/heartbeat çağırır; ws bağlantısı gerektirmez.

Ağır Test (demo.py)

BURN_MINUTES=1 python demo.py

CPU, disk, bellek ve opsiyonel GPU/net yükleri oluşturur. Dashboard’da belirgin enerji artışı görürsün.

Unutma: Önce backend’i aç (python -m pycarbon.dashboard.server veya Docker imajı).

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

greenrefactor_python-0.3.10.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

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

greenrefactor_python-0.3.10-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file greenrefactor_python-0.3.10.tar.gz.

File metadata

  • Download URL: greenrefactor_python-0.3.10.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for greenrefactor_python-0.3.10.tar.gz
Algorithm Hash digest
SHA256 dad897e309afddc548a86ec81d48a381711659f628b9377c96ed615b9773e554
MD5 a84e41b5f17f70b5ee3a0ab1a2836f78
BLAKE2b-256 6d208515e2641c302b3ad286287442f99bf8fde50c7a885cb7722c8b965fff24

See more details on using hashes here.

File details

Details for the file greenrefactor_python-0.3.10-py3-none-any.whl.

File metadata

File hashes

Hashes for greenrefactor_python-0.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 d788a6b18d0d62fe898653ea0a106f3394ffae151df2b9509215e3c4a97f1258
MD5 637b1143938ee9bd309544c2001f664f
BLAKE2b-256 720ce882405b16dc5829872bbce1fcf0f047a1abcd7f40dcf21fb93e416f466d

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