Skip to content
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

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

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

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

…re processing

Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
@odubajDT odubajDT force-pushed the fix-metric-validation branch from a501483 to 47af88a Compare January 23, 2025 11:50
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
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

Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
@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
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.
2 participants