Sitelet https://github.com/RETIT/opentelemetry-javaagent-extension/pull/390
Skip to content

Fix SCI calculation in example dashboards and exclude high-cardinality attributes from resource demand metrics - #390

Merged
brunnert merged 11 commits into
mainfrom
bug/FixBugReport
Oct 5, 2026
Merged

brunnert merged 11 commits into
mainfrom
bug/FixBugReport

Conversation

@brunnert

@brunnert brunnert commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

This MR fixes two problems found in a user's bug report: SCI values that were far too high, and transactions that showed a rate of 0.

  1. Fix the SCI formula in the example Grafana dashboards

The SCI panels in all four example dashboards had unit errors. The corrected formulas follow the model from our SSP24 and FSE'25 papers. Recomputed with the
measurement data from the FSE'25 paper (Table 4), the new formula matches the published per-transaction power values within 0.6–1.5 %.

  • CPU utilization: rate() returns ms per second, but the old formula treated it as ms per minute (/ 60000) and didn't divide by the vCPU count. It now uses rate
    / 1000 / vCPU.
  • CPU power: min/max power are published per vCPU, so they are now multiplied by the vCPU count.
  • CPU energy: the old formula produced Joules instead of kWh, which made it too high by a factor of 3600. It is now PTcpu / 60 / 1000, i.e. kWh per minute.
  • Attribution: the Spring and Quarkus dashboards didn't assign CPU power to the transaction, so it is now multiplied by CPUutilT. PUE is now applied as well.
  • Unit mismatches: GEF is published in kg/kWh, so the CPU and memory terms are now converted to g. Embodied emissions were in mg and are now converted to g. The memory rate is now converted from per-second to per-minute.
  • New gauge io.retit.emissions.instance.vcpu.count: gives the dashboards the vCPU count, which was previously only available as a label.
  • README: documents the units of all metrics, including the process CPU time in ms and the Prometheus naming difference between the two CPU counters, plus the full SCI formula.
  1. Exclude high-cardinality span attributes from resource demand metrics

All span attributes were copied onto the io.retit.resource.demand.* counters, including url.query. If the query contains session or person IDs, almost every
request creates its own time series. A new series starts with a single value, so Prometheus' rate() returns 0 for it, and after 2000 series the SDK puts
everything into an overflow series that has no url.path. Personal data also ended up as metric labels.

  • Extended default exclusion list: besides the existing network, thread, user, client and instance, it now also excludes:
    • url.query, url.full, url.fragment
    • http.request.header, http.response.header
    • session, enduser
    • messaging.message.id, messaging.message.conversation_id
    • db.statement, db.query.text
  • New config option IO_RETIT_METRICS_EXCLUDED_ATTRIBUTES: a comma-separated list of prefixes that replaces the default list. For example, it can bring url.query
    back for applications that dispatch via query parameters. io.retit.* attributes are always excluded.
  • Unit tests in MetricPublishingServiceTest cover the default list, a replacement list and an empty list.
  • README: documents the new option and which attributes are published by default.

Breaking changes

  • Metric attributes from the newly excluded prefixes are no longer published. Queries that filter or group by url_query etc. need to be adjusted.
  • The example dashboards need the new vCPU gauge, so they require this extension version.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

AWS power units, Quarkus memory conversions, and the exclusion example can still produce incorrect or unsafe results.

Review effort: Balanced
Findings: 2 High severity · 1 Low severity

Open (3)
What changed in this PR

Corrects SCI calculations and reduces resource-demand metric cardinality and sensitive-label exposure.

Changes:

  • Revises SCI unit conversions and adds a vCPU gauge.
  • Adds configurable attribute-prefix exclusions with tests.
  • Documents metric units, formulas, and configuration.
File Description
README.md Documents metrics, exclusions, and SCI formulas.
ContainerLogMetricAndSpanExtractingTest.java Expects the new vCPU gauge.
spring-test-service-dashboard.json Updates Spring SCI calculations.
simple-jdk8-application-dashboard.json Updates JDK 8 SCI calculations.
simple-jdk21-application-dashboard.json Updates JDK 21 SCI calculations.
quarkus-test-service-dashboard.json Updates Quarkus SCI calculations.
MetricPublishingServiceTest.java Tests attribute filtering.
MetricPublishingService.java Publishes vCPU count and filters attributes.
InstanceConfiguration.java Parses configurable exclusion prefixes.
Constants.java Defines the new configuration property.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread README.md Outdated
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 37299175545]:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #119.28691807.023.30547.72
Total Run19.291807.023.30547.72
Additional overhead from Eco CIN/A7.107.101.00

🌳 CO2 Data:
City: CONSTANT, Lat: , Lon:
IP:
CO₂ from energy is: 0.167651300 g
CO₂ from manufacturing (embodied carbon) is: 0.156272079 g
Carbon Intensity for this location: 334 gCO₂eq/kWh
SCI: 0.323923 gCO₂eq / pipeline run emitted

brunnert and others added 3 commits October 5, 2026 14:08
Updated the IO_RETIT_METRICS_EXCLUDED_ATTRIBUTES to include additional prefixes for exclusion in metrics.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Andreas Brunnert <brunnert@retit.de>
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 37307484092]:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #122.53431993.013.47574.45
Total Run22.531993.013.47574.45
Additional overhead from Eco CIN/A7.587.081.07

🌳 CO2 Data:
City: CONSTANT, Lat: , Lon:
IP:
CO₂ from energy is: 0.184907076 g
CO₂ from manufacturing (embodied carbon) is: 0.163898517 g
Carbon Intensity for this location: 334 gCO₂eq/kWh
SCI: 0.348806 gCO₂eq / pipeline run emitted

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 37307830833]:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #125.53392256.413.67614.54
Total Run25.532256.413.67614.54
Additional overhead from Eco CIN/A11.007.381.49

🌳 CO2 Data:
City: CONSTANT, Lat: , Lon:
IP:
CO₂ from energy is: 0.209344854 g
CO₂ from manufacturing (embodied carbon) is: 0.175336748 g
Carbon Intensity for this location: 334 gCO₂eq/kWh
SCI: 0.384682 gCO₂eq / pipeline run emitted

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 37307955243]:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #125.42342373.893.67645.98
Total Run25.422373.893.67645.98
Additional overhead from Eco CIN/A11.026.841.61

🌳 CO2 Data:
City: CONSTANT, Lat: , Lon:
IP:
CO₂ from energy is: 0.220244276 g
CO₂ from manufacturing (embodied carbon) is: 0.184307014 g
Carbon Intensity for this location: 334 gCO₂eq/kWh
SCI: 0.404551 gCO₂eq / pipeline run emitted

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The new test fixture contains realistic identifiers and does not exercise most newly added exclusion prefixes.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
Resolved since last review (3)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Azure constrained-instance vCPU ratios produce incorrect dashboard calculations, and exclusion configuration is repeatedly parsed on a hot path.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Cache exclusion configuration instead of reparsing per span

core/​src/​main/​java/​io/​retit/​opentelemetry/​javaagent/​extension/​metrics/​MetricPublishingService.java:284

This resolves and parses the exclusion configuration for every completed top-level span. On the default path, getProperty still constructs the environment-variable name and queries the environment each time; with a configured list it additionally splits, trims, and allocates a new list each time. Since agent configuration is process-wide and effectively immutable, resolve this list once during service initialization and reuse it to avoid adding configuration parsing to this hot path.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 37330751979]:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #122.09952003.223.46579.51
Total Run22.102003.223.46579.51
Additional overhead from Eco CIN/A9.896.511.52

🌳 CO2 Data:
City: CONSTANT, Lat: , Lon:
IP:
CO₂ from energy is: 0.185854300 g
CO₂ from manufacturing (embodied carbon) is: 0.165342205 g
Carbon Intensity for this location: 334 gCO₂eq/kWh
SCI: 0.351197 gCO₂eq / pipeline run emitted

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Eco CI Output - Old Energy Estimation

Eco CI Output [RUN-ID: 37331132309]:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #126.63862305.973.77611.09
Total Run26.642305.973.77611.09
Additional overhead from Eco CIN/A12.527.451.68

🌳 CO2 Data:
City: CONSTANT, Lat: , Lon:
IP:
CO₂ from energy is: 0.213942698 g
CO₂ from manufacturing (embodied carbon) is: 0.174352415 g
Carbon Intensity for this location: 334 gCO₂eq/kWh
SCI: 0.388295 gCO₂eq / pipeline run emitted

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The formulas, unit conversions, cloud normalization, filtering behavior, documentation, and tests are consistent.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Eco CI Output [RUN-ID: 37334264144]:

Label🖥 avg. CPU utilization [%]🔋 Total Energy [Joules]🔌 avg. Power [Watts]Duration [Seconds]
Measurement #125.51052371.33.69642.91
Total Run25.512371.303.69642.91
Additional overhead from Eco CIN/A11.327.161.58

🌳 CO2 Data:
City: CONSTANT, Lat: , Lon:
IP:
CO₂ from energy is: 0.220003796 g
CO₂ from manufacturing (embodied carbon) is: 0.183431100 g
Carbon Intensity for this location: 334 gCO₂eq/kWh
SCI: 0.403435 gCO₂eq / pipeline run emitted

@brunnert
brunnert merged commit b3748bc into main Oct 5, 2026
2 checks passed
@brunnert
brunnert deleted the bug/FixBugReport branch October 5, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants