-
Notifications
You must be signed in to change notification settings - Fork 207
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
Adding Statuscode Handler to Agent Health Extension #1423
Conversation
…s from status codes
9465711
to
5dc40f4
Compare
} | ||
|
||
statsRequestHandlers, statsResponseHandlers = stats.NewHandlers(ah.logger, statsConfig, statusCodeEnabled, agentStatsEnabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could just pass in the stats pointer directly to determine if it's enabled.
statsRequestHandlers, statsResponseHandlers = stats.NewHandlers(ah.logger, statsConfig, statusCodeEnabled, agentStatsEnabled) | |
statsRequestHandlers, statsResponseHandlers = stats.NewHandlers(ah.logger, ah.cfg.Stats, statusCodeEnabled) |
existingStats.Merge(newStats) | ||
newStats = existingStats |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newStats.Merge(existingStats) also works.
var statsResponseHandlers []awsmiddleware.ResponseHandler | ||
var statsRequestHandlers []awsmiddleware.RequestHandler | ||
var statsConfig agent.StatsConfig | ||
var agentStatsEnabled bool | ||
|
||
if ah.cfg.Stats != nil { | ||
statsConfig = *ah.cfg.Stats | ||
agentStatsEnabled = true | ||
} else { | ||
agentStatsEnabled = false | ||
} | ||
|
||
statsRequestHandlers, statsResponseHandlers = stats.NewHandlers(ah.logger, statsConfig, statusCodeEnabled, agentStatsEnabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: don't need to define variables
var statsResponseHandlers []awsmiddleware.ResponseHandler | |
var statsRequestHandlers []awsmiddleware.RequestHandler | |
var statsConfig agent.StatsConfig | |
var agentStatsEnabled bool | |
if ah.cfg.Stats != nil { | |
statsConfig = *ah.cfg.Stats | |
agentStatsEnabled = true | |
} else { | |
agentStatsEnabled = false | |
} | |
statsRequestHandlers, statsResponseHandlers = stats.NewHandlers(ah.logger, statsConfig, statusCodeEnabled, agentStatsEnabled) | |
var statsConfig agent.StatsConfig | |
var agentStatsEnabled bool | |
if ah.cfg.Stats != nil { | |
statsConfig = *ah.cfg.Stats | |
agentStatsEnabled = true | |
} else { | |
agentStatsEnabled = false | |
} | |
statsRequestHandlers, statsResponseHandlers := stats.NewHandlers(ah.logger, statsConfig, statusCodeEnabled, agentStatsEnabled) |
(and you can remove the conditional from @jefchien's nit)
Stats: agent.StatsConfig{ | ||
Operations: []string{agent.AllowAllOperations}, | ||
}, | ||
Stats: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
Should IsStatusCodeEnabled
be added for consistency?
Stats: nil, | |
IsStatusCodeEnabled: false, | |
Stats: nil, |
Or remove Stats
since it should set to nil
regardless ?
Stats: nil, |
func NewTranslatorWithStatusCode(name component.DataType, operations []string, isStatusCodeEnabled bool) common.Translator[component.Config] { | ||
return &translator{ | ||
name: name.String(), | ||
operations: operations, | ||
factory: agenthealth.NewFactory(), | ||
isUsageDataEnabled: envconfig.IsUsageDataEnabled(), | ||
isStatusCodeEnabled: isStatusCodeEnabled, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we just combine this with the NewTranslator
function? Is there any case where this function is called when isStatusCodeEnabled
is false?
Or you can do this instead.
func NewTranslatorWithStatusCode(name component.DataType, operations []string, isStatusCodeEnabled bool) common.Translator[component.Config] { | |
return &translator{ | |
name: name.String(), | |
operations: operations, | |
factory: agenthealth.NewFactory(), | |
isUsageDataEnabled: envconfig.IsUsageDataEnabled(), | |
isStatusCodeEnabled: isStatusCodeEnabled, | |
} | |
} | |
func NewTranslatorWithStatusCode(name component.DataType, operations []string) common.Translator[component.Config] { | |
return &translator{ | |
name: name.String(), | |
operations: operations, | |
factory: agenthealth.NewFactory(), | |
isUsageDataEnabled: envconfig.IsUsageDataEnabled(), | |
isStatusCodeEnabled: true, | |
} | |
} |
Description of the Issue
The CloudWatch Agent lacked an
agenthealth
configuration to monitor API health by tracking HTTP status codes for specific responses. Monitoring the status codes (200
,400
,408
,419
, and429
) across all APIs is critical for diagnosing issues and ensuring comprehensive observability of API behaviors. Without this configuration, users were unable to quickly identify trends in API health metrics or correlate specific status codes with performance issues.Changes Made
Added
agenthealth
Configuration:200
: Success400
: Bad Request408
: Request Timeout419
: Authentication Timeout429
: Too Many RequestsUpdated CloudWatch Agent Configuration JSON:
agenthealth
metrics.Validated the Configuration:
Impact
Testing
200
,400
,408
,419
, and429
are captured in the header as you can see from the image below: