Skip to content

Conversation

@shalper2
Copy link

@shalper2 shalper2 commented Dec 10, 2025

Reopens 13900

Description

Modified cmd/mdatagen to allow for two new fields in the configuration yaml of metrics. These new configuration options will allow for a user to enable or disable attributes (i.e. reduce dimensionality of metrics being generated) from their collector configuration. The modified MetricsBuilder generated by mdatagen does not record disabled attributes and automatically re-aggregates metrics based on the resulting enabled set of attributes. There are four different aggregation strategies supported (sum, average, min, and max) which can be specified as a setting in config.yaml.

The changes to the config.yaml are:

receiver:
  someMetricReceiver:
    ...
    metrics:
    ...
      attributes: [<list of attributes to include for metric at runtime>] # new
      aggregation_strategy: <sum|avg|min|max> # new

Attribute requirement_level takes president over this re-aggregation and any metric attribute with a requirement_level of required cannot be disabled in this way. For more information on requirement_level please see 13913

The set of attributes provided by the user must be contained in the set of attributes defined in the metadata.yaml, including an attribute which is not defined in the metrics metadata file will fail. Also, attempting to omit an attribute defined as requirement_level: required will cause the configuration to fail and the collector not to start. Omitting the field entirely will default to the defined set of metric attributes in the metadata file with a requirement level of recommended or above.

Link to tracking issue

Fixes 10726

Testing

Generated tests have been updated to test new aggregation behavior.

Documentation

ran make gogenerate
ran make generate

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 56.22066% with 373 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.39%. Comparing base (97fcd3d) to head (38d46d4).

Files with missing lines Patch % Lines
...plereceiver/internal/metadata/generated_metrics.go 50.84% 106 Missing and 10 partials ⚠️
...mplescraper/internal/metadata/generated_metrics.go 50.00% 106 Missing and 10 partials ⚠️
...leconnector/internal/metadata/generated_metrics.go 53.36% 89 Missing and 8 partials ⚠️
cmd/mdatagen/internal/metadata.go 16.00% 21 Missing ⚠️
...pleconnector/internal/metadata/generated_config.go 83.72% 4 Missing and 3 partials ⚠️
...mplereceiver/internal/metadata/generated_config.go 85.41% 4 Missing and 3 partials ⚠️
...amplescraper/internal/metadata/generated_config.go 85.41% 4 Missing and 3 partials ⚠️
cmd/mdatagen/internal/command.go 83.33% 1 Missing and 1 partial ⚠️

❌ Your patch check has failed because the patch coverage (56.22%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14281      +/-   ##
==========================================
- Coverage   92.15%   91.39%   -0.76%     
==========================================
  Files         668      668              
  Lines       41517    42287     +770     
==========================================
+ Hits        38258    38649     +391     
- Misses       2221     2560     +339     
- Partials     1038     1078      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 10, 2025

CodSpeed Performance Report

Merging #14281 will not alter performance

Comparing shalper2:10726-reag (38d46d4) with main (97fcd3d)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 59 untouched
⏩ 20 skipped1

Footnotes

  1. 20 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@shalper2 shalper2 changed the title 10726 reag [mdatagen] Enable configurable attributes for metrics Dec 11, 2025
@shalper2 shalper2 marked this pull request as ready for review December 11, 2025 17:06
@shalper2 shalper2 requested review from a team and dmitryax as code owners December 11, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[metrics builder] Ability to re-aggregate metric by attributes

1 participant