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 41cc8ce commit 1d86f9a
Show file tree
Hide file tree
Showing 3 changed files with 17 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.7.1
* Enhancement - Added different base user agent for Linux and Windows

## 1.7.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.7.0
1.7.1
15 changes: 13 additions & 2 deletions plugins/user_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,27 @@ import (
"github.com/aws/aws-sdk-go/aws/request"
)

const userAgentHeader = "User-Agent"
const (
userAgentHeader = "User-Agent"
// 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"
)

// CustomUserAgentHandler returns a http request handler that sets a custom user agent to all aws requests
func CustomUserAgentHandler() request.NamedHandler {
baseUserAgent := linuxBaseUserAgent
if runtime.GOOS == "windows" {
baseUserAgent = windowsBaseUserAgent
}

return request.NamedHandler{
Name: "ECSLocalEndpointsAgentHandler",
Fn: func(r *request.Request) {
currentAgent := r.HTTPRequest.Header.Get(userAgentHeader)
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))
},
}
}

0 comments on commit 1d86f9a

Please sign in to comment.