Skip to content

Commit

Permalink
Add hostRole config option (#931)
Browse files Browse the repository at this point in the history
Allow users to configure a role for a host. It's not used a lot in the
product yet, but we generate a metric for it and we can do some more
stuff with it in the future.

Part of appsignal/appsignal-agent#1020
  • Loading branch information
tombruijn authored Aug 25, 2023
1 parent 8cfb06c commit 5cdf57b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changesets/add-role-config-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "add"
---

Add the `hostRole` config option. This config option can be set per host to generate some metrics automatically per host and possibly do things like grouping in the future.
3 changes: 3 additions & 0 deletions src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ describe("Configuration", () => {
expect(env("_APPSIGNAL_FILES_WORLD_ACCESSIBLE")).toEqual("true")
expect(env("_APPSIGNAL_FILTER_DATA_KEYS")).toBeUndefined()
expect(env("_APPSIGNAL_HOSTNAME")).toBeUndefined()
expect(env("_APPSIGNAL_HOST_ROLE")).toBeUndefined()
expect(env("_APPSIGNAL_HTTP_PROXY")).toBeUndefined()
expect(env("_APPSIGNAL_IGNORE_ACTIONS")).toBeUndefined()
expect(env("_APPSIGNAL_IGNORE_ERRORS")).toBeUndefined()
Expand Down Expand Up @@ -314,6 +315,7 @@ describe("Configuration", () => {
filterParameters: ["password", "confirm_password"],
filterSessionData: ["key1", "key2"],
hostname: "MyHostName",
hostRole: "host role",
httpProxy: "http://localhost",
ignoreActions: ["MyAction", "MyOtherAction"],
ignoreErrors: ["MyError", "MyOtherError"],
Expand Down Expand Up @@ -341,6 +343,7 @@ describe("Configuration", () => {
)
expect(env("_APPSIGNAL_FILTER_SESSION_DATA")).toEqual("key1,key2")
expect(env("_APPSIGNAL_HOSTNAME")).toEqual("MyHostName")
expect(env("_APPSIGNAL_HOST_ROLE")).toEqual("host role")
expect(env("_APPSIGNAL_HTTP_PROXY")).toEqual("http://localhost")
expect(env("_APPSIGNAL_IGNORE_ACTIONS")).toEqual(
"MyAction,MyOtherAction"
Expand Down
3 changes: 3 additions & 0 deletions src/config/configmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const ENV_TO_KEY_MAPPING: Record<string, keyof AppsignalOptions> = {
APPSIGNAL_FILTER_PARAMETERS: "filterParameters",
APPSIGNAL_FILTER_SESSION_DATA: "filterSessionData",
APPSIGNAL_HOSTNAME: "hostname",
APPSIGNAL_HOST_ROLE: "hostRole",
APPSIGNAL_HTTP_PROXY: "httpProxy",
APPSIGNAL_IGNORE_ACTIONS: "ignoreActions",
APPSIGNAL_IGNORE_ERRORS: "ignoreErrors",
Expand Down Expand Up @@ -50,6 +51,7 @@ export const PRIVATE_ENV_MAPPING: Record<string, keyof AppsignalOptions> = {
_APPSIGNAL_FILTER_PARAMETERS: "filterParameters",
_APPSIGNAL_FILTER_SESSION_DATA: "filterSessionData",
_APPSIGNAL_HOSTNAME: "hostname",
_APPSIGNAL_HOST_ROLE: "hostRole",
_APPSIGNAL_HTTP_PROXY: "httpProxy",
_APPSIGNAL_IGNORE_ACTIONS: "ignoreActions",
_APPSIGNAL_IGNORE_ERRORS: "ignoreErrors",
Expand Down Expand Up @@ -85,6 +87,7 @@ export const JS_TO_RUBY_MAPPING: Record<keyof AppsignalOptions, string> = {
filterParameters: "filter_parameters",
filterSessionData: "filter_session_data",
hostname: "hostname",
hostRole: "host_role",
httpProxy: "http_proxy",
ignoreActions: "ignore_actions",
ignoreErrors: "ignore_errors",
Expand Down
1 change: 1 addition & 0 deletions src/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type AppsignalOptions = {
filterParameters: string[]
filterSessionData: string[]
hostname: string
hostRole: string
httpProxy: string
ignoreActions: string[]
ignoreErrors: string[]
Expand Down

0 comments on commit 5cdf57b

Please sign in to comment.