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

Enhance EMFExporter for Metrics Batching in AWS EMF Logs #2271

Merged
merged 5 commits into from
Feb 8, 2021

Conversation

mxiamxia
Copy link
Member

@mxiamxia mxiamxia commented Feb 2, 2021

Description:
We sent a large PR #1891 to support batching the metrics on the same dimensions for AWS EMF Log request to save the customers' billing cost and request throughput. At the same time, there was a fairly large code refactor on EMFExporter. For better code review purpose, I plan to split #1891 to 2 PRs. (This is PR#1)

In this PR, We refactored EMFExporter without introducing any new feature. For each OTel metrics data point, we defined DataPoint file, it wraps pdata.DataPointSlice to the custom structures for each type of metric data point. we also moved the metric data handling functions - data conversion and rate calculation to datapoint.
It also fixed the metric timestamp bug.

@mxiamxia mxiamxia requested a review from anuraaga as a code owner February 2, 2021 08:04
@mxiamxia mxiamxia requested a review from a team February 2, 2021 08:04
@mxiamxia
Copy link
Member Author

mxiamxia commented Feb 2, 2021

@anuraaga PTAL - Thanks!

Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

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

Thanks!

exporter/awsemfexporter/datapoint.go Outdated Show resolved Hide resolved
exporter/awsemfexporter/datapoint.go Outdated Show resolved Hide resolved
return
}

rateKeyParams := map[string]string{
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this should be a struct, not map

exporter/awsemfexporter/util.go Outdated Show resolved Hide resolved
}
cWNamespace := getNamespace(rm, config.Namespace)
logGroup, logStream := getLogInfo(rm, cWNamespace, config)
timestampMs := time.Now().UnixNano() / int64(time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does time.Now() / time.Millisecond work?

Copy link
Member Author

Choose a reason for hiding this comment

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

it looks not, time.Now() returns Time struct that can't be divided, and it seems timestampMs := time.Now().UnixNano() / int64(time.Millisecond) is pretty common practice for getting current timestamp in MS. :)

"testing"
"time"

metricspb "github.com/census-instrumentation/opencensus-proto/gen-go/metrics/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we still using opencensus somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, we still reply on opencensus and internaldata.OCToMetrics(oc) to generate OTel Metrics test data in some of metrics exporter test cases. We'll create a specific PR for the test data migration.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit worried about going 1.0 with this, what if the metrics change drastically? I guess not but we need to confirm this is safe, or migrate soon. We probably were supposed to have been migrated a while ago really.

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 see. It'll be a problem If no one maintains internaldata.OCToMetrics(oc) for the new Metrics updates. I see there are a few metrics components are creating test data in this way for unit tests. I can create an issue for it to call out the problem.

@mxiamxia mxiamxia requested a review from anuraaga February 4, 2021 05:35
@codecov
Copy link

codecov bot commented Feb 4, 2021

Codecov Report

Merging #2271 (3ccd00c) into main (65673ad) will increase coverage by 0.03%.
The diff coverage is 99.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2271      +/-   ##
==========================================
+ Coverage   90.69%   90.72%   +0.03%     
==========================================
  Files         399      400       +1     
  Lines       19802    19879      +77     
==========================================
+ Hits        17959    18036      +77     
  Misses       1382     1382              
  Partials      461      461              
Flag Coverage Δ
integration 69.33% <ø> (ø)
unit 89.54% <99.00%> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
exporter/awsemfexporter/util.go 94.44% <90.00%> (-5.56%) ⬇️
exporter/awsemfexporter/datapoint.go 100.00% <100.00%> (ø)
...er/awsemfexporter/mapwithexpiry/map_with_expiry.go 100.00% <100.00%> (ø)
exporter/awsemfexporter/metric_translator.go 98.23% <100.00%> (+0.20%) ⬆️

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 65673ad...3ccd00c. Read the comment docs.

@mxiamxia
Copy link
Member Author

mxiamxia commented Feb 4, 2021

The build-publish failures are not related to the changes in this PR.

@mxiamxia
Copy link
Member Author

mxiamxia commented Feb 8, 2021

Hi @tigrannajaryan @bogdandrutu , Please help to review and merge the changes. Thanks.

@tigrannajaryan
Copy link
Member

Approved by codeowner, merging.

@tigrannajaryan tigrannajaryan merged commit 27dbdd3 into open-telemetry:main Feb 8, 2021
pmatyjasek-sumo referenced this pull request in pmatyjasek-sumo/opentelemetry-collector-contrib Apr 28, 2021
We sent a large PR open-telemetry#1891 to support batching the metrics on the same dimensions for AWS EMF Log request to save the customers' billing cost and request throughput. At the same time, there was a fairly large code refactor on EMFExporter. For better code review purpose, I plan to split open-telemetry#1891  to 2 PRs. (This is PR#1)

In this PR, We refactored EMFExporter without introducing any new feature. For each OTel metrics data point, we defined `DataPoint` file, it wraps `pdata.DataPointSlice` to the custom structures for each type of metric data point. we also moved the metric data handling functions - data conversion and rate calculation to `datapoint`. 
It also fixed the metric `timestamp` bug.
ljmsc referenced this pull request in ljmsc/opentelemetry-collector-contrib Feb 21, 2022
* move Descriptor to sdkapi, add test

* rename Descriptor to sdkapi

* precommit

* Move the rest of the sdkapi

* use alias for Observation and Measurement

* Changelog

* pr num

* comment Measurement and Observation

* swap comments

* move->moved
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.

4 participants