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

Support bool metrics #637

Merged
merged 21 commits into from Jun 30, 2023
Merged

Conversation

psx95
Copy link
Contributor

@psx95 psx95 commented Jun 1, 2023

PR to add support for Bool metrics in exporter/collector.

This currently adds support for boolean valued metrics in collector exporter.

Testing

  • These changes are also being tested on a newly created collector based example, this example will be added in a separate PR.

#624

@psx95 psx95 requested a review from aabmass June 2, 2023 14:19
@codecov
Copy link

codecov bot commented Jun 2, 2023

Codecov Report

Merging #637 (b9e9250) into main (bd431a2) will increase coverage by 1.95%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #637      +/-   ##
==========================================
+ Coverage   66.44%   68.39%   +1.95%     
==========================================
  Files          36       36              
  Lines        4297     4559     +262     
==========================================
+ Hits         2855     3118     +263     
+ Misses       1314     1288      -26     
- Partials      128      153      +25     
Impacted Files Coverage Δ
...tor/integrationtest/testcases/testcases_metrics.go 100.00% <100.00%> (ø)
exporter/collector/metrics.go 72.72% <100.00%> (+5.43%) ⬆️

... and 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

exporter/collector/metrics.go Outdated Show resolved Hide resolved
exporter/collector/metrics.go Outdated Show resolved Hide resolved
exporter/collector/metrics.go Show resolved Hide resolved
exporter/collector/metrics.go Outdated Show resolved Hide resolved
exporter/collector/metrics.go Outdated Show resolved Hide resolved
@aabmass
Copy link
Contributor

aabmass commented Jun 2, 2023

Can you add a fixture based integration test for this? It should make it really easy to test your changes against the real API as well. Directions in https://github.com/GoogleCloudPlatform/opentelemetry-operations-go/blob/main/exporter/collector/integrationtests.md

@psx95 psx95 marked this pull request as ready for review June 22, 2023 01:32
@psx95 psx95 requested a review from a team as a code owner June 22, 2023 01:32
@psx95 psx95 requested review from punya and damemi and removed request for punya June 22, 2023 01:33
@psx95 psx95 marked this pull request as draft June 22, 2023 15:41
@psx95 psx95 marked this pull request as ready for review June 29, 2023 14:49
@psx95 psx95 changed the title WIP: Support bool metrics Support bool metrics Jun 29, 2023
exporter/collector/metrics.go Outdated Show resolved Hide resolved
Comment on lines 1227 to 1232
_, supportedType := me.convertMetricKindToBoolIfSupported(m.Gauge().DataPoints().At(0), kind, m.Unit())
if supportedType != metricpb.MetricDescriptor_VALUE_TYPE_UNSPECIFIED {
typ = supportedType
} else {
typ = metricPointValueType(m.Gauge().DataPoints().At(0).ValueType())
}
Copy link
Member

Choose a reason for hiding this comment

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

would it make sense to move the same kind of check that convertMetricKindToBoolIfSupported does into metricPointValueType? so then the switch statement would be something like:

switch pt {
case pmetric.NumberDataPointValueTypeInt:
  if boolUnitPresent && metricKind == metricpb.MetricDescriptor_GAUGE {
    return metricpb.MetricDescriptor_BOOL
  }
  return metricpb.MetricDescriptor_INT64
}

you could add a similar error log but it's already going to be covered by the actual data point conversion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we would have to pass all those extra parameters - kind and and unit to metricPointValueType as well.
Currently this method seems simple to me and serves a single purpose - convert pmetric.NumberDataPointValueType to its equivalent cloud monitoring type. I can see it going either way if you feel strongly about this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just removed the support for Bool metrics from non-monotonic sum (which was interpreted as GUAGE) as per the spec we have.

So now moving the check to metricPointValueType would only simplify switch statement for a single case and I feel it may not increase readability by a lot.

Co-authored-by: Mike Dame <mikedame@google.com>
@psx95 psx95 force-pushed the support-bool-metrics branch 2 times, most recently from 4b02365 to 5f8812c Compare June 30, 2023 00:13
exporter/collector/metrics.go Outdated Show resolved Hide resolved
exporter/collector/metrics.go Outdated Show resolved Hide resolved
exporter/collector/metrics.go Outdated Show resolved Hide resolved
exporter/collector/metrics.go Show resolved Hide resolved
psx95 and others added 2 commits June 30, 2023 12:31
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
@psx95 psx95 merged commit 207e0d8 into GoogleCloudPlatform:main Jun 30, 2023
25 checks passed
@psx95 psx95 deleted the support-bool-metrics branch July 5, 2023 14:11
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.

None yet

3 participants