[Hackathon] feat(traces): estimate climate impact from span duration - #122363
Draft
sentry-junior[bot] wants to merge 4 commits into
Draft
[Hackathon] feat(traces): estimate climate impact from span duration#122363sentry-junior[bot] wants to merge 4 commits into
sentry-junior[bot] wants to merge 4 commits into
Conversation
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>
Co-Authored-By: Prajjwal Bhandari <prajjwal.bhandari@sentry.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the climate-impact hackathon POC. Stacked on #122327.
What
Replaces the
1.0 g/spanplaceholder with a simple duration-based model:The implementation handles the two response shapes used here: top-level
durationfor trace results andspan.durationinside 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:
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]