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] Metric tests are broken #8393

Closed
pmm-sumo opened this issue Mar 13, 2022 · 12 comments
Closed

[processor/attributes] Metric tests are broken #8393

pmm-sumo opened this issue Mar 13, 2022 · 12 comments
Assignees
Labels
bug Something isn't working closed as inactive good first issue Good for newcomers help wanted Extra attention is needed priority:p3 Lowest processor/attributes Attributes processor Stale

Comments

@pmm-sumo
Copy link
Contributor

Describe the bug
generateMetricData function does not generate actual data points. When it is fixed to generate some data points, the tests fail

What version did you use?
The bug was introduced in #8111

Additional context
Thanks to @hughsimpson for spotting this while working on #7930

@pmm-sumo pmm-sumo added the bug Something isn't working label Mar 13, 2022
@pmm-sumo pmm-sumo changed the title [processor/attributes] metric tests are broken [processor/attributes] Metric tests are broken Mar 13, 2022
@codeboten codeboten added the needs triage New item requiring triage label Sep 16, 2022
@dmitryax dmitryax added priority:p3 Lowest processor/attributes Attributes processor and removed needs triage New item requiring triage labels Nov 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2022

Pinging code owners: @boostchicken. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@dmitryax dmitryax added help wanted Extra attention is needed good first issue Good for newcomers labels Nov 8, 2022
@mattsains
Copy link
Contributor

mattsains commented Nov 16, 2022

I added the following lines to the generateMetricData function and caused TestAttributes_FilterMetrics to fail:

g := m.SetEmptyGauge()
dp := g.DataPoints().AppendEmpty()
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.UnixMicro(0)))
dp.SetIntValue(7)

The reason the tests pass without this change is that the attrs parameter to generateMetricData is only used when m is not empty (has type field set). Otherwise, the attributes are never set on any Metrics object and all the tests pass trivially.

I think the bug being surfaced by fixing this problem is here: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/internal/coreinternal/processor/filtermetric/filtermetric.go#L33-L36 where there is a case for an expression matcher, a name matcher, but there is no usage of the ResourceAttributes field on MatchProperties.

Therefore, no matching happens based on this filter:

Resources: []filterconfig.Attribute{{Key: "name", Value: "^[^i].*"}}

I'm not very familiar with the code base, so I was hoping someone (@pmm-sumo ?) could verify my hypothesis. It seems like the function I linked above would need to be modified to add functionality to return a resource_metric when config.ResourceAttributes is not nil. Does this make sense?

@mattsains
Copy link
Contributor

Updated link to suspected bug location (I think this is where it moved to):

if mp.MatchType == Expr {
if len(mp.Expressions) == 0 {
return nil, nil
}
return newExprMatcher(mp.Expressions)
}
if len(mp.MetricNames) == 0 {
return nil, nil
}
return newNameMatcher(mp)

@mattsains
Copy link
Contributor

It's not just resources, the metric data point attributes filter is also non-functional

@mattsains
Copy link
Contributor

mattsains commented Dec 13, 2022

I've created a draft PR that implements both resources and data point attribute filtering: #17017

I published this PR to take advantage of Cunningham's law. Let me know what you think!

@mattsains
Copy link
Contributor

@boostchicken I think you might be an owner for this processor? If so, could you provide some feedback on what I have so far? Also, I was not sure what to do with the services filter field, which the documentation implies should work for metrics, but I'm not sure what field within the metric structure that is referring to specifically.

@mattsains
Copy link
Contributor

Also, please assign me to this issue

@github-actions
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Feb 21, 2023
@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2023

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 5, 2023
@dmitryax dmitryax reopened this Aug 14, 2023
@github-actions
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

  • issue: Github issue template generation code needs this to generate the corresponding labels.
  • processor/attributes: @boostchicken

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Oct 16, 2023
@atoulme atoulme removed the Stale label Dec 6, 2023
Copy link
Contributor

github-actions bot commented Feb 5, 2024

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Feb 5, 2024
Copy link
Contributor

github-actions bot commented Apr 5, 2024

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working closed as inactive good first issue Good for newcomers help wanted Extra attention is needed priority:p3 Lowest processor/attributes Attributes processor Stale
Projects
None yet
Development

No branches or pull requests

5 participants