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 aggregation capability to signalfx exporter translations #501

Merged

Conversation

dmitryax
Copy link
Member

Description:
We need simple aggregation capability to get machine_cpu_cores metric. For now only "count" aggregation method is needed. Later this might be moved to metrics transform processor.

@dmitryax dmitryax requested a review from a team as a code owner July 23, 2020 21:50
@dmitryax dmitryax force-pushed the aggregate-sfx-exporter branch 3 times, most recently from 9e7ddca to 8566792 Compare July 23, 2020 22:03
@codecov
Copy link

codecov bot commented Jul 23, 2020

Codecov Report

Merging #501 into master will increase coverage by 0.06%.
The diff coverage is 96.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #501      +/-   ##
==========================================
+ Coverage   85.96%   86.03%   +0.06%     
==========================================
  Files         187      187              
  Lines       10063    10142      +79     
==========================================
+ Hits         8651     8726      +75     
- Misses       1091     1093       +2     
- Partials      321      323       +2     
Flag Coverage Δ
#integration 71.09% <ø> (ø)
#unit 85.86% <96.03%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...xporter/signalfxexporter/translation/translator.go 96.19% <95.45%> (-0.83%) ⬇️
...fxexporter/translation/metricdata_to_signalfxv2.go 99.45% <100.00%> (+<0.01%) ⬆️

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 9764b90...fc3459a. Read the comment docs.

@dmitryax dmitryax changed the title Add simple aggregation capability to signalfx translations Add simple aggregation capability to signalfx exporter translations Jul 23, 2020
@dmitryax dmitryax changed the title Add simple aggregation capability to signalfx exporter translations Add aggregation capability to signalfx exporter translations Jul 23, 2020
@dmitryax dmitryax force-pushed the aggregate-sfx-exporter branch 2 times, most recently from 7bc3b31 to 5b6a503 Compare July 24, 2020 00:46
Comment on lines +313 to +319
// NOTE: Based on the usage of TranslateDataPoints we can assume that the datapoints batch []*sfxpb.DataPoint
// represents only one metric and all the datapoints can be aggregated together.
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the comment. I see that below we check the MetricName, so presumably it means the batch can contain different metrics?

Copy link
Member Author

Choose a reason for hiding this comment

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

I put a comment in the check below. Different names can potentially go from copy_metric translation rules in the actions list before aggregation.

for _, d := range dp.Dimensions {
if d.Key == dimensionKey {
if _, ok := dimValToDps[d.Value]; !ok {
dimValToDps[d.Value] = make([]*sfxpb.DataPoint, 0, len(dps)-i)
Copy link
Member

Choose a reason for hiding this comment

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

It would be worth to explain why len(dps)-i is a good idea.

result := make([]*sfxpb.DataPoint, 0, len(dimValToDps))
for _, dps := range dimValToDps {
dp := proto.Clone(dps[0]).(*sfxpb.DataPoint)
dp.Dimensions = getCommonDimensions(dps)
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 we need to calculate common dimensions? Aren't we reducing this metric to only contain the single dimension across which we aggregate?

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, this is a bit unusual for aggregations, but since we are getting a bunch of common dimensions from resource attributes like k8s.node.name, k8s.cluster.name etc, we would like to keep them as is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Instead , we could explicitly specify list of dimensions to aggregate across

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm changing it to use this approach ^ . Please do not review yet

Copy link
Member Author

Choose a reason for hiding this comment

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

@tigrannajaryan I refactored it accordingly. PTAL

Copy link
Member

@pmcollins pmcollins left a comment

Choose a reason for hiding this comment

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

Code changes LGTM

exporter/signalfxexporter/translation/translator.go Outdated Show resolved Hide resolved
@@ -65,6 +65,28 @@ const (
// k8s.pod.network.io{direction="receive"} -> pod_network_receive_bytes_total{}
// k8s.pod.network.io{direction="transmit"} -> pod_network_transmit_bytes_total{}
ActionSplitMetric Action = "split_metric"

Copy link
Member

Choose a reason for hiding this comment

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

This explanation is excellent. Just a couple of grammar nits

exporter/signalfxexporter/translation/translator.go Outdated Show resolved Hide resolved
exporter/signalfxexporter/translation/translator.go Outdated Show resolved Hide resolved
exporter/signalfxexporter/translation/translator.go Outdated Show resolved Hide resolved
@@ -266,6 +344,86 @@ func (mp *MetricTranslator) TranslateDimension(orig string) string {
return orig
}

// aggregateDatapoints aggregates datapoints assuming that they have
// the same Timestamp, MetricType, Metric and Source fields.
func aggregateDatapoints(
Copy link
Member

Choose a reason for hiding this comment

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

Might be nice to have a unit test just for this fcn and getCommonDimensions but they're already covered, so totally up to you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, I'd like to use the same test framework with defined input/output and get it covered through TranslateDataPoints

@dmitryax
Copy link
Member Author

@tigrannajaryan @pmcollins comments addressed

We need simple aggregation capability to get machine_cpu_cores metric. For now only "count" aggregation method is needed
@tigrannajaryan tigrannajaryan merged commit c8eea78 into open-telemetry:master Jul 24, 2020
dyladan referenced this pull request in dynatrace-oss-contrib/opentelemetry-collector-contrib Jan 29, 2021
…501) (#515)

* Added support to opencensusreceiver for listening on a unix domain socket (#400)

* Update testbed to include new parameter in opencensusreceiver

* Removed unneeded omit_empty attribute.
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