{"slug": "show-hn-ecotrace-lightweight-carbon-footprint-and-energy-tracker-for-python", "title": "Show HN: EcoTrace – Lightweight carbon footprint and energy tracker for Python", "summary": "EcoTrace v1.4.0, a lightweight Python library for real-time carbon footprint tracking of applications, has been released with new features including a pausable tracking API, WebhookExporter for streaming emissions data to Slack or Discord, side-by-side CLI diff comparisons, filtered CSV exporting, and log maintenance commands, all with zero new mandatory dependencies. The tool provides function-level carbon measurement, hardware detection, and optional GPU and AI insights support, enabling developers to monitor and enforce carbon budgets during development and CI/CD pipelines.", "body_md": "**v1.4.0 — Feature Release.** Pausable tracking API, WebhookExporter, side-by-side CLI diff comparison, filtered CSV exporting, and log maintenance commands — all with zero new mandatory dependencies.\n\n**EcoTrace is a lightweight library for granular carbon footprint measurement of Python applications. No configuration files, no background services—just real-time hardware-level transparency.**\n\nReal-time monitoring | 50+ Global Zones | AI-powered insights | Zero-configuration\n\n[!TIP]\n\nVS Code Extension:Monitor application carbon footprint in real-time during development.[Download here].\n\n*Function-level carbon measurement with real-time monitoring*\n\nFeature Release.v1.4.0 adds pausable tracking, side-by-side run comparisons, webhook integrations, filtered CSV exporting, and log rotation capabilities.\n\n**Pausing API**— Temporarily disable carbon tracking using`EcoTrace.pause()`\n\nand`EcoTrace.resume()`\n\nto exclude setup and teardown overhead.**Run Comparisons (**— Perform side-by-side carbon and execution duration comparisons between two specific runs.`ecotrace diff`\n\n)**Webhook Integration (**— Stream carbon emissions data to Slack, Teams, Discord, or a custom API in real-time.`WebhookExporter`\n\n)**Filtered CSV Exporting**— Export filtered subsets of measurement logs with`--csv`\n\nformat and`--run`\n\n/`--func`\n\nfilters.**Log Maintenance Commands**— Rotate and trim logs via`ecotrace clean`\n\n, and permanently delete logs using`ecotrace reset`\n\n.**Multi-Run History**— Every session gets a unique`RunID`\n\n. Use`ecotrace history`\n\nto compare runs and`ecotrace trends`\n\nfor an ASCII carbon trend chart.— Programmatic access to all session metrics as a typed dict. Ideal for notebooks, dashboards, and CI assertions.`get_summary()`\n\nAPI\n\n```\npip install ecotrace\n```\n\nOptional extras:\n\n```\npip install ecotrace[gpu]   # NVIDIA GPU support\npip install ecotrace[ai]    # Gemini AI insights\npip install ecotrace[all]   # Everything\n```\n\nMeasure any script without changing a single line of code:\n\n```\necotrace run my_script.py\n```\n\nDecorate functions for granular instrumentation:\n\n``` python\nfrom ecotrace import EcoTrace\n\neco = EcoTrace(region_code=\"US\")\n\n@eco.track\ndef my_function():\n    # Your heavy processing here\n    pass\n\nmy_function()\n\n# Export audit-ready reports or check cumulative totals\neco.generate_pdf_report(\"carbon_audit.pdf\")\nprint(f\"Total Carbon Emitted: {eco.total_carbon} gCO2\")\n```\n\nSet a limit and let EcoTrace enforce it:\n\n```\neco = EcoTrace(\n    region_code=\"TR\",\n    carbon_limit=5.0,                   # 5 gCO2 budget\n    on_budget_exceeded=lambda t, l: print(f\"Budget exceeded: {t:.4f}/{l:.4f} gCO2\")\n)\n\n@eco.track\ndef training_pipeline():\n    ...\n\ntraining_pipeline()\nprint(f\"Remaining budget: {eco.remaining_budget} gCO2\")\n```\n\nWhen initialized, EcoTrace performs automated hardware detection:\n\n```\n[EcoTrace] INFO: [INFO] EcoTrace instrumentation session initialized (STATIC).\n[EcoTrace] INFO: -----------------------------------------------------\n[EcoTrace] INFO: Region        : TR (475 gCO2/kWh)\n[EcoTrace] INFO: Hardware Logic: 13th Gen Intel Core i7-13700H\n[EcoTrace] INFO: Specifications: 20 Cores | 45.0W TDP\n[EcoTrace] INFO: Energy Sensor : Boavizta Advanced Estimation\n[EcoTrace] INFO: Memory Config : 15.6 GB DDR4\n[EcoTrace] INFO: GPU Accelerator: Intel Iris Xe Graphics (15.0W TDP)\n[EcoTrace] INFO: -----------------------------------------------------\n```\n\nAt process exit, a session summary is printed automatically:\n\n```\n=======================================================\n  EcoTrace — Session Summary\n=======================================================\n  Duration       : 12.34s\n  Functions      : 5 tracked\n  Total Carbon   : 0.00312000 gCO2\n  Region         : TR (475 gCO2/kWh)\n  Budget         : 0.003120 / 5.000000 gCO2 (0.1%) [OK]\n  Equivalent     : 0.4 min of LED bulb (10W)\n=======================================================\n```\n\nEnforce carbon budgets in your pipeline with our official GitHub Action. Add this to your `.github/workflows/ci.yml`\n\n:\n\n```\n- name: EcoTrace Carbon Gate\n  uses: Zwony/ecotrace@v1.3.0\n  with:\n    budget: '10.0'\n    region: 'US'\n```\n\nYou can also run the gate manually:\n\n```\necotrace gate --budget 10.0\n```\n\nIf total emissions exceed the budget, the gate fails with exit code 1 — preventing carbon-heavy code from being merged.\n\n| Feature | EcoTrace v1.0 |\nCodeCarbon | CarbonTracker |\n|---|---|---|---|\nSampling Interval |\n50ms |\n15s | Per Epoch |\nIsolation |\nProcess-scoped |\nSystem-wide | System-wide |\nBudget Enforcement |\nBuilt-in |\nNo | No |\nCI/CD Gate |\nBuilt-in |\nNo | No |\nIdle Noise Subtraction |\nAutomatic |\nNo | No |\nAsync Support |\nNative |\nLimited | No |\n\n**Deep Transparency:** Derived from verified manufacturer TDP specifications rather than category averages.**Fail-Safe Architecture:** Guaranteed application continuity even if hardware drivers or API keys are missing.**Actionable AI:** Integrates with Google Gemini to provide specific code optimization advice (optional).\n\nFull documentation is available at [ ecotrace.readthedocs.io](https://ecotrace.readthedocs.io/en/latest/).\n\n— How the energy model and process isolation work.**Architecture and Science**— GPU tracking, AI insights, benchmarks, and comparison tables.** Advanced Usage**— Technical documentation for core classes and functions.** API Reference**— Troubleshooting, region codes, and hardware compatibility.** Support and Reference**\n\nWe welcome contributions! Please see our [ CONTRIBUTING.MD](/Zwony/ecotrace/blob/main/CONTRIBUTING.MD) for guidelines on reporting bugs, suggesting features, or contributing hardware data.\n\n**Emre Ozkal** — [GitHub](https://github.com/Zwony) · [ecotraceteam@gmail.com](mailto:ecotraceteam@gmail.com)\n\nMIT License — Use it however you like.\n\n*Developed for sustainable software development practices.*", "url": "https://wpnews.pro/news/show-hn-ecotrace-lightweight-carbon-footprint-and-energy-tracker-for-python", "canonical_source": "https://github.com/Zwony/ecotrace", "published_at": "2026-07-22 15:45:55+00:00", "updated_at": "2026-07-22 15:52:14.496754+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure", "ai-ethics"], "entities": ["EcoTrace", "Python", "Slack", "Teams", "Discord", "NVIDIA", "Gemini", "GitHub"], "alternates": {"html": "https://wpnews.pro/news/show-hn-ecotrace-lightweight-carbon-footprint-and-energy-tracker-for-python", "markdown": "https://wpnews.pro/news/show-hn-ecotrace-lightweight-carbon-footprint-and-energy-tracker-for-python.md", "text": "https://wpnews.pro/news/show-hn-ecotrace-lightweight-carbon-footprint-and-energy-tracker-for-python.txt", "jsonld": "https://wpnews.pro/news/show-hn-ecotrace-lightweight-carbon-footprint-and-energy-tracker-for-python.jsonld"}}