Skip to content

[Hackathon] feat(traces): estimate climate impact from span duration - #122363

Draft
sentry-junior[bot] wants to merge 4 commits into
climate-impact-data-sentryfrom
feat/climate-impact-duration-estimate
Draft

[Hackathon] feat(traces): estimate climate impact from span duration#122363
sentry-junior[bot] wants to merge 4 commits into
climate-impact-data-sentryfrom
feat/climate-impact-duration-estimate

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Part of the climate-impact hackathon POC. Stacked on #122327.

What

Replaces the 1.0 g/span placeholder with a simple duration-based model:

gCO₂e = duration_ms × 15 W × 400 gCO₂e/kWh ÷ 3,600,000,000

The implementation handles the two response shapes used here: top-level duration for trace results and span.duration inside trace-item attributes.

Why this shape

The span schema has no CPU-time field. Wall duration is the closest existing proxy, so the POC can ship without SDK or schema changes.

The constants stay fixed to keep comparisons deterministic without hardware experiments or location-aware grid data:

  • 15 W for the assumed CPU
  • 400 gCO₂e/kWh, rounded from EPA's ~394 estimate to avoid false precision

Unknown duration omits the estimate instead of returning 0, because the frontend uses field presence as the availability signal.

Limitations

Wall time is not CPU time. Parent and child span durations can overlap. This is a relative POC estimate, not inventory-grade accounting.

Tests

Adds focused unit coverage for the formula, both payload shapes, missing data, tree annotation, trace summaries, and trace-item details. Endpoint tests now assert duration-derived values.

Requested by Prajjwal Bhandari.

--

View Junior Session [Sentry]

Replace the 1g/span placeholder with a simple POC model:
duration_ms treated as active CPU time at 15W and 400 gCO2e/kWh.

Co-Authored-By: Josh Goldberg <joshua.goldberg@sentry.io>
Co-Authored-By: Prajjwal Bhandari <prajjwal.bhandari@sentry.io>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Aug 20, 2026
Co-Authored-By: Prajjwal Bhandari <prajjwal.bhandari@sentry.io>
@pbhandari pbhandari changed the title feat(traces): estimate climate impact from span duration [Hackathon] feat(traces): estimate climate impact from span duration Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants