Skip to content

Commit

Permalink
added different user agents for Linux and Windows
Browse files Browse the repository at this point in the history
Presently, we set the same user agent for both Linux and Windows i.e. `aws-fluent-bit-plugin`. In order to differentiate metrics for Windows and Linux, we are using different user agents for Linux and Windows.

We are also updating the version and adding the change log.
  • Loading branch information
Harsh Rawat authored and PettitWesley committed Nov 1, 2022
1 parent 0a51b80 commit 52f156f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 1.9.1
* Enhancement - Added different base user agent for Linux and Windows

## 1.9.0
* Feature - Add support for building this plugin on Windows. *Note that this is only support in this plugin repo for Windows compilation.*

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.0
1.9.1
13 changes: 11 additions & 2 deletions cloudwatch/cloudwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const (
logStreamInactivityTimeout = time.Hour
// Check for expired log streams every 10 minutes
logStreamInactivityCheckInterval = 10 * time.Minute
// linuxBaseUserAgent is the base user agent string used for Linux.
linuxBaseUserAgent = "aws-fluent-bit-plugin"
// windowsBaseUserAgent is the base user agent string used for Windows.
windowsBaseUserAgent = "aws-fluent-bit-plugin-windows"
)

// LogsClient contains the CloudWatch API calls used by this plugin
Expand Down Expand Up @@ -324,16 +328,21 @@ func newCloudWatchLogsClient(config OutputPluginConfig) (*cloudwatchlogs.CloudWa
func customUserAgentHandler(config OutputPluginConfig) request.NamedHandler {
const userAgentHeader = "User-Agent"

baseUserAgent := linuxBaseUserAgent
if runtime.GOOS == "windows" {
baseUserAgent = windowsBaseUserAgent
}

return request.NamedHandler{
Name: "ECSLocalEndpointsAgentHandler",
Fn: func(r *request.Request) {
currentAgent := r.HTTPRequest.Header.Get(userAgentHeader)
if config.ExtraUserAgent != "" {
r.HTTPRequest.Header.Set(userAgentHeader,
fmt.Sprintf("aws-fluent-bit-plugin-%s (%s) %s", config.ExtraUserAgent, runtime.GOOS, currentAgent))
fmt.Sprintf("%s-%s (%s) %s", baseUserAgent, config.ExtraUserAgent, runtime.GOOS, currentAgent))
} else {
r.HTTPRequest.Header.Set(userAgentHeader,
fmt.Sprintf("aws-fluent-bit-plugin (%s) %s", runtime.GOOS, currentAgent))
fmt.Sprintf("%s (%s) %s", baseUserAgent, runtime.GOOS, currentAgent))
}
},
}
Expand Down

0 comments on commit 52f156f

Please sign in to comment.