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 host_role config option #990

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 `host_role` 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 lib/appsignal/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Config
"APPSIGNAL_FILTER_PARAMETERS" => :filter_parameters,
"APPSIGNAL_FILTER_SESSION_DATA" => :filter_session_data,
"APPSIGNAL_HOSTNAME" => :hostname,
"APPSIGNAL_HOST_ROLE" => :host_role,
"APPSIGNAL_HTTP_PROXY" => :http_proxy,
"APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
Expand Down Expand Up @@ -115,6 +116,7 @@ class Config
APPSIGNAL_BIND_ADDRESS
APPSIGNAL_CA_FILE_PATH
APPSIGNAL_HOSTNAME
APPSIGNAL_HOST_ROLE
APPSIGNAL_HTTP_PROXY
APPSIGNAL_LOG
APPSIGNAL_LOG_LEVEL
Expand Down Expand Up @@ -337,6 +339,7 @@ def write_to_environment # rubocop:disable Metrics/AbcSize
ENV["_APPSIGNAL_FILTER_PARAMETERS"] = config_hash[:filter_parameters].join(",")
ENV["_APPSIGNAL_FILTER_SESSION_DATA"] = config_hash[:filter_session_data].join(",")
ENV["_APPSIGNAL_HOSTNAME"] = config_hash[:hostname].to_s
ENV["_APPSIGNAL_HOST_ROLE"] = config_hash[:host_role].to_s
ENV["_APPSIGNAL_HTTP_PROXY"] = config_hash[:http_proxy]
ENV["_APPSIGNAL_IGNORE_ACTIONS"] = config_hash[:ignore_actions].join(",")
ENV["_APPSIGNAL_IGNORE_ERRORS"] = config_hash[:ignore_errors].join(",")
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/appsignal/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@
expect(ENV.fetch("_APPSIGNAL_RUNNING_IN_CONTAINER", nil)).to eq "false"
expect(ENV.fetch("_APPSIGNAL_ENABLE_HOST_METRICS", nil)).to eq "true"
expect(ENV.fetch("_APPSIGNAL_HOSTNAME", nil)).to eq ""
expect(ENV.fetch("_APPSIGNAL_HOST_ROLE", nil)).to eq ""
expect(ENV.fetch("_APPSIGNAL_PROCESS_NAME", nil)).to include "rspec"
expect(ENV.fetch("_APPSIGNAL_CA_FILE_PATH", nil))
.to eq File.join(resources_dir, "cacert.pem")
Expand All @@ -667,6 +668,17 @@
end
end

context "with :host_role" do
before do
config[:host_role] = "host role"
config.write_to_environment
end

it "sets the modified :host_role" do
expect(ENV.fetch("_APPSIGNAL_HOST_ROLE", nil)).to eq "host role"
end
end

context "with :working_dir_path" do
before do
config[:working_dir_path] = "/tmp/appsignal2"
Expand Down