appsignal 2.7.0.alpha.4 → 2.7.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c61b262b517a8dc0923998d62be036fd6133c7cc
4
- data.tar.gz: 3d84a9925bf05798201d91e3174823ffe6c793e6
2
+ SHA256:
3
+ metadata.gz: b23b27d0c6cd268d86cc544d68ef947e365bbf6895cf84968f75ebd683d996f2
4
+ data.tar.gz: d7e8e9c06423301cc6ad0bd5a782e6059d0ac9373fd885425d114d75026c7b5b
5
5
  SHA512:
6
- metadata.gz: 77170a310402131b77ad99f147c754ae328b3c0a688eee5306fe4d5468ea9f8eec51a04fdf3cf80cebf6374771fade3689155b5006832df84294c6a4324e6445
7
- data.tar.gz: b60fd4f13ecc8c4c6c8cec97d5d0796c9a815abb56d3d5543950fd99ec14242e4cd4794eea53028b10be8bbd124216ac0b9e77cddf9eee54220f0d101c034eac
6
+ metadata.gz: 1cd7206a51c7e076fdef7ac3945d86074044271973946af3274cb9dd5aad1d0b756ac432a40b19224dd5eb5e59b1053bb0849f700f9795fa335dece2f0360566
7
+ data.tar.gz: 63e74bc3338a8de89237dec4b7c26c6dffce3d9d40cea768e1b94670db8bb45ea8160d019969d643c180e531369528657d7c3f31a6c4fbb88b79f754cf945367
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-05-06 12:47:25 +0200 using RuboCop version 0.50.0.
3
+ # on 2018-06-01 17:12:10 +0200 using RuboCop version 0.50.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 45
9
+ # Offense count: 44
10
10
  Metrics/AbcSize:
11
11
  Max: 56
12
12
 
@@ -28,13 +28,13 @@ Metrics/ClassLength:
28
28
  Metrics/CyclomaticComplexity:
29
29
  Max: 11
30
30
 
31
- # Offense count: 537
31
+ # Offense count: 523
32
32
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
33
33
  # URISchemes: http, https
34
34
  Metrics/LineLength:
35
35
  Max: 152
36
36
 
37
- # Offense count: 95
37
+ # Offense count: 94
38
38
  # Configuration parameters: CountComments.
39
39
  Metrics/MethodLength:
40
40
  Max: 60
@@ -108,10 +108,3 @@ Style/GuardClause:
108
108
  - 'lib/appsignal/event_formatter/moped/query_formatter.rb'
109
109
  - 'lib/appsignal/hooks.rb'
110
110
  - 'lib/appsignal/marker.rb'
111
-
112
- # Offense count: 1
113
- # Cop supports --auto-correct.
114
- # Configuration parameters: MaxLineLength.
115
- Style/IfUnlessModifier:
116
- Exclude:
117
- - 'lib/appsignal.rb'
@@ -1,9 +1,11 @@
1
- # 2.7.0 Alpha 3
2
- - Fix reporting of memory host metrics for containerized hosts. PR #415
3
- - Detect Kubernetes containers as containers in probes-rs library.
4
- Commit 60822aac24ccc394df073091c64f05096455942d.
1
+ # 2.7.0 Beta 1
5
2
  - Detect Kubernetes containers as containers for `running_in_container`
6
3
  config option. Commit 60822aac24ccc394df073091c64f05096455942d.
4
+ - Fix in memory logger initialization. PR #416
5
+ - Organize classes in their own files. PR #417
6
+ - Move tag value limit handling to extension. PR #418
7
+ - Add working_directory_path config option. PR #421
8
+ - Use doubles values in custom metrics functions. PR #422
7
9
 
8
10
  # 2.6.1
9
11
  - Remove request_headers warning and use sane default. PR #410
@@ -1,64 +1,64 @@
1
1
  ---
2
- version: 94aaf32
2
+ version: 64deb96
3
3
  triples:
4
4
  x86_64-darwin:
5
5
  static:
6
- checksum: 1316f7c202a232ae691dc3745f2ec6ee824e01aa2a613e56a41979b19ba1ec8f
7
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-darwin-all-static.tar.gz
6
+ checksum: 1ab49acb93615b0c1e2fe9e48c179e0fd3fcadd391523940c322f154bd479a83
7
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-darwin-all-static.tar.gz
8
8
  dynamic:
9
- checksum: b54ae98cfedfe82d7c4b6fbb05ec6d0310484db5706eeeb29a8cda006b5ea361
10
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-darwin-all-dynamic.tar.gz
9
+ checksum: 8b1acc7825c2fd024e4fed9bd4fe5485c3ba8dc903a00dbcd26d3ab27dc2e7ee
10
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-darwin-all-dynamic.tar.gz
11
11
  universal-darwin:
12
12
  static:
13
- checksum: 1316f7c202a232ae691dc3745f2ec6ee824e01aa2a613e56a41979b19ba1ec8f
14
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-darwin-all-static.tar.gz
13
+ checksum: 1ab49acb93615b0c1e2fe9e48c179e0fd3fcadd391523940c322f154bd479a83
14
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-darwin-all-static.tar.gz
15
15
  dynamic:
16
- checksum: b54ae98cfedfe82d7c4b6fbb05ec6d0310484db5706eeeb29a8cda006b5ea361
17
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-darwin-all-dynamic.tar.gz
16
+ checksum: 8b1acc7825c2fd024e4fed9bd4fe5485c3ba8dc903a00dbcd26d3ab27dc2e7ee
17
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-darwin-all-dynamic.tar.gz
18
18
  i686-linux:
19
19
  static:
20
- checksum: c0c5c3ad646e500c2a4a78afadbf4828560e4b4f00901a726fd06af0e5047cdc
21
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-i686-linux-all-static.tar.gz
20
+ checksum: a27cf9191f70f13263662f6ca2555cada27ebb4384d6c981a534774b5e7def0e
21
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-i686-linux-all-static.tar.gz
22
22
  dynamic:
23
- checksum: a6b98af9a1ac6d016b7021e73b76b457b6a1890114719fe6552eb46a371731ae
24
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-i686-linux-all-dynamic.tar.gz
23
+ checksum: 7a19dd1aabe68a454649155e99fd95293915d0019ba438366c9cce247cdb4bc1
24
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-i686-linux-all-dynamic.tar.gz
25
25
  x86-linux:
26
26
  static:
27
- checksum: c0c5c3ad646e500c2a4a78afadbf4828560e4b4f00901a726fd06af0e5047cdc
28
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-i686-linux-all-static.tar.gz
27
+ checksum: a27cf9191f70f13263662f6ca2555cada27ebb4384d6c981a534774b5e7def0e
28
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-i686-linux-all-static.tar.gz
29
29
  dynamic:
30
- checksum: a6b98af9a1ac6d016b7021e73b76b457b6a1890114719fe6552eb46a371731ae
31
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-i686-linux-all-dynamic.tar.gz
30
+ checksum: 7a19dd1aabe68a454649155e99fd95293915d0019ba438366c9cce247cdb4bc1
31
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-i686-linux-all-dynamic.tar.gz
32
32
  i686-linux-musl:
33
33
  static:
34
- checksum: 05bfaa688ceef363523818b2d0d5d94db178b2596cca96d804932c129d8ede10
35
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-i686-linux-musl-all-static.tar.gz
34
+ checksum: 80fb5c2f36b7e8efcfc6914bb707688e248dd06c58b174d07e8a931f4bbf97ce
35
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-i686-linux-musl-all-static.tar.gz
36
36
  x86-linux-musl:
37
37
  static:
38
- checksum: 05bfaa688ceef363523818b2d0d5d94db178b2596cca96d804932c129d8ede10
39
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-i686-linux-musl-all-static.tar.gz
38
+ checksum: 80fb5c2f36b7e8efcfc6914bb707688e248dd06c58b174d07e8a931f4bbf97ce
39
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-i686-linux-musl-all-static.tar.gz
40
40
  x86_64-linux:
41
41
  static:
42
- checksum: db176c740e26db37d61df1f9e18d57127a1a5208495f02bf18ff2c9553b12d62
43
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-linux-all-static.tar.gz
42
+ checksum: 83befc3bb521d5e055eb92d5a5a0afca929bce8968ca6d0426fac6aeaec3df24
43
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-linux-all-static.tar.gz
44
44
  dynamic:
45
- checksum: cb0f024f8a027d2a059c7d1a12fb98071e3c2da0ae6277ef5ac32fddf1e7ae8c
46
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-linux-all-dynamic.tar.gz
45
+ checksum: a6a8237df0fa0c8ff62ca3cd519e0494f01fc5e52f5ae9757c5fe375f451673a
46
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-linux-all-dynamic.tar.gz
47
47
  x86_64-linux-musl:
48
48
  static:
49
- checksum: a3c5882bfa3ee6f9612449a8c90eb64791764f34d910c21fd436ce26cf232b4e
50
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-linux-musl-all-static.tar.gz
49
+ checksum: 3cb74695955c7bc809320fa966d7290fe3162926c239bb6a845b82ef7aec266e
50
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-linux-musl-all-static.tar.gz
51
51
  x86_64-freebsd:
52
52
  static:
53
- checksum: ba8e6b26b76809a22753a6e6829be72c45a1c2a31c113e04d0fe09789ff63d98
54
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-freebsd-all-static.tar.gz
53
+ checksum: 7735718e2789c71f1135100ff4fab13cd85cbebe0ba2b87c5b555b30635bdcdc
54
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-freebsd-all-static.tar.gz
55
55
  dynamic:
56
- checksum: 52b17d8504aa335a35c9a84cde5762096b2e94ee2c9d622397e240ffa01cf5cd
57
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-freebsd-all-dynamic.tar.gz
56
+ checksum: '059ee407610bd4154a8a94bb029d0451758bfb995b530ab5142e4fd3a1a59030'
57
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-freebsd-all-dynamic.tar.gz
58
58
  amd64-freebsd:
59
59
  static:
60
- checksum: ba8e6b26b76809a22753a6e6829be72c45a1c2a31c113e04d0fe09789ff63d98
61
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-freebsd-all-static.tar.gz
60
+ checksum: 7735718e2789c71f1135100ff4fab13cd85cbebe0ba2b87c5b555b30635bdcdc
61
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-freebsd-all-static.tar.gz
62
62
  dynamic:
63
- checksum: 52b17d8504aa335a35c9a84cde5762096b2e94ee2c9d622397e240ffa01cf5cd
64
- download_url: https://appsignal-agent-releases.global.ssl.fastly.net/94aaf32/appsignal-x86_64-freebsd-all-dynamic.tar.gz
63
+ checksum: '059ee407610bd4154a8a94bb029d0451758bfb995b530ab5142e4fd3a1a59030'
64
+ download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-freebsd-all-dynamic.tar.gz
@@ -588,14 +588,14 @@ static VALUE increment_counter(VALUE self, VALUE key, VALUE count, VALUE tags) {
588
588
  appsignal_data_t* tags_data;
589
589
 
590
590
  Check_Type(key, T_STRING);
591
- Check_Type(count, T_FIXNUM);
591
+ Check_Type(count, T_FLOAT);
592
592
  Check_Type(tags, RUBY_T_DATA);
593
593
 
594
594
  Data_Get_Struct(tags, appsignal_data_t, tags_data);
595
595
 
596
596
  appsignal_increment_counter(
597
597
  make_appsignal_string(key),
598
- FIX2INT(count),
598
+ NUM2DBL(count),
599
599
  tags_data
600
600
  );
601
601
  return Qnil;
@@ -600,7 +600,11 @@ module Appsignal
600
600
  end
601
601
 
602
602
  def set_gauge(key, value, tags = {})
603
- Appsignal::Extension.set_gauge(key.to_s, value.to_f, Appsignal::Utils.data_generate(tags))
603
+ Appsignal::Extension.set_gauge(
604
+ key.to_s,
605
+ value.to_f,
606
+ Appsignal::Utils::Data.generate(tags)
607
+ )
604
608
  rescue RangeError
605
609
  Appsignal.logger.warn("Gauge value #{value} for key '#{key}' is too big")
606
610
  end
@@ -617,14 +621,22 @@ module Appsignal
617
621
  Appsignal.logger.warn("Process gauge value #{value} for key '#{key}' is too big")
618
622
  end
619
623
 
620
- def increment_counter(key, value = 1, tags = {})
621
- Appsignal::Extension.increment_counter(key.to_s, value, Appsignal::Utils.data_generate(tags))
624
+ def increment_counter(key, value = 1.0, tags = {})
625
+ Appsignal::Extension.increment_counter(
626
+ key.to_s,
627
+ value.to_f,
628
+ Appsignal::Utils::Data.generate(tags)
629
+ )
622
630
  rescue RangeError
623
631
  Appsignal.logger.warn("Counter value #{value} for key '#{key}' is too big")
624
632
  end
625
633
 
626
634
  def add_distribution_value(key, value, tags = {})
627
- Appsignal::Extension.add_distribution_value(key.to_s, value.to_f, Appsignal::Utils.data_generate(tags))
635
+ Appsignal::Extension.add_distribution_value(
636
+ key.to_s,
637
+ value.to_f,
638
+ Appsignal::Utils::Data.generate(tags)
639
+ )
628
640
  rescue RangeError
629
641
  Appsignal.logger.warn("Distribution value #{value} for key '#{key}' is too big")
630
642
  end
@@ -682,9 +694,7 @@ module Appsignal
682
694
  Logger::INFO
683
695
  end
684
696
 
685
- if in_memory_log
686
- logger << in_memory_log.string
687
- end
697
+ logger << @in_memory_log.string if @in_memory_log
688
698
 
689
699
  if path_arg
690
700
  logger.info("Setting the path in start_logger has no effect anymore, set it in the config instead")
@@ -65,6 +65,7 @@ module Appsignal
65
65
  "APPSIGNAL_ENABLE_GC_INSTRUMENTATION" => :enable_gc_instrumentation,
66
66
  "APPSIGNAL_RUNNING_IN_CONTAINER" => :running_in_container,
67
67
  "APPSIGNAL_WORKING_DIR_PATH" => :working_dir_path,
68
+ "APPSIGNAL_WORKING_DIRECTORY_PATH" => :working_directory_path,
68
69
  "APPSIGNAL_ENABLE_HOST_METRICS" => :enable_host_metrics,
69
70
  "APPSIGNAL_ENABLE_MINUTELY_PROBES" => :enable_minutely_probes,
70
71
  "APPSIGNAL_HOSTNAME" => :hostname,
@@ -168,6 +169,7 @@ module Appsignal
168
169
  ENV["_APPSIGNAL_SEND_PARAMS"] = config_hash[:send_params].to_s
169
170
  ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"] = config_hash[:running_in_container].to_s
170
171
  ENV["_APPSIGNAL_WORKING_DIR_PATH"] = config_hash[:working_dir_path] if config_hash[:working_dir_path]
172
+ ENV["_APPSIGNAL_WORKING_DIRECTORY_PATH"] = config_hash[:working_directory_path] if config_hash[:working_directory_path]
171
173
  ENV["_APPSIGNAL_ENABLE_HOST_METRICS"] = config_hash[:enable_host_metrics].to_s
172
174
  ENV["_APPSIGNAL_ENABLE_MINUTELY_PROBES"] = config_hash[:enable_minutely_probes].to_s
173
175
  ENV["_APPSIGNAL_HOSTNAME"] = config_hash[:hostname].to_s
@@ -246,6 +248,12 @@ module Appsignal
246
248
  next if config[new_key] # Skip if new key is already in use
247
249
  config[new_key] = old_config_value
248
250
  end
251
+
252
+ if config.include?(:working_dir_path)
253
+ logger.warn "'working_dir_path' is deprecated, please use " \
254
+ "'working_directory_path' instead and specify the " \
255
+ "full path to the working directory"
256
+ end
249
257
  end
250
258
  end
251
259
 
@@ -72,7 +72,7 @@ module Appsignal
72
72
  [:appsignal_string, :double],
73
73
  :void
74
74
  attach_function :appsignal_increment_counter,
75
- [:appsignal_string, :int64, :pointer],
75
+ [:appsignal_string, :double, :pointer],
76
76
  :void
77
77
  attach_function :appsignal_add_distribution_value,
78
78
  [:appsignal_string, :double, :pointer],
@@ -48,7 +48,7 @@ module Appsignal
48
48
  transaction.finish_event(
49
49
  "query.mongodb",
50
50
  "#{event.command_name} | #{event.database_name} | #{result}",
51
- Appsignal::Utils.data_generate(command),
51
+ Appsignal::Utils::Data.generate(command),
52
52
  Appsignal::EventFormatter::DEFAULT
53
53
  )
54
54
  end
@@ -29,7 +29,7 @@ module Appsignal
29
29
  ext.set_error(
30
30
  @data["name"],
31
31
  @data["message"] || "",
32
- Appsignal::Utils.data_generate(@data["backtrace"] || [])
32
+ Appsignal::Utils::Data.generate(@data["backtrace"] || [])
33
33
  )
34
34
  end
35
35
 
@@ -43,7 +43,7 @@ module Appsignal
43
43
  next unless data.is_a?(Array) || data.is_a?(Hash)
44
44
  ext.set_sample_data(
45
45
  key.to_s,
46
- Appsignal::Utils.data_generate(data)
46
+ Appsignal::Utils::Data.generate(data)
47
47
  )
48
48
  end
49
49
  end
@@ -9,6 +9,8 @@ module Appsignal
9
9
  ACTION_CABLE = "action_cable".freeze
10
10
  FRONTEND = "frontend".freeze
11
11
  BLANK = "".freeze
12
+ ALLOWED_TAG_KEY_TYPES = [Symbol, String].freeze
13
+ ALLOWED_TAG_VALUE_TYPES = [Symbol, String, Integer].freeze
12
14
 
13
15
  class << self
14
16
  def create(id, namespace, request, options = {})
@@ -242,7 +244,7 @@ module Appsignal
242
244
  return unless key && data && (data.is_a?(Array) || data.is_a?(Hash))
243
245
  @ext.set_sample_data(
244
246
  key.to_s,
245
- Appsignal::Utils.data_generate(data)
247
+ Appsignal::Utils::Data.generate(data)
246
248
  )
247
249
  rescue RuntimeError => e
248
250
  Appsignal.logger.error("Error generating data (#{e.class}: #{e.message}) for '#{data.inspect}'")
@@ -268,7 +270,7 @@ module Appsignal
268
270
  @ext.set_error(
269
271
  error.class.name,
270
272
  error.message.to_s,
271
- backtrace ? Appsignal::Utils.data_generate(backtrace) : Appsignal::Extension.data_array_new
273
+ backtrace ? Appsignal::Utils::Data.generate(backtrace) : Appsignal::Extension.data_array_new
272
274
  )
273
275
  end
274
276
  alias_method :add_exception, :set_error
@@ -447,10 +449,12 @@ module Appsignal
447
449
  # * Key is a symbol or string with less then 100 chars
448
450
  # * Value is a symbol or string with less then 100 chars
449
451
  # * Value is an integer
452
+ #
453
+ # @see https://docs.appsignal.com/ruby/instrumentation/tagging.html
450
454
  def sanitized_tags
451
- @tags.select do |k, v|
452
- (k.is_a?(Symbol) || k.is_a?(String) && k.length <= 100) &&
453
- (((v.is_a?(Symbol) || v.is_a?(String)) && v.length <= 100) || v.is_a?(Integer))
455
+ @tags.select do |key, value|
456
+ ALLOWED_TAG_KEY_TYPES.any? { |type| key.is_a? type } &&
457
+ ALLOWED_TAG_VALUE_TYPES.any? { |type| value.is_a? type }
454
458
  end
455
459
  end
456
460
 
@@ -1,129 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "appsignal/utils/data"
3
4
  require "appsignal/utils/hash_sanitizer"
5
+ require "appsignal/utils/json"
4
6
  require "appsignal/utils/query_params_sanitizer"
5
-
6
- module Appsignal
7
- # @api private
8
- module Utils
9
- def self.data_generate(body)
10
- Data.generate(body)
11
- end
12
-
13
- class Data
14
- class << self
15
- def generate(body)
16
- if body.is_a?(Hash)
17
- map_hash(body)
18
- elsif body.is_a?(Array)
19
- map_array(body)
20
- else
21
- raise TypeError, "Body of type #{body.class} should be a Hash or Array"
22
- end
23
- end
24
-
25
- def map_hash(hash_value)
26
- map = Appsignal::Extension.data_map_new
27
- hash_value.each do |key, value|
28
- key = key.to_s
29
- case value
30
- when String
31
- map.set_string(key, value)
32
- when Integer
33
- # An Integer too big for C-lang longs to fit
34
- bigint = 1 << 63
35
- if value >= bigint
36
- map.set_string(key, "bigint:#{value}")
37
- else
38
- map.set_integer(key, value)
39
- end
40
- when Float
41
- map.set_float(key, value)
42
- when TrueClass, FalseClass
43
- map.set_boolean(key, value)
44
- when NilClass
45
- map.set_nil(key)
46
- when Hash
47
- map.set_data(key, map_hash(value))
48
- when Array
49
- map.set_data(key, map_array(value))
50
- else
51
- map.set_string(key, value.to_s)
52
- end
53
- end
54
- map
55
- end
56
-
57
- def map_array(array_value)
58
- array = Appsignal::Extension.data_array_new
59
- array_value.each do |value|
60
- case value
61
- when String
62
- array.append_string(value)
63
- when Integer
64
- # An Integer too big for C-lang longs to fit
65
- bigint = 1 << 63
66
- if value >= bigint
67
- array.append_string("bigint:#{value}")
68
- else
69
- array.append_integer(value)
70
- end
71
- when Float
72
- array.append_float(value)
73
- when TrueClass, FalseClass
74
- array.append_boolean(value)
75
- when NilClass
76
- array.append_nil
77
- when Hash
78
- array.append_data(map_hash(value))
79
- when Array
80
- array.append_data(map_array(value))
81
- else
82
- array.append_string(value.to_s)
83
- end
84
- end
85
- array
86
- end
87
- end
88
- end
89
-
90
- def self.json_generate(body)
91
- JSON.generate(body)
92
- end
93
-
94
- class JSON
95
- class << self
96
- def generate(body)
97
- ::JSON.generate(jsonify(body))
98
- end
99
-
100
- private
101
-
102
- def jsonify(value)
103
- case value
104
- when String
105
- encode_utf8(value)
106
- when Numeric, NilClass, TrueClass, FalseClass
107
- value
108
- when Hash
109
- value.each_with_object({}) do |(k, v), hash|
110
- hash[jsonify(k)] = jsonify(v)
111
- end
112
- when Array
113
- value.map { |v| jsonify(v) }
114
- else
115
- jsonify(value.to_s)
116
- end
117
- end
118
-
119
- def encode_utf8(value)
120
- value.encode(
121
- "utf-8".freeze,
122
- :invalid => :replace,
123
- :undef => :replace
124
- )
125
- end
126
- end
127
- end
128
- end
129
- end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Utils
5
+ # @api private
6
+ class Data
7
+ class << self
8
+ def generate(body)
9
+ if body.is_a?(Hash)
10
+ map_hash(body)
11
+ elsif body.is_a?(Array)
12
+ map_array(body)
13
+ else
14
+ raise TypeError, "Body of type #{body.class} should be a Hash or Array"
15
+ end
16
+ end
17
+
18
+ def map_hash(hash_value)
19
+ map = Appsignal::Extension.data_map_new
20
+ hash_value.each do |key, value|
21
+ key = key.to_s
22
+ case value
23
+ when String
24
+ map.set_string(key, value)
25
+ when Integer
26
+ # An Integer too big for C-lang longs to fit
27
+ bigint = 1 << 63
28
+ if value >= bigint
29
+ map.set_string(key, "bigint:#{value}")
30
+ else
31
+ map.set_integer(key, value)
32
+ end
33
+ when Float
34
+ map.set_float(key, value)
35
+ when TrueClass, FalseClass
36
+ map.set_boolean(key, value)
37
+ when NilClass
38
+ map.set_nil(key)
39
+ when Hash
40
+ map.set_data(key, map_hash(value))
41
+ when Array
42
+ map.set_data(key, map_array(value))
43
+ else
44
+ map.set_string(key, value.to_s)
45
+ end
46
+ end
47
+ map
48
+ end
49
+
50
+ def map_array(array_value)
51
+ array = Appsignal::Extension.data_array_new
52
+ array_value.each do |value|
53
+ case value
54
+ when String
55
+ array.append_string(value)
56
+ when Integer
57
+ # An Integer too big for C-lang longs to fit
58
+ bigint = 1 << 63
59
+ if value >= bigint
60
+ array.append_string("bigint:#{value}")
61
+ else
62
+ array.append_integer(value)
63
+ end
64
+ when Float
65
+ array.append_float(value)
66
+ when TrueClass, FalseClass
67
+ array.append_boolean(value)
68
+ when NilClass
69
+ array.append_nil
70
+ when Hash
71
+ array.append_data(map_hash(value))
72
+ when Array
73
+ array.append_data(map_array(value))
74
+ else
75
+ array.append_string(value.to_s)
76
+ end
77
+ end
78
+ array
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Appsignal
4
+ module Utils
5
+ # @api private
6
+ class JSON
7
+ class << self
8
+ def generate(body)
9
+ ::JSON.generate(jsonify(body))
10
+ end
11
+
12
+ private
13
+
14
+ def jsonify(value)
15
+ case value
16
+ when String
17
+ encode_utf8(value)
18
+ when Numeric, NilClass, TrueClass, FalseClass
19
+ value
20
+ when Hash
21
+ value.each_with_object({}) do |(k, v), hash|
22
+ hash[jsonify(k)] = jsonify(v)
23
+ end
24
+ when Array
25
+ value.map { |v| jsonify(v) }
26
+ else
27
+ jsonify(value.to_s)
28
+ end
29
+ end
30
+
31
+ def encode_utf8(value)
32
+ value.encode(
33
+ "utf-8".freeze,
34
+ :invalid => :replace,
35
+ :undef => :replace
36
+ )
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Appsignal
4
- VERSION = "2.7.0.alpha.4".freeze
4
+ VERSION = "2.7.0.beta.1".freeze
5
5
  end
@@ -443,6 +443,7 @@ describe Appsignal::Config do
443
443
  expect(ENV["_APPSIGNAL_FILES_WORLD_ACCESSIBLE"]).to eq "true"
444
444
  expect(ENV["_APP_REVISION"]).to eq "v2.5.1"
445
445
  expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIR_PATH")
446
+ expect(ENV).to_not have_key("_APPSIGNAL_WORKING_DIRECTORY_PATH")
446
447
  end
447
448
 
448
449
  context "with :hostname" do
@@ -466,6 +467,17 @@ describe Appsignal::Config do
466
467
  expect(ENV["_APPSIGNAL_WORKING_DIR_PATH"]).to eq "/tmp/appsignal2"
467
468
  end
468
469
  end
470
+
471
+ context "with :working_directory_path" do
472
+ before do
473
+ config[:working_directory_path] = "/tmp/appsignal2"
474
+ config.write_to_environment
475
+ end
476
+
477
+ it "sets the modified :working_directory_path" do
478
+ expect(ENV["_APPSIGNAL_WORKING_DIRECTORY_PATH"]).to eq "/tmp/appsignal2"
479
+ end
480
+ end
469
481
  end
470
482
 
471
483
  describe "#log_file_path" do
@@ -107,7 +107,7 @@ describe Appsignal::Extension do
107
107
  end
108
108
 
109
109
  it "should have a increment_counter method" do
110
- subject.increment_counter("key", 1, Appsignal::Extension.data_map_new)
110
+ subject.increment_counter("key", 1.0, Appsignal::Extension.data_map_new)
111
111
  end
112
112
 
113
113
  it "should have a add_distribution_value method" do
@@ -81,7 +81,7 @@ describe Appsignal::Hooks::MongoMonitorSubscriber do
81
81
  expect(transaction).to receive(:finish_event).with(
82
82
  "query.mongodb",
83
83
  "find | test | SUCCEEDED",
84
- Appsignal::Utils.data_generate("foo" => "?"),
84
+ Appsignal::Utils::Data.generate("foo" => "?"),
85
85
  0
86
86
  )
87
87
 
@@ -60,7 +60,7 @@ describe Appsignal::JSExceptionTransaction do
60
60
  expect(transaction.ext).to receive(:set_error).with(
61
61
  "TypeError",
62
62
  "foo is not a valid method",
63
- Appsignal::Utils.data_generate(["foo.bar/js:11:1", "foo.bar/js:22:2"])
63
+ Appsignal::Utils::Data.generate(["foo.bar/js:11:1", "foo.bar/js:22:2"])
64
64
  )
65
65
 
66
66
  transaction.set_error
@@ -71,7 +71,7 @@ describe Appsignal::JSExceptionTransaction do
71
71
  it "should call `Appsignal::Extension.set_transaction_error_data`" do
72
72
  expect(transaction.ext).to receive(:set_sample_data).with(
73
73
  "tags",
74
- Appsignal::Utils.data_generate(["tag1"])
74
+ Appsignal::Utils::Data.generate(["tag1"])
75
75
  )
76
76
 
77
77
  transaction.set_sample_data
@@ -102,7 +102,7 @@ describe Appsignal::JSExceptionTransaction do
102
102
  expect(transaction.ext).to receive(:set_error).with(
103
103
  "TypeError",
104
104
  "",
105
- Appsignal::Utils.data_generate([])
105
+ Appsignal::Utils::Data.generate([])
106
106
  )
107
107
 
108
108
  transaction.set_error
@@ -334,68 +334,114 @@ describe Appsignal::Transaction do
334
334
  end
335
335
 
336
336
  describe "#set_tags" do
337
- it "should add tags to transaction" do
338
- expect do
339
- transaction.set_tags("a" => "b")
340
- end.to change(transaction, :tags).to("a" => "b")
337
+ let(:long_string) { "a" * 2001 }
338
+ before do
339
+ transaction.set_tags(
340
+ :valid_key => "valid_value",
341
+ "valid_string_key" => "valid_value",
342
+ :both_symbols => :valid_value,
343
+ :integer_value => 1,
344
+ :hash_value => { "invalid" => "hash" },
345
+ :array_value => %w[invalid array],
346
+ :object => Object.new,
347
+ :too_long_value => long_string,
348
+ long_string => "too_long_key"
349
+ )
350
+ transaction.sample_data
341
351
  end
342
- end
343
352
 
344
- describe "set_action" do
345
- it "should set the action in extension" do
346
- expect(transaction.ext).to receive(:set_action).with(
347
- "PagesController#show"
348
- ).once
353
+ it "stores tags on the transaction" do
354
+ expect(transaction.to_h["sample_data"]["tags"]).to eq(
355
+ "valid_key" => "valid_value",
356
+ "valid_string_key" => "valid_value",
357
+ "both_symbols" => "valid_value",
358
+ "integer_value" => 1,
359
+ "too_long_value" => "#{"a" * 2000}...",
360
+ long_string => "too_long_key"
361
+ )
362
+ end
363
+ end
349
364
 
350
- transaction.set_action("PagesController#show")
365
+ describe "#set_action" do
366
+ context "when the action is set" do
367
+ it "updates the action name on the transaction" do
368
+ action_name = "PagesController#show"
369
+ transaction.set_action(action_name)
351
370
 
352
- expect(transaction.action).to eq "PagesController#show"
371
+ expect(transaction.action).to eq(action_name)
372
+ expect(transaction.to_h["action"]).to eq(action_name)
373
+ end
353
374
  end
354
375
 
355
- it "should not set the action in extension when value is nil" do
356
- expect(Appsignal::Extension).to_not receive(:set_action)
376
+ context "when the action is nil" do
377
+ it "does not update the action name on the transaction" do
378
+ action_name = "PagesController#show"
379
+ transaction.set_action(action_name)
380
+ transaction.set_action(nil)
357
381
 
358
- transaction.set_action(nil)
382
+ expect(transaction.action).to eq(action_name)
383
+ expect(transaction.to_h["action"]).to eq(action_name)
384
+ end
359
385
  end
360
386
  end
361
387
 
362
- describe "set_action_if_nil" do
363
- context "if action is currently nil" do
364
- it "should set the action" do
365
- expect(transaction.ext).to receive(:set_action).with(
366
- "PagesController#show"
367
- ).once
388
+ describe "#set_action_if_nil" do
389
+ context "when the action is not set" do
390
+ it "updates the action name on the transaction" do
391
+ expect(transaction.action).to eq(nil)
392
+ expect(transaction.to_h["action"]).to eq(nil)
393
+
394
+ action_name = "PagesController#show"
395
+ transaction.set_action_if_nil(action_name)
396
+
397
+ expect(transaction.action).to eq(action_name)
398
+ expect(transaction.to_h["action"]).to eq(action_name)
399
+ end
400
+
401
+ context "when the given action is nil" do
402
+ it "does not update the action name on the transaction" do
403
+ action_name = "something"
404
+ transaction.set_action("something")
405
+ transaction.set_action_if_nil(nil)
368
406
 
369
- transaction.set_action_if_nil("PagesController#show")
407
+ expect(transaction.action).to eq(action_name)
408
+ expect(transaction.to_h["action"]).to eq(action_name)
409
+ end
370
410
  end
371
411
  end
372
412
 
373
- context "if action is currently set" do
374
- it "should not set the action" do
413
+ context "when the action is set" do
414
+ it "does not update the action name on the transaction" do
415
+ action_name = "something"
375
416
  transaction.set_action("something")
417
+ transaction.set_action_if_nil("something else")
376
418
 
377
- expect(transaction.ext).not_to receive(:set_action)
378
-
379
- transaction.set_action_if_nil("PagesController#show")
419
+ expect(transaction.action).to eq(action_name)
420
+ expect(transaction.to_h["action"]).to eq(action_name)
380
421
  end
381
422
  end
382
423
  end
383
424
 
384
- describe "set_namespace" do
385
- it "should set the action in extension" do
386
- expect(transaction.ext).to receive(:set_namespace).with(
387
- "custom"
388
- ).once
425
+ describe "#set_namespace" do
426
+ context "when the namespace is not nil" do
427
+ it "updates the namespace on the transaction" do
428
+ namespace = "custom"
429
+ transaction.set_namespace(namespace)
389
430
 
390
- transaction.set_namespace("custom")
391
-
392
- expect(transaction.namespace).to eq "custom"
431
+ expect(transaction.namespace).to eq namespace
432
+ expect(transaction.to_h["namespace"]).to eq(namespace)
433
+ end
393
434
  end
394
435
 
395
- it "should not set the action in extension when value is nil" do
396
- expect(Appsignal::Extension).to_not receive(:set_namespace)
436
+ context "when the namespace is nil" do
437
+ it "does not update the namespace on the transaction" do
438
+ namespace = "custom"
439
+ transaction.set_namespace(namespace)
440
+ transaction.set_namespace(nil)
397
441
 
398
- transaction.set_action(nil)
442
+ expect(transaction.namespace).to eq(namespace)
443
+ expect(transaction.to_h["namespace"]).to eq(namespace)
444
+ end
399
445
  end
400
446
  end
401
447
 
@@ -478,44 +524,68 @@ describe Appsignal::Transaction do
478
524
  end
479
525
 
480
526
  describe "#set_metadata" do
481
- it "should set the metdata in extension" do
482
- expect(transaction.ext).to receive(:set_metadata).with(
483
- "request_method",
484
- "GET"
485
- ).once
486
-
527
+ it "updates the metadata on the transaction" do
487
528
  transaction.set_metadata("request_method", "GET")
529
+
530
+ expect(transaction.to_h["metadata"]).to eq("request_method" => "GET")
488
531
  end
489
532
 
490
- it "should not set the metdata in extension when value is nil" do
491
- expect(transaction.ext).to_not receive(:set_metadata)
533
+ context "when the key is nil" do
534
+ it "does not update the metadata on the transaction" do
535
+ transaction.set_metadata(nil, "GET")
492
536
 
493
- transaction.set_metadata("request_method", nil)
537
+ expect(transaction.to_h["metadata"]).to eq({})
538
+ end
494
539
  end
495
- end
496
540
 
497
- describe "set_sample_data" do
498
- it "should set the data" do
499
- expect(transaction.ext).to receive(:set_sample_data).with(
500
- "params",
501
- Appsignal::Utils.data_generate("controller" => "blog_posts", "action" => "show", "id" => "1")
502
- ).once
541
+ context "when the value is nil" do
542
+ it "does not update the metadata on the transaction" do
543
+ transaction.set_metadata("request_method", nil)
503
544
 
545
+ expect(transaction.to_h["metadata"]).to eq({})
546
+ end
547
+ end
548
+ end
549
+
550
+ describe "#set_sample_data" do
551
+ it "updates the sample data on the transaction" do
504
552
  transaction.set_sample_data(
505
553
  "params",
506
554
  :controller => "blog_posts",
507
555
  :action => "show",
508
556
  :id => "1"
509
557
  )
510
- end
511
558
 
512
- it "should do nothing if the data cannot be converted to json" do
513
- expect(transaction.ext).to_not receive(:set_sample_data).with(
514
- "params",
515
- kind_of(String)
559
+ expect(transaction.to_h["sample_data"]).to eq(
560
+ "params" => {
561
+ "action" => "show",
562
+ "controller" => "blog_posts",
563
+ "id" => "1"
564
+ }
516
565
  )
566
+ end
567
+
568
+ context "when the data is no Array or Hash" do
569
+ it "does not update the sample data on the transaction" do
570
+ transaction.set_sample_data("params", "string")
571
+
572
+ expect(transaction.to_h["sample_data"]).to eq({})
573
+ end
574
+ end
517
575
 
518
- transaction.set_sample_data("params", "string")
576
+ context "when the data cannot be converted to JSON" do
577
+ it "does not update the sample data on the transaction" do
578
+ klass = Class.new do
579
+ def to_s
580
+ raise "foo" # Cause a deliberate error
581
+ end
582
+ end
583
+ transaction.set_sample_data("params", klass.new => 1)
584
+
585
+ expect(transaction.to_h["sample_data"]).to eq({})
586
+ expect(log_contents(log)).to contains_log :error,
587
+ "Error generating data (RuntimeError: foo) for"
588
+ end
519
589
  end
520
590
  end
521
591
 
@@ -523,7 +593,7 @@ describe Appsignal::Transaction do
523
593
  it "should sample data" do
524
594
  expect(transaction.ext).to receive(:set_sample_data).with(
525
595
  "environment",
526
- Appsignal::Utils.data_generate(
596
+ Appsignal::Utils::Data.generate(
527
597
  "CONTENT_LENGTH" => "0",
528
598
  "REQUEST_METHOD" => "GET",
529
599
  "SERVER_NAME" => "example.org",
@@ -533,19 +603,23 @@ describe Appsignal::Transaction do
533
603
  ).once
534
604
  expect(transaction.ext).to receive(:set_sample_data).with(
535
605
  "session_data",
536
- Appsignal::Utils.data_generate({})
606
+ Appsignal::Utils::Data.generate({})
537
607
  ).once
538
608
  expect(transaction.ext).to receive(:set_sample_data).with(
539
609
  "params",
540
- Appsignal::Utils.data_generate("controller" => "blog_posts", "action" => "show", "id" => "1")
610
+ Appsignal::Utils::Data.generate(
611
+ "controller" => "blog_posts",
612
+ "action" => "show",
613
+ "id" => "1"
614
+ )
541
615
  ).once
542
616
  expect(transaction.ext).to receive(:set_sample_data).with(
543
617
  "metadata",
544
- Appsignal::Utils.data_generate("key" => "value")
618
+ Appsignal::Utils::Data.generate("key" => "value")
545
619
  ).once
546
620
  expect(transaction.ext).to receive(:set_sample_data).with(
547
621
  "tags",
548
- Appsignal::Utils.data_generate({})
622
+ Appsignal::Utils::Data.generate({})
549
623
  ).once
550
624
 
551
625
  transaction.sample_data
@@ -572,7 +646,7 @@ describe Appsignal::Transaction do
572
646
  expect(transaction.ext).to receive(:set_error).with(
573
647
  "RSpec::Mocks::Double",
574
648
  "test message",
575
- Appsignal::Utils.data_generate(["line 1"])
649
+ Appsignal::Utils::Data.generate(["line 1"])
576
650
  )
577
651
 
578
652
  transaction.set_error(error)
@@ -590,7 +664,7 @@ describe Appsignal::Transaction do
590
664
  expect(transaction.ext).to receive(:set_error).with(
591
665
  "RSpec::Mocks::Double",
592
666
  "",
593
- Appsignal::Utils.data_generate(["line 1"])
667
+ Appsignal::Utils::Data.generate(["line 1"])
594
668
  )
595
669
 
596
670
  transaction.set_error(error)
@@ -1080,32 +1154,6 @@ describe Appsignal::Transaction do
1080
1154
  end
1081
1155
  end
1082
1156
 
1083
- describe "#sanitized_tags" do
1084
- before do
1085
- transaction.set_tags(
1086
- :valid_key => "valid_value",
1087
- "valid_string_key" => "valid_value",
1088
- :both_symbols => :valid_value,
1089
- :integer_value => 1,
1090
- :hash_value => { "invalid" => "hash" },
1091
- :array_value => %w[invalid array],
1092
- :to_long_value => SecureRandom.urlsafe_base64(101),
1093
- :object => Object.new,
1094
- SecureRandom.urlsafe_base64(101) => "to_long_key"
1095
- )
1096
- end
1097
- subject { transaction.send(:sanitized_tags).keys }
1098
-
1099
- it "should only return whitelisted data" do
1100
- is_expected.to match_array([
1101
- :valid_key,
1102
- "valid_string_key",
1103
- :both_symbols,
1104
- :integer_value
1105
- ])
1106
- end
1107
- end
1108
-
1109
1157
  describe "#cleaned_backtrace" do
1110
1158
  subject { transaction.send(:cleaned_backtrace, ["line 1", "line 2"]) }
1111
1159
 
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- describe Appsignal::Utils do
4
- describe ".data_generate" do
5
- subject { Appsignal::Utils.data_generate(body) }
3
+ describe Appsignal::Utils::Data do
4
+ describe ".generate" do
5
+ subject { Appsignal::Utils::Data.generate(body) }
6
6
 
7
7
  context "with a valid hash body" do
8
8
  let(:body) do
@@ -22,8 +22,8 @@ describe Appsignal::Utils do
22
22
  }
23
23
  end
24
24
 
25
- it { is_expected.to eq Appsignal::Utils.data_generate(body) }
26
- it { is_expected.to_not eq Appsignal::Utils.data_generate({}) }
25
+ it { is_expected.to eq Appsignal::Utils::Data.generate(body) }
26
+ it { is_expected.to_not eq Appsignal::Utils::Data.generate({}) }
27
27
 
28
28
  describe "#to_s" do
29
29
  it "returns a serialized hash" do
@@ -60,8 +60,8 @@ describe Appsignal::Utils do
60
60
  ]
61
61
  end
62
62
 
63
- it { is_expected.to eq Appsignal::Utils.data_generate(body) }
64
- it { is_expected.to_not eq Appsignal::Utils.data_generate({}) }
63
+ it { is_expected.to eq Appsignal::Utils::Data.generate(body) }
64
+ it { is_expected.to_not eq Appsignal::Utils::Data.generate({}) }
65
65
 
66
66
  describe "#to_s" do
67
67
  it "returns a serialized array" do
@@ -110,41 +110,4 @@ describe Appsignal::Utils do
110
110
  end
111
111
  end
112
112
  end
113
-
114
- describe ".json_generate" do
115
- subject { Appsignal::Utils.json_generate(body) }
116
-
117
- context "with a valid body" do
118
- let(:body) do
119
- {
120
- "the" => "payload",
121
- 1 => true,
122
- nil => "test",
123
- :foo => [1, 2, "three"],
124
- "bar" => nil,
125
- "baz" => { "foo" => "bar" }
126
- }
127
- end
128
-
129
- it { is_expected.to eq %({"the":"payload","1":true,"":"test","foo":[1,2,"three"],"bar":null,"baz":{"foo":"bar"}}) }
130
- end
131
-
132
- context "with a body that contains strings with invalid utf-8 content" do
133
- let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
134
- let(:body) do
135
- {
136
- "field_one" => [0x61, 0x61].pack("c*"),
137
- :field_two => string_with_invalid_utf8,
138
- "field_three" => [
139
- "one", string_with_invalid_utf8
140
- ],
141
- "field_four" => {
142
- "one" => string_with_invalid_utf8
143
- }
144
- }
145
- end
146
-
147
- it { is_expected.to eq %({"field_one":"aa","field_two":"aa�","field_three":["one","aa�"],"field_four":{"one":"aa�"}}) }
148
- end
149
- end
150
113
  end
@@ -0,0 +1,40 @@
1
+ # encoding: UTF-8
2
+
3
+ describe Appsignal::Utils::JSON do
4
+ describe ".generate" do
5
+ subject { Appsignal::Utils::JSON.generate(body) }
6
+
7
+ context "with a valid body" do
8
+ let(:body) do
9
+ {
10
+ "the" => "payload",
11
+ 1 => true,
12
+ nil => "test",
13
+ :foo => [1, 2, "three"],
14
+ "bar" => nil,
15
+ "baz" => { "foo" => "bar" }
16
+ }
17
+ end
18
+
19
+ it { is_expected.to eq %({"the":"payload","1":true,"":"test","foo":[1,2,"three"],"bar":null,"baz":{"foo":"bar"}}) }
20
+ end
21
+
22
+ context "with a body that contains strings with invalid utf-8 content" do
23
+ let(:string_with_invalid_utf8) { [0x61, 0x61, 0x85].pack("c*") }
24
+ let(:body) do
25
+ {
26
+ "field_one" => [0x61, 0x61].pack("c*"),
27
+ :field_two => string_with_invalid_utf8,
28
+ "field_three" => [
29
+ "one", string_with_invalid_utf8
30
+ ],
31
+ "field_four" => {
32
+ "one" => string_with_invalid_utf8
33
+ }
34
+ }
35
+ end
36
+
37
+ it { is_expected.to eq %({"field_one":"aa","field_two":"aa�","field_three":["one","aa�"],"field_four":{"one":"aa�"}}) }
38
+ end
39
+ end
40
+ end
@@ -434,7 +434,8 @@ describe Appsignal do
434
434
  end
435
435
 
436
436
  it "should call set_gauge with tags" do
437
- expect(Appsignal::Extension).to receive(:set_gauge).with("key", 0.1, Appsignal::Utils.data_generate(tags))
437
+ expect(Appsignal::Extension).to receive(:set_gauge)
438
+ .with("key", 0.1, Appsignal::Utils::Data.generate(tags))
438
439
  Appsignal.set_gauge("key", 0.1, tags)
439
440
  end
440
441
 
@@ -499,7 +500,8 @@ describe Appsignal do
499
500
  end
500
501
 
501
502
  it "should call increment_counter with tags" do
502
- expect(Appsignal::Extension).to receive(:increment_counter).with("key", 1, Appsignal::Utils.data_generate(tags))
503
+ expect(Appsignal::Extension).to receive(:increment_counter)
504
+ .with("key", 1, Appsignal::Utils::Data.generate(tags))
503
505
  Appsignal.increment_counter("key", 1, tags)
504
506
  end
505
507
 
@@ -529,7 +531,8 @@ describe Appsignal do
529
531
  end
530
532
 
531
533
  it "should call add_distribution_value with tags" do
532
- expect(Appsignal::Extension).to receive(:add_distribution_value).with("key", 0.1, Appsignal::Utils.data_generate(tags))
534
+ expect(Appsignal::Extension).to receive(:add_distribution_value)
535
+ .with("key", 0.1, Appsignal::Utils::Data.generate(tags))
533
536
  Appsignal.add_distribution_value("key", 0.1, tags)
534
537
  end
535
538
 
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: 2.7.0.alpha.4
4
+ version: 2.7.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-29 00:00:00.000000000 Z
12
+ date: 2018-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -235,7 +235,9 @@ files:
235
235
  - lib/appsignal/transaction.rb
236
236
  - lib/appsignal/transmitter.rb
237
237
  - lib/appsignal/utils.rb
238
+ - lib/appsignal/utils/data.rb
238
239
  - lib/appsignal/utils/hash_sanitizer.rb
240
+ - lib/appsignal/utils/json.rb
239
241
  - lib/appsignal/utils/query_params_sanitizer.rb
240
242
  - lib/appsignal/version.rb
241
243
  - lib/sequel/extensions/appsignal_integration.rb
@@ -304,9 +306,10 @@ files:
304
306
  - spec/lib/appsignal/system_spec.rb
305
307
  - spec/lib/appsignal/transaction_spec.rb
306
308
  - spec/lib/appsignal/transmitter_spec.rb
309
+ - spec/lib/appsignal/utils/data_spec.rb
307
310
  - spec/lib/appsignal/utils/hash_sanitizer_spec.rb
311
+ - spec/lib/appsignal/utils/json_spec.rb
308
312
  - spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
309
- - spec/lib/appsignal/utils_spec.rb
310
313
  - spec/lib/appsignal_spec.rb
311
314
  - spec/spec_helper.rb
312
315
  - spec/support/fixtures/containers/cgroups/docker
@@ -362,7 +365,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
365
  version: 1.3.1
363
366
  requirements: []
364
367
  rubyforge_project:
365
- rubygems_version: 2.5.2.3
368
+ rubygems_version: 2.7.6
366
369
  signing_key:
367
370
  specification_version: 4
368
371
  summary: Logs performance and exception data from your app to appsignal.com
@@ -430,9 +433,10 @@ test_files:
430
433
  - spec/lib/appsignal/system_spec.rb
431
434
  - spec/lib/appsignal/transaction_spec.rb
432
435
  - spec/lib/appsignal/transmitter_spec.rb
436
+ - spec/lib/appsignal/utils/data_spec.rb
433
437
  - spec/lib/appsignal/utils/hash_sanitizer_spec.rb
438
+ - spec/lib/appsignal/utils/json_spec.rb
434
439
  - spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
435
- - spec/lib/appsignal/utils_spec.rb
436
440
  - spec/lib/appsignal_spec.rb
437
441
  - spec/spec_helper.rb
438
442
  - spec/support/fixtures/containers/cgroups/docker