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

Add misc changes for metrics correctness #1453

Merged
merged 1 commit into from
Aug 13, 2020
Merged

Add misc changes for metrics correctness #1453

merged 1 commit into from
Aug 13, 2020

Conversation

pmcollins
Copy link
Member

@pmcollins pmcollins commented Jul 28, 2020

This is in support of issue #652.

This change:

  • Adds support for setting a prefix on every metric name for metrics generated for testing. Doing so will be necessary to distinguish metric names for metrics generated from different rows in a PICT file.
  • Exports some fields and functions in the correctness package so that they can be used from the metrics subdirectory/package.
  • Replaces argument types that refer to the struct MockTraceConsumer and MockMetricsConsumer with the interfaces MetricsDualConsumer and TraceDualConsumer, both of which can consume old and new metrics/traces. This will be used in a forthcoming TestHarness type that implements MetricsDualConsumer.
  • Adds a PrometheusDataReceiver and a PrometheusDataSender so that Prometheus correctness can be tested.

@codecov
Copy link

codecov bot commented Jul 28, 2020

Codecov Report

Merging #1453 into master will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1453      +/-   ##
==========================================
+ Coverage   91.42%   91.44%   +0.01%     
==========================================
  Files         248      248              
  Lines       17219    17226       +7     
==========================================
+ Hits        15743    15752       +9     
+ Misses       1064     1063       -1     
+ Partials      412      411       -1     
Impacted Files Coverage Δ
internal/goldendataset/metric_gen.go 100.00% <100.00%> (ø)
internal/goldendataset/pict_metric_gen.go 96.15% <100.00%> (+0.07%) ⬆️
translator/internaldata/resource_to_oc.go 87.50% <0.00%> (+2.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e68440e...ed33e98. Read the comment docs.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Reviewed first 2 files, then got stuck. Would be good to:

  1. Either split in smaller PRs with 1 line description
  2. OR Add more detailed description about what to expect in this PR :)

internal/goldendataset/metric_gen.go Show resolved Hide resolved
return NewMetricGenerator().GenMetricDataFromCfg(cfg)
}

type MetricGenerator struct {
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be exported?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

metricID int
}

func NewMetricGenerator() *MetricGenerator {
Copy link
Member

Choose a reason for hiding this comment

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

same, can this be package private?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@pmcollins
Copy link
Member Author

pmcollins commented Jul 29, 2020

@bogdandrutu Thanks for taking a look. I have added a more detailed explanation of the contents of this PR.

Comment on lines +81 to +87
type metricGenerator struct {
metricID int
}

func newMetricGenerator() *metricGenerator {
return &metricGenerator{}
}
Copy link
Member

Choose a reason for hiding this comment

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

Is this whole type needed? You can just pass around metricID.

Copy link
Member Author

@pmcollins pmcollins Aug 6, 2020

Choose a reason for hiding this comment

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

metricID is a counter that gets incremented every time a new metric is generated. It's used to create unique metric names. I guess we could hold and increment the current count on the stack, but it would be a more complicated solution than this.

testbed/correctness/util.go Outdated Show resolved Hide resolved
@bogdandrutu
Copy link
Member

Rebase?

@pmcollins
Copy link
Member Author

Rebase?

Done.

Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Making progress.

@@ -172,13 +173,20 @@ func (mb *MockBackend) ConsumeMetricOld(md consumerdata.MetricsData) {
}
}

type TraceDualConsumer interface {
consumer.TraceConsumer
consumer.TraceConsumerOld
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need the Old interface?

Copy link
Member Author

Choose a reason for hiding this comment

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

To answer this and the next question, the old interface is used by Prometheus and OpenCensus on the metrics side, and Zipkin on the tracing side.

Copy link
Member

Choose a reason for hiding this comment

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

That is no longer true :) for 2 out of 3 :)

@@ -243,29 +251,28 @@ func (tc *MockTraceConsumer) ConsumeTraceData(ctx context.Context, td consumerda
return nil
}

type MetricsDualConsumer interface {
consumer.MetricsConsumer
consumer.MetricsConsumerOld
Copy link
Member

Choose a reason for hiding this comment

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

Same.

}

var _ TraceDualConsumer = (*MockTraceConsumer)(nil)

type MockTraceConsumer struct {
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be public?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it will be used by the test harness in the metrics package as a placeholder trace consumer.

testbed/testbed/validator.go Outdated Show resolved Hide resolved
@bogdandrutu
Copy link
Member

Please rebase

@pmcollins
Copy link
Member Author

Please rebase

Done.

@bogdandrutu bogdandrutu merged commit 9c96fe2 into open-telemetry:master Aug 13, 2020
MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
…1453)

* Bump github.com/stretchr/testify from 1.6.1 to 1.7.0

Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.6.1 to 1.7.0.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](stretchr/testify@v1.6.1...v1.7.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Auto-fix go.sum changes in dependent modules

* Auto-fix go.sum changes in dependent modules

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Troels51 pushed a commit to Troels51/opentelemetry-collector that referenced this pull request Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants