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 ability to optionally translate metrics in signalfx exporter #477

Merged
merged 1 commit into from Jul 21, 2020

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Jul 20, 2020

Description:
This PR provides ability to translate metrics in siganlfx exporter. If an optional "send_compatible_metrics" configuration flag is enabled, signalfx exporter translates metrics before sending them out according to translation_rules configuration. If translation_rules field is not set, default translation rules are used that defined in exporter/signalfxexporter/translation/constants.go.

Only dimension renaming is added in this commit to validate the approach. Dimension translation applied to metric dimensions as well as to metadata properties update. Other translation rules will be added in the following PRs.

@dmitryax dmitryax requested a review from a team as a code owner July 20, 2020 19:51
@project-bot project-bot bot added this to In progress in Collector Jul 20, 2020
@codecov
Copy link

codecov bot commented Jul 20, 2020

Codecov Report

Merging #477 into master will increase coverage by 14.39%.
The diff coverage is 95.37%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #477       +/-   ##
===========================================
+ Coverage   71.09%   85.48%   +14.39%     
===========================================
  Files          14      181      +167     
  Lines         602     9695     +9093     
===========================================
+ Hits          428     8288     +7860     
- Misses        150     1088      +938     
- Partials       24      319      +295     
Flag Coverage Δ
#integration 71.09% <ø> (ø)
#unit 85.29% <95.37%> (?)

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

Impacted Files Coverage Δ
exporter/signalfxexporter/factory.go 88.57% <76.47%> (ø)
.../signalfxexporter/dimensions/kubernetesmetadata.go 69.23% <92.30%> (ø)
exporter/signalfxexporter/config.go 91.83% <100.00%> (ø)
exporter/signalfxexporter/dimensions/dimclient.go 82.80% <100.00%> (ø)
exporter/signalfxexporter/dpclient.go 90.47% <100.00%> (ø)
exporter/signalfxexporter/exporter.go 85.71% <100.00%> (ø)
...fxexporter/translation/metricdata_to_signalfxv2.go 99.44% <100.00%> (ø)
...xporter/signalfxexporter/translation/translator.go 100.00% <100.00%> (ø)
receiver/wavefrontreceiver/wavefront_parser.go 100.00% <0.00%> (ø)
receiver/wavefrontreceiver/factory.go 92.85% <0.00%> (ø)
... and 170 more

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 b6d0d67...b0ad531. Read the comment docs.

@dmitryax dmitryax force-pushed the enable-sfx-translations branch 2 times, most recently from f300312 to 2d68b43 Compare July 20, 2020 21:08
) (sfxDataPoints []*sfxpb.DataPoint, numDroppedTimeSeries int) {
sfxDataPoints, numDroppedTimeSeries = metricDataToSfxDataPoints(logger, md)
if metricTranslator != nil {
metricTranslator.TranslateDataPoints(sfxDataPoints)
Copy link
Member

Choose a reason for hiding this comment

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

do you think this translation and the sanitization could be moved to metricDataToSfxDataPoints? Seems like since we already iterate over the datapoints in that method, we can avoid going over it again? What do you think?

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 don't see any benefit from moving it to metricDataToSfxDataPoints to be honest. Additional iteration doesn't seem to expensive comparing to all the other logic, and I'd really like to separate out all the additional metric translations from the core data conversion logic. At some point, once backend supports all the Otel convention we should be able to remove these couple of lines, instead of going through the data conversion logic.

Copy link
Member

Choose a reason for hiding this comment

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

I agree some of the translations we may want to do would fit better as a post processing step. But in this case I guess if we do these translations before converting consumerdata.MetricsData to []*sfxpb.DataPoint, doing the mapping once per consumerdata.MetricsData is sufficient whereas later on we have to do it once per dimension per sfxpb.DataPoint. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

We cannot mutate consumerdata.MetricsData because it'll affect other exporters that user sets in the pipeline, so in that case would need to copy consumerdata.MetricsData objects before making any modifications. That's why I think it's better to do translation on final data structure that is already a copy and can be mutated.

Copy link
Member Author

@dmitryax dmitryax Jul 21, 2020

Choose a reason for hiding this comment

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

Also translation that can be done once on consumerdata.MetricsData is resource/node labels renaming only, which is pretty small part comparing to all the other translations we have to do: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/476/files#diff-a964270a3bd3600cfd48aa1d7f5f856f

Copy link
Member

Choose a reason for hiding this comment

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

I wasn't recommending we update consumerdata.MetricsData but rather do the translation alongside the consumerdata.MetricsData -> []*sfxpb.Datapoint conversion. However, if you don't think we'll gain a lot in terms efficiency, I'm good with this approach.


// TranslationRules defines a set of rules how to translate metrics to a SignalFx compatible format
// If not provided explicitly, the rules defined in translations/config/default.yaml are used.
TranslationRules []translation.Rule `mapstructure:"translation_rules"`
Copy link
Member

Choose a reason for hiding this comment

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

Could you also update the README to include these options?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@dmitryax dmitryax force-pushed the enable-sfx-translations branch 2 times, most recently from 5dffca7 to a4ce62d Compare July 21, 2020 04:32
@dmitryax dmitryax force-pushed the enable-sfx-translations branch 2 times, most recently from bfebcf0 to 346b008 Compare July 21, 2020 17:58
This commit provides ability to translate metrics in siganlfx exporter. If an optional "send_compatible_metrics" configuration flag is enabled signalfx exporter translates metrics before sending them out according to `translation_rules` configuration. If "translation_rules" field is not set, default translation rules are used that defined in exporter/signalfxexporter/translation/constants.go.

Only dimension renaming is added in this commit to validate the approach. Dimension translation applied to metric dimensions as well as to metadata properties update. Other translation rules will be added in the following commits
Copy link
Contributor

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

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

LGTM

Collector automation moved this from In progress to Reviewer approved Jul 21, 2020
@pjanotti pjanotti merged commit 8f9eb4f into open-telemetry:master Jul 21, 2020
Collector automation moved this from Reviewer approved to Done Jul 21, 2020
mxiamxia referenced this pull request in mxiamxia/opentelemetry-collector-contrib Jul 22, 2020
This change fixes inconsistencies in component interfaces. Motivation:

- Uniformness results in reduction of code that currently has to
  deal with differences.
- Processor.Start is missing and is important for allowing processors
  to communicate with the Host.

What's changed:

- Introduced Component interface.
- Unified Host interface.
- Added a Start function to processors (via Component interface).
- Start/Shutdown is now called for Processors from service start/shutdown.
- Receivers, Exporters, Processors, Extensions now embed Component interface.
- Replaced StartTraceReception/StartMetricsReception by single Start function for receivers.
- Replaced StopTraceReception/StopMetricsReception by single Shutdown function for receivers.

Note: before merging this we need to announce the change in Gitter since it
breaks existing implementations in contrib (although the fix is easy).

Resolves #477
Resolves #262
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
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants