Skip to content

Add exponential histogram support to CloudWatch PMD Exporter #1677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dricross
Copy link
Contributor

@dricross dricross commented May 8, 2025

Description of the issue

The Cloudwatch/PMD exporter currently drops all exponential histogram metrics.

Description of changes

Adds support for exponential histogram to the CloudWatch/PMD exporter

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Setup something to what our OTLP -> AMP test does (see test repo).

Agent config:

{
  "agent": {
    "metrics_collection_interval": 15,
    "run_as_user": "root",
    "debug": true
  },
  "metrics": {
    "metrics_collected": {
      "otlp": {
        "http_endpoint": "127.0.0.1:1234"
      }
    }
  }
}

Use OTLP metrics and OTLP pusher from test repo to generate exponential histogram metrics.

In CloudWatch, we can see:

  • min: 0
  • max: 5
  • sample count: 72
  • Sum: 240

image

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@dricross dricross requested a review from a team as a code owner May 8, 2025 20:55
@dricross dricross force-pushed the dricross/exponentialhistogram branch from 49857cf to 97c4271 Compare May 16, 2025 21:08
@dricross dricross force-pushed the dricross/exponentialhistogram branch from 97c4271 to 995902e Compare May 16, 2025 21:08
return d.AddEntryWithUnit(value, weight, "")
}

func (d *ExpHistogramDistribution) AddDistribution(other *ExpHistogramDistribution) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we trying to match the Distribution interface? It doesn't look like this would satisfy the interface as it is now. We would have to make the Distribution interface generic.

@@ -82,7 +83,7 @@ func ConvertOtelNumberDataPoints(
unit string,
scale float64,
entity cloudwatch.Entity,
) []*aggregationDatum {
) []*aggregationDatum { //nolint:revive
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Instead of ignoring the lint, can we just not export the function? It doesn't look like it's used outside of this package.

}
// Assume function pointer is valid.
ad.expHistDistribution = exph.NewExpHistogramDistribution()
ad.expHistDistribution.ConvertFromOtel(dp, unit)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: If we store the unit in the MetricDatum already, why do we need to store it in the distribution?

return datums
}

func (c *CloudWatch) buildMetricDataumExph(metric *aggregationDatum, dimensionsList [][]*cloudwatch.Dimension) []*cloudwatch.MetricDatum {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Typo

Suggested change
func (c *CloudWatch) buildMetricDataumExph(metric *aggregationDatum, dimensionsList [][]*cloudwatch.Dimension) []*cloudwatch.MetricDatum {
func (c *CloudWatch) buildMetricDatumExph(metric *aggregationDatum, dimensionsList [][]*cloudwatch.Dimension) []*cloudwatch.MetricDatum {

Copy link
Contributor

This PR was marked stale due to lack of activity.

@github-actions github-actions bot added the Stale label May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants