appsignal 4.8.2-java → 4.8.3-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d3b0a7b974307c3481bcec024d44f2e04bc388ebc7732401be0f1fc9b53b53a
4
- data.tar.gz: a213da6461793f487e86633222afd41317a58278654f4231da4002abf1b4d45e
3
+ metadata.gz: cd64c501f9026dc4658364532b105f9a866c21533fd510bf2c0abea321c2d513
4
+ data.tar.gz: ff044b5dda35caaeeb9eb51789100937122db57a2d28f798c037b99b74367f01
5
5
  SHA512:
6
- metadata.gz: d1f5e8b6334777942146ad8c48966d6a9ad2e2987596cfc21d140c30f54a5c0c150346a8f67b3537528bbc23b3d588f1bf43c35f0230ca83c74ba76dd2c0a14b
7
- data.tar.gz: 10fafdc1f77f5eaf68cde39e598206e5fb8e0779b1046a40df6e76e6e894528f5f05a546da68aa4d42482aa0080fb43a20ba60e153287c2f2de4142944686a8b
6
+ metadata.gz: c7d95a9271fd861afb88e398f9db80288870114d26a6719517a6a9f5654e40b0b6f332d3432e2cfebe29d061d1fb75247587ce7e36757da630f119e990c13171
7
+ data.tar.gz: 6c4c27891167d520cfa0d86f1ce6771fe8b9c3a24189ed4b05a43a124fd1be41667628182c08bd6baed443de81089c77197e31cf25b1193ffd07d2b8be46fd5c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # AppSignal for Ruby gem Changelog
2
2
 
3
+ ## 4.8.3
4
+
5
+ _Published on 2026-02-17._
6
+
7
+ ### Added
8
+
9
+ - Add a `default_tags` configuration option. Tags set in this configuration option will be set for all transactions. (patch [3b9d9f48](https://github.com/appsignal/appsignal-ruby/commit/3b9d9f4844295d3c8f94fe750509f69f579cb372))
10
+
3
11
  ## 4.8.2
4
12
 
5
13
  _Published on 2026-02-05._
@@ -132,7 +132,8 @@ module Appsignal
132
132
  :send_environment_metadata => true,
133
133
  :send_params => true,
134
134
  :send_session_data => true,
135
- :sidekiq_report_errors => "all"
135
+ :sidekiq_report_errors => "all",
136
+ :default_tags => {}
136
137
  }.freeze
137
138
 
138
139
  # @!visibility private
@@ -221,6 +222,11 @@ module Appsignal
221
222
  :cpu_count => "APPSIGNAL_CPU_COUNT"
222
223
  }.freeze
223
224
 
225
+ # @!visibility private
226
+ HASH_OPTIONS = {
227
+ :default_tags => "APPSIGNAL_DEFAULT_TAGS"
228
+ }.freeze
229
+
224
230
  # @!visibility private
225
231
  attr_reader :root_path, :env, :config_hash
226
232
 
@@ -639,9 +645,34 @@ module Appsignal
639
645
  config[option] = env_var.to_f
640
646
  end
641
647
 
648
+ # Configuration with hash type
649
+ HASH_OPTIONS.each do |option, env_key|
650
+ env_var = ENV.fetch(env_key, nil)
651
+ next unless env_var
652
+
653
+ config[option] = parse_tags_from_env(env_var)
654
+ end
655
+
642
656
  config
643
657
  end
644
658
 
659
+ # Parse tags from environment variable string format "foo=bar,baz=quux"
660
+ # @param env_var [String] the environment variable value
661
+ # @return [Hash] parsed tags with string keys and values
662
+ # @api private
663
+ def parse_tags_from_env(env_var)
664
+ return {} if env_var.nil? || env_var.strip.empty?
665
+
666
+ env_var.split(",").each_with_object({}) do |pair, hash|
667
+ key, value = pair.split("=", 2)
668
+
669
+ # Skip malformed pairs (no key, no value, or missing "=")
670
+ next unless key && value && !key.strip.empty? && !value.strip.empty?
671
+
672
+ hash[key.strip] = value.strip
673
+ end
674
+ end
675
+
645
676
  # Set config options based on the final user config. Fix any conflicting
646
677
  # config.
647
678
  def determine_overrides
@@ -891,6 +922,24 @@ module Appsignal
891
922
  end
892
923
  end
893
924
 
925
+ # @!group Hash Configuration Options
926
+
927
+ # @!attribute [rw] default_tags
928
+ # @return [Hash] Default tags to set on all transactions
929
+
930
+ # @!endgroup
931
+
932
+ # Custom getter for default_tags to ensure consistent format
933
+ def default_tags
934
+ fetch_option(:default_tags) || {}
935
+ end
936
+
937
+ # Custom setter for default_tags with validation
938
+ def default_tags=(value)
939
+ parsed_tags = parse_and_validate_tags(value)
940
+ update_option(:default_tags, parsed_tags)
941
+ end
942
+
894
943
  private
895
944
 
896
945
  def fetch_option(key)
@@ -904,6 +953,48 @@ module Appsignal
904
953
  def update_option(key, value)
905
954
  @dsl_options[key] = value
906
955
  end
956
+
957
+ # Parse tags from various input formats and validate values
958
+ # @param value [Hash, nil] input tags
959
+ # @return [Hash] validated tags with string keys
960
+ # @api private
961
+ def parse_and_validate_tags(value)
962
+ case value
963
+ when Hash
964
+ validate_tag_values(value)
965
+ when nil
966
+ {}
967
+ else
968
+ Appsignal.internal_logger.warn(
969
+ "Invalid value for 'default_tags' config option: #{value.class}. " \
970
+ "The 'default_tags' config option must be a Hash."
971
+ )
972
+ {}
973
+ end
974
+ end
975
+
976
+ # Validate tag values are allowed types, log errors for invalid types
977
+ # @param tags [Hash] tags to validate
978
+ # @return [Hash] tags with only valid values
979
+ # @api private
980
+ def validate_tag_values(tags)
981
+ tags.each_with_object({}) do |(key, value), valid_tags|
982
+ # Convert keys to strings for consistency
983
+ string_key = key.to_s
984
+
985
+ # Check if value is an allowed type
986
+ if [Symbol, String, Integer, TrueClass, FalseClass].any? { |type| value.is_a?(type) }
987
+ valid_tags[string_key] = value
988
+ else
989
+ Appsignal.internal_logger.warn(
990
+ "Ignored tag '#{string_key}' in 'default_tags' config option because of " \
991
+ "invalid value type: #{value.class}. " \
992
+ "Tags in the 'default_tags' config option must have values of type " \
993
+ "String, Symbol, Integer, or Boolean."
994
+ )
995
+ end
996
+ end
997
+ end
907
998
  end
908
999
  end
909
1000
  end
@@ -897,7 +897,18 @@ module Appsignal
897
897
  #
898
898
  # @see https://docs.appsignal.com/ruby/instrumentation/tagging.html
899
899
  def sanitized_tags
900
- @tags.select do |key, value|
900
+ # Start with config default_tags as base (if config is available)
901
+ base_tags = if Appsignal.config
902
+ Appsignal.config[:default_tags] || {}
903
+ else
904
+ {}
905
+ end
906
+
907
+ # Merge transaction tags on top (transaction tags take priority)
908
+ all_tags = base_tags.merge(@tags)
909
+
910
+ # Apply existing sanitization filter
911
+ all_tags.select do |key, value|
901
912
  ALLOWED_TAG_KEY_TYPES.any? { |type| key.is_a? type } &&
902
913
  ALLOWED_TAG_VALUE_TYPES.any? { |type| value.is_a? type }
903
914
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Appsignal
4
4
  # @return [String]
5
- VERSION = "4.8.2"
5
+ VERSION = "4.8.3"
6
6
  end
data/sig/appsignal.rbi CHANGED
@@ -8,7 +8,7 @@
8
8
  module Appsignal
9
9
  extend Appsignal::Helpers::Metrics
10
10
  extend Appsignal::Helpers::Instrumentation
11
- VERSION = T.let("4.8.2", T.untyped)
11
+ VERSION = T.let("4.8.3", T.untyped)
12
12
 
13
13
  class << self
14
14
  # The loaded AppSignal configuration.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.8.2
4
+ version: 4.8.3
5
5
  platform: java
6
6
  authors:
7
7
  - Robert Beekman