Skip to content

Conversation

@fvaleye
Copy link
Owner

@fvaleye fvaleye commented Jun 3, 2025

Description

The metrics are displayed when launching before timing expiration with the CLI.

Related Issue(s)

@fvaleye fvaleye requested a review from Copilot June 3, 2025 07:17
@fvaleye fvaleye self-assigned this Jun 3, 2025
@fvaleye fvaleye added the enhancement New feature or request label Jun 3, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures metrics are only displayed after their timing window expires when using the CLI and hardens error handling, while also updating project configuration and tooling.

  • Add skip logic and structured error handling around metric generation in the stdout exporter
  • Enhance CLI’s run_metrics with initialization guards and top-level exception handling
  • Migrate project metadata to PEP 621 format and bump tooling versions (Makefile & pre-commit)

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tracarbon/exporters/stdout.py Wraps metric loop in try/except, logs and skips None values, adds debug/error logging
tracarbon/cli/init.py Initializes tracarbon before try, catches general exceptions, differentiates exit log paths
pyproject.toml Replaces [tool.poetry] with PEP 621 [project], restructures author/dev dependency formats
Makefile Changes poetry install target to poetry install --with dev
.pre-commit-config.yaml Updates Poetry plugin rev from 1.5.1 to 2.1.3
Comments suppressed due to low confidence (5)

tracarbon/exporters/stdout.py:24

  • Added logic to skip metrics with None value but there are no tests covering this scenario; consider adding a unit test to verify that metrics with None values are properly skipped and that the corresponding debug log is emitted.
if metric_value is not None:

tracarbon/exporters/stdout.py:31

  • [nitpick] Using logger.error here omits the stack trace; consider using logger.exception to include full exception context for easier debugging.
except Exception as e:

tracarbon/cli/init.py:124

  • [nitpick] The CLI logs initialization errors but still exits with a zero status code; consider calling sys.exit(1) after logging to signal failure to upstream processes.
except Exception as e:

pyproject.toml:1

  • Migrating from Poetry’s [tool.poetry] to PEP 621 [project] may break existing Poetry workflows; ensure the [build-system] section is updated accordingly and that your CI/tooling supports the PEP 621 layout.
[project]

Makefile:6

  • [nitpick] Using --with dev ensures development dependencies are installed but may exclude other optional groups; verify this aligns with the expected setup and update the README accordingly.
@poetry install --with dev

@fvaleye fvaleye force-pushed the fix/metrics-appear-when-launching-with-cli branch 2 times, most recently from 7db77bd to 31dcf64 Compare June 3, 2025 07:20
@fvaleye fvaleye force-pushed the fix/metrics-appear-when-launching-with-cli branch from 31dcf64 to 5da2656 Compare June 3, 2025 07:24
@fvaleye fvaleye force-pushed the fix/metrics-appear-when-launching-with-cli branch from edc85e6 to 282e169 Compare June 3, 2025 07:29
@fvaleye fvaleye merged commit c1f4b61 into main Jun 3, 2025
8 checks passed
@fvaleye fvaleye deleted the fix/metrics-appear-when-launching-with-cli branch June 3, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nothing happend upon running Tracarbon CLI

2 participants