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

[exporter/tanzuobservability] Don't roll resource tags into metrics #8338

Merged
merged 3 commits into from
Apr 5, 2022

Conversation

keep94
Copy link
Contributor

@keep94 keep94 commented Mar 8, 2022

[exporter/tanzuobservability] Don't roll resource tags into metrics

Use the resourcetotelemetry helper instead.

This involves several steps:
1. attributesToTags() works like it did before. It simply concatenates multiple
pdata.AttributeMap values into a single map[string]string
2. Add newAttributeMap() to convert a map[string]string into a
pdata.AttributeMap. This way you can still concatenate a map[string]string
and a pdata.AttributeMap together into a single map[string]string because
the traces exporter still needs to do this.
3. Add getSource() function to get just the source from resource attributes.
4. Add replaceSourceTag() function which replaces "source" with "_source"
in the tags. This way the traces exporter can still work like it did before.
5. Remove the Tags field from the metricInfo type so that it just has the
metric and its source. We don't need to store the resource tags with metrics
anymore.
6. Update all attributesToTags() calls in the metrics exporter so that they
get just the metric tags.
7. Fix all metric exporter tests so that they no longer expect resource
attributes in the metrics.
8. Remove the tests that check that tags names "source" get renamed
to "_source"
9. Use the resourcetotelemetry helper.

Description:
Undo the rolling of resource tags into metrics. In the future we will rely on the resourcetotelemetry helper to do this for us.

Testing:
Unit tests. Run OTEL collector with resourcetotelemetry helper turned off (default). Run OTEL collector with resourcetotelemetry helper turned on.

@keep94 keep94 requested a review from a team as a code owner March 8, 2022 00:56
@keep94 keep94 requested a review from anuraaga March 8, 2022 00:56
@project-bot project-bot bot added this to In progress in Collector Mar 8, 2022
@keep94 keep94 force-pushed the resourcetotelemetry branch 5 times, most recently from dea7d22 to dc92dec Compare March 9, 2022 16:23
@keep94
Copy link
Contributor Author

keep94 commented Mar 10, 2022

Hello, build-and-test unit test is failing, but I don't think the failure is related to the changes I made in this PR. I think the errors below are coming from: prometheusremotewriteexporter, but this PR is for the exporter/tanzuobservabilityexporter. Maybe it is a flaky test?

=== RUN   Test_PushMetrics/WAL/staleNaNDoubleGauge_case
=== PAUSE Test_PushMetrics/WAL/staleNaNDoubleGauge_case
=== RUN   Test_PushMetrics/WAL/staleNaNIntSum_case
=== PAUSE Test_PushMetrics/WAL/staleNaNIntSum_case
=== RUN   Test_PushMetrics/WAL/staleNaNSum_case
=== PAUSE Test_PushMetrics/WAL/staleNaNSum_case
=== RUN   Test_PushMetrics/WAL/staleNaNHistogram_case
=== PAUSE Test_PushMetrics/WAL/staleNaNHistogram_case
=== RUN   Test_PushMetrics/WAL/staleNaNEmptyHistogram_case
=== PAUSE Test_PushMetrics/WAL/staleNaNEmptyHistogram_case
=== RUN   Test_PushMetrics/WAL/staleNaNSummary_case
=== PAUSE Test_PushMetrics/WAL/staleNaNSummary_case
=== CONT  Test_PushMetrics/WAL/doubleSum_case
=== CONT  Test_PushMetrics/WAL/emptyCumulativeSum_case
=== CONT  Test_PushMetrics/WAL/staleNaNSummary_case
=== CONT  Test_PushMetrics/WAL/staleNaNHistogram_case
=== CONT  Test_PushMetrics/WAL/staleNaNEmptyHistogram_case
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xd1fd6c]

Copy link
Contributor

@deosu deosu left a comment

Choose a reason for hiding this comment

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

Travis, the code changes look good to me. The only comment I can add here is that we are missing unit testing. Are there any in-direct tests we have, which are covering the code changes?

Copy link
Contributor

@thepeterstone thepeterstone left a comment

Choose a reason for hiding this comment

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

Looks good - a few minor comments. Thank you!

CHANGELOG.md Outdated Show resolved Hide resolved
exporter/tanzuobservabilityexporter/transformer.go Outdated Show resolved Hide resolved
@keep94
Copy link
Contributor Author

keep94 commented Mar 15, 2022

CHANGELOG.md changes very frequently, so I am constantly rebasing with main to resolve conflicts. Is it possible to review this this PR even though this copy of CHANGELOG.md may have conflicts?

@keep94
Copy link
Contributor Author

keep94 commented Mar 15, 2022

My build was all green before, but with my latest rebase to main, a load test is failing. The only files with conflicts during my rebase were CHANGELOG.md and go.sum. Could this test failure be unrelated to the changes made in this PR?

@keep94 keep94 force-pushed the resourcetotelemetry branch 2 times, most recently from c18ed08 to 7f0486e Compare March 17, 2022 16:07
Copy link
Member

@oppegard oppegard left a comment

Choose a reason for hiding this comment

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

Left one comment, but we'll pair-program on the full review and submit the changes.

@@ -268,7 +270,7 @@ func TestGaugeConsumerMissingValue(t *testing.T) {
}

func createMetricInfo(metric pdata.Metric) metricInfo {
mi := metricInfo{Metric: metric, Source: "test_source"}
mi := metricInfo{Metric: metric, Source: "test_source", SourceKey: "host.name"}
Copy link
Member

Choose a reason for hiding this comment

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

I think we should inline this helper so that it's easy to see the hard-coded string values that are later used as assertions in the test.

Collector automation moved this from In progress to Review in progress Mar 18, 2022
@keep94 keep94 force-pushed the resourcetotelemetry branch 2 times, most recently from a9fd93d to 3e5e916 Compare March 21, 2022 16:33
Copy link
Member

@oppegard oppegard left a comment

Choose a reason for hiding this comment

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

Looks good – thanks Travis!

@keep94
Copy link
Contributor Author

keep94 commented Mar 22, 2022

Hello. My change has been approved internally, but I see that the load tests are failing. These changes to our tanzuobservability exporter involve changing our unit tests. Can unit tests such as our unit tests for the tanzuobservability exporter affect the load tests? It seems that the load tests are failing because too much RAM is being used.

@keep94
Copy link
Contributor Author

keep94 commented Mar 22, 2022

Also, it seems that go.sum go.mod and changelog.md files change often. Is it ok if I rebase once and for all after I have your approval?

@keep94 keep94 force-pushed the resourcetotelemetry branch 2 times, most recently from ce969a4 to 5ce27df Compare March 28, 2022 23:41
@keep94
Copy link
Contributor Author

keep94 commented Mar 29, 2022

It looks like testing the deb package is failing, but I am not sure why. What is the best way to troubleshoot? It looks like the offending command is docker rm -fv otelcontribcol-deb-test >/dev/null 2>&1 || true

@jpkrohling
Copy link
Member

Can you rebase and fix the conflicts? I think the deb issue might also go away.

@keep94
Copy link
Contributor Author

keep94 commented Mar 30, 2022

@jpkrohling I rebased my PR to the latest version of main to resolve the conflicts. The debian file built, but now the load tests are failing. Could these failures be flaky?

keep94 and others added 2 commits March 31, 2022 14:00
Use the resourcetotelemetry helper instead.

This involves several steps:
1. attributesToTags() works like it did before. It simply concatenates multiple
pdata.AttributeMap values into a single map[string]string
2. Add newAttributeMap() to convert a map[string]string into a
pdata.AttributeMap. This way you can still concatenate a map[string]string
and a pdata.AttributeMap together into a single map[string]string because
the traces exporter still needs to do this.
3. Add getSource() function to get just the source from resource attributes.
4. Add replaceSourceTag() function which replaces "source" with "_source"
in the tags. This way the traces exporter can still work like it did before.
5. Remove the Tags field from the metricInfo type so that it just has the
metric and its source. We don't need to store the resource tags with metrics
anymore.
6. Update all attributesToTags() calls in the metrics exporter so that they
get just the metric tags.
7. Fix all metric exporter tests so that they no longer expect resource
attributes in the metrics.
8. Remove the tests that check that tags names "source" get renamed
to "_source"
9. Use the resourcetotelemetry helper.
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@jpkrohling
Copy link
Member

Yes, those are intermittent failures. I rebased this to account for v0.48.0 changes.

@keep94
Copy link
Contributor Author

keep94 commented Mar 31, 2022

Thank you @jpkrohling

@keep94
Copy link
Contributor Author

keep94 commented Mar 31, 2022

@jpkrohling Can this PR be merged?

@jpkrohling
Copy link
Member

Looks like it has been affected by a flaky test. I just restarted the failed jobs, will merge on green.

Collector automation moved this from Review in progress to Reviewer approved Apr 5, 2022
@jpkrohling jpkrohling merged commit 517e9c4 into open-telemetry:main Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Collector
  
Reviewer approved
Development

Successfully merging this pull request may close these issues.

None yet

5 participants