Skip to content

[processor/attributes] validate metrics configuration parameters before processing #37435

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

Merged
merged 8 commits into from
Mar 11, 2025

Conversation

odubajDT
Copy link
Contributor

@odubajDT odubajDT commented Jan 23, 2025

Description

Add validation for metrics-only configuration parameters

Link to tracking issue

Fixes #36077

if len(mp.MetricNames) > 0 {
return errors.New("metric_names should not be specified for trace spans")
}

Copy link
Contributor Author

@odubajDT odubajDT Jan 23, 2025

Choose a reason for hiding this comment

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

According to the documentation, metric_names should be allowed only for metrics

@@ -176,7 +182,7 @@ func (mp *MatchProperties) ValidateForSpans() error {

// ValidateForLogs validates properties for logs.
func (mp *MatchProperties) ValidateForLogs() error {
if len(mp.SpanNames) > 0 || len(mp.Services) > 0 || len(mp.SpanKinds) > 0 {
if len(mp.SpanNames) > 0 || len(mp.Services) > 0 || len(mp.SpanKinds) > 0 || len(mp.MetricNames) > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the documentation, metric_names should be allowed only for metrics

@@ -193,8 +193,8 @@ must be specified with a non-empty value for a valid configuration. The `log_bod
- For logs, one of `log_bodies`, `log_severity_texts`, `log_severity_number`, `attributes`, `resources`
or `libraries` must be specified with a non-empty value for a valid configuration. The `span_names`,
`span_kinds`, `metric_names` and `services` fields are invalid.
- For metrics, `metric_names` must be specified with a valid non-empty value for
a valid configuration. The `span_names`, `span_kinds`, `resources`, `log_bodies`, `log_severity_texts`,
- For metrics, one of `metric_names` or `resources` must be specified with a valid non-empty value for
Copy link
Contributor Author

Choose a reason for hiding this comment

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

resources are valid for metrics, see ResourceAttributes in the creation of MetricMatchProperties from MatchProperties

@odubajDT odubajDT marked this pull request as ready for review January 23, 2025 13:05
@odubajDT odubajDT requested a review from a team as a code owner January 23, 2025 13:05
Copy link
Contributor

github-actions bot commented Feb 7, 2025

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 7, 2025
@odubajDT
Copy link
Contributor Author

odubajDT commented Feb 7, 2025

not stale

@github-actions github-actions bot removed the Stale label Feb 8, 2025
@odubajDT odubajDT force-pushed the fix-metric-validation branch from 48541aa to d3c8021 Compare February 11, 2025 13:18
odubajDT added 4 commits March 3, 2025 16:43
Signed-off-by: odubajDT <[email protected]>
Signed-off-by: odubajDT <[email protected]>
Signed-off-by: odubajDT <[email protected]>
@odubajDT odubajDT force-pushed the fix-metric-validation branch from 4c01127 to 801cd1b Compare March 3, 2025 15:44
@odubajDT odubajDT requested a review from evan-bradley March 5, 2025 13:55
Copy link
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

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

LGTM thanks!

@atoulme atoulme merged commit ceeb462 into open-telemetry:main Mar 11, 2025
156 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 11, 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.

[processor/attributes] Configuration options meant for traces-only should not pass validation on metrics.
4 participants