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 New Metrics For Where Customer Are Using The Agent #913

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

sethAmazon
Copy link
Contributor

@sethAmazon sethAmazon commented Oct 17, 2023

Description of the issue

CloudWatch Agent wants to collect metrics on where the agent is being run.

Description of changes

Add metrics for CloudWatch Agent mode and region provider. I did this by creating global variables for these metrics and shoving them into the config layer to be picked up by the plugins. This is because this information is only known at translation time, but we need this information at plugin runtime.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

Unit tests

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@sethAmazon sethAmazon requested a review from a team as a code owner October 17, 2023 16:07
region = SDKRegionWithCredsMap(mode, credsConfig)
regionType = agentinfo.REGION_NOT_FOUND
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if this happens, the agent will shut down before being able to reach out to the backend to send this metric. I will leave this in any way.

@codecov-commenter
Copy link

codecov-commenter commented Oct 17, 2023

Codecov Report

Attention: 37 lines in your changes are missing coverage. Please review.

Comparison is base (96d4763) 57.58% compared to head (747f0f0) 62.95%.
Report is 433 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #913      +/-   ##
==========================================
+ Coverage   57.58%   62.95%   +5.37%     
==========================================
  Files         370      325      -45     
  Lines       17548    16154    -1394     
==========================================
+ Hits        10105    10170      +65     
+ Misses       6848     5470    -1378     
+ Partials      595      514      -81     
Files Coverage Δ
cfg/commonconfig/commonconfig.go 8.00% <ø> (ø)
...md/amazon-cloudwatch-agent-config-wizard/wizard.go 50.56% <ø> (-17.50%) ⬇️
...amazon-cloudwatch-agent/amazon-cloudwatch-agent.go 2.64% <ø> (ø)
...oudwatch-agent/register_event_logger_notwindows.go 0.00% <ø> (ø)
cmd/config-translator/translator.go 0.00% <ø> (ø)
cmd/xray-migration/commands_unix.go 42.50% <ø> (ø)
cmd/xray-migration/xray-migration.go 28.87% <ø> (ø)
handlers/agentinfo/info.go 82.50% <ø> (ø)
internal/cloudwatch/unit.go 86.00% <ø> (ø)
internal/ecsservicediscovery/decoratedtask.go 87.23% <ø> (ø)
... and 19 more

... and 217 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sethAmazon
Copy link
Contributor Author

We may need to increase our header size so we do not drop logs since we are increasing the header size with this change.

@sethAmazon sethAmazon force-pushed the new-metrics branch 2 times, most recently from c38a9b1 to 3fbfdec Compare October 18, 2023 16:47
@@ -31,7 +31,7 @@ const (
LogEntryField = "value"

defaultFlushTimeout = 5 * time.Second
eventHeaderSize = 26
eventHeaderSize = 200
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to 200 at the request of @bryce-carey

@@ -96,6 +97,17 @@ func (ctx *Context) Mode() string {
return ctx.mode
}

func (ctx *Context) ShortMode() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can move to SetMode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke offline changed to suggestions

@sethAmazon sethAmazon force-pushed the new-metrics branch 3 times, most recently from 5f187b5 to 747f0f0 Compare October 23, 2023 19:59
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