mlco2 / mlco2/codecarbon

RFE: Add support for OpenTelemetry metrics and tracing

Open
#504 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement P3
Dominant language
Python
Stars
1.9k
Forks
323
Avg merge
1d 12h
Merged PRs (30d)
12

Description

Description

This RFE (Request for Enhancement) is to add the ability for codecarbon to allow collection of OpenTelemetry traces and correlation with codecarbon metrics. See
https://opentelemetry.io/docs/specs/otel/metrics/

This will allow existing codecarbon users to view codecarbon metrics alongside their regular observability tools such as Jaeger, Honeycomb etc. (thanks to the OpenTelemetry standard). This allows per-trace carbon tracking with additional context in addition to trend analysis.

Proposed Implementation

The proposed implementation is to follow a similar pattern to the Prometheus feature:

  • Add save_metrics_to_otel and save_traces_to_otel flags to the track_emissions decorator. These flags will govern if full traces are collected along with metrics and persisted in the OpenTelemetry collector.
  • Allow configuration of OTel Collector

I will add a more detailed technical proposal and MR if you agree this is a feature worth implementing. I'm very open to discussion and ideas, and look forward to contributing in this space.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Prometheus feature and the track_emissions decorator, which the issue identifies as the implementation pattern. Define the OpenTelemetry collector configuration and the required metrics and trace behavior; done means the proposed flags support collection and persistence with trace correlation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.