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

feat: Add option for Batch to merge results before sending. #1103

Merged
merged 3 commits into from
Apr 28, 2022

Conversation

lenny-goodell
Copy link
Member

This is needed when batching Metric data that has been transformed to
Line Protocol format.

closes #1101

Signed-off-by: Leonard Goodell [email protected]

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/app-functions-sdk-go/blob/main/.github/CONTRIBUTING.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)
    TBD

Testing Instructions

Build and run App Template service to generate metrics
Build ASC with this branch
Configure ASC metrics-profile with:

  • ExecutionOrder = "ToLineProtocol, Batch, HTTPExport"
  • MergeOnSend = "true" in Batch function parameters
  • HTTP to send to InfluxDB
    Run ASC with metrics-profile with DEBUG logging
    Verify HTTP Export reports status is 204 No Content in log file

New Dependency Instructions (If applicable)

This is needed when batching Metric data that has been transformed to
Line Protocol format.

closes edgexfoundry#1101

Signed-off-by: Leonard Goodell <[email protected]>
@@ -64,7 +64,8 @@ func (mp *MetricsProcessor) ToLineProtocol(ctx interfaces.AppFunctionContext, da
metric.Tags = append(metric.Tags, mp.additionalTags...)
}

result := metric.ToLineProtocol()
// New line is needed if the resulting metric data is batched and sent in chunks to service like InfluxDB
result := metric.ToLineProtocol() + "\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

use fmt.Sprintln() to avoid hard coded \n? :

Suggested change
result := metric.ToLineProtocol() + "\n"
result := fmt.Sprintln(metric.ToLineProtocol())

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 like it. THX!
Changed.

@lenny-goodell lenny-goodell changed the title feat: Add option for Bath to merge results before sending. feat: Add option for Batch to merge results before sending. Apr 27, 2022
Copy link
Contributor

@jim-wang-intel jim-wang-intel left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2022

Codecov Report

Merging #1103 (00467d3) into main (cad5e53) will decrease coverage by 0.07%.
The diff coverage is 53.84%.

@@            Coverage Diff             @@
##             main    #1103      +/-   ##
==========================================
- Coverage   68.56%   68.49%   -0.08%     
==========================================
  Files          37       37              
  Lines        3022     3034      +12     
==========================================
+ Hits         2072     2078       +6     
- Misses        822      827       +5     
- Partials      128      129       +1     
Impacted Files Coverage Δ
internal/app/configurable.go 70.53% <14.28%> (-0.93%) ⬇️
pkg/transforms/batch.go 91.48% <100.00%> (+0.47%) ⬆️
pkg/transforms/metrics.go 70.00% <100.00%> (ø)

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 cad5e53...00467d3. Read the comment docs.

@lenny-goodell lenny-goodell merged commit 8ff173f into edgexfoundry:main Apr 28, 2022
@lenny-goodell lenny-goodell deleted the batch-merge branch May 16, 2022 23:14
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.

[App SDK] Enhance Batch to merge data to one []byte
3 participants