appsignal 2.7.0.alpha.4-java → 2.7.0.beta.1-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 +5 -5
- data/.rubocop_todo.yml +4 -11
- data/CHANGELOG.md +6 -4
- data/ext/agent.yml +35 -35
- data/ext/appsignal_extension.c +2 -2
- data/lib/appsignal.rb +17 -7
- data/lib/appsignal/config.rb +8 -0
- data/lib/appsignal/extension/jruby.rb +1 -1
- data/lib/appsignal/integrations/mongo_ruby_driver.rb +1 -1
- data/lib/appsignal/js_exception_transaction.rb +2 -2
- data/lib/appsignal/transaction.rb +9 -5
- data/lib/appsignal/utils.rb +2 -125
- data/lib/appsignal/utils/data.rb +83 -0
- data/lib/appsignal/utils/json.rb +41 -0
- data/lib/appsignal/version.rb +1 -1
- data/spec/lib/appsignal/config_spec.rb +12 -0
- data/spec/lib/appsignal/extension_spec.rb +1 -1
- data/spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb +1 -1
- data/spec/lib/appsignal/js_exception_transaction_spec.rb +3 -3
- data/spec/lib/appsignal/transaction_spec.rb +141 -93
- data/spec/lib/appsignal/{utils_spec.rb → utils/data_spec.rb} +7 -44
- data/spec/lib/appsignal/utils/json_spec.rb +40 -0
- data/spec/lib/appsignal_spec.rb +6 -3
- metadata +9 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b399322e51f86bc6afedcc43ab989bb7baec0a9330423a0c6e00cb95d785c86e
|
|
4
|
+
data.tar.gz: d7e8e9c06423301cc6ad0bd5a782e6059d0ac9373fd885425d114d75026c7b5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4b43c6308993443266376d56e1c5f179a1e452fb2e19b952ba675d46c94f7f03fc48868c65a44a03005e6eebb046b6effcf5b66f612fd36fe0ec7ce895dc959
|
|
7
|
+
data.tar.gz: 63e74bc3338a8de89237dec4b7c26c6dffce3d9d40cea768e1b94670db8bb45ea8160d019969d643c180e531369528657d7c3f31a6c4fbb88b79f754cf945367
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2018-
|
|
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:
|
|
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:
|
|
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:
|
|
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'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
# 2.7.0
|
|
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
|
data/ext/agent.yml
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
---
|
|
2
|
-
version:
|
|
2
|
+
version: 64deb96
|
|
3
3
|
triples:
|
|
4
4
|
x86_64-darwin:
|
|
5
5
|
static:
|
|
6
|
-
checksum:
|
|
7
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
10
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
14
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
17
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
21
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
24
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
28
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
31
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
35
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
39
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
43
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
46
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
50
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
54
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
57
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
61
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
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:
|
|
64
|
-
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/
|
|
63
|
+
checksum: '059ee407610bd4154a8a94bb029d0451758bfb995b530ab5142e4fd3a1a59030'
|
|
64
|
+
download_url: https://appsignal-agent-releases.global.ssl.fastly.net/64deb96/appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
data/ext/appsignal_extension.c
CHANGED
|
@@ -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,
|
|
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
|
-
|
|
598
|
+
NUM2DBL(count),
|
|
599
599
|
tags_data
|
|
600
600
|
);
|
|
601
601
|
return Qnil;
|
data/lib/appsignal.rb
CHANGED
|
@@ -600,7 +600,11 @@ module Appsignal
|
|
|
600
600
|
end
|
|
601
601
|
|
|
602
602
|
def set_gauge(key, value, tags = {})
|
|
603
|
-
Appsignal::Extension.set_gauge(
|
|
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(
|
|
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(
|
|
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")
|
data/lib/appsignal/config.rb
CHANGED
|
@@ -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, :
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 |
|
|
452
|
-
|
|
453
|
-
|
|
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
|
|
data/lib/appsignal/utils.rb
CHANGED
|
@@ -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
|
data/lib/appsignal/version.rb
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
"
|
|
348
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
356
|
-
|
|
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
|
-
|
|
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 "
|
|
364
|
-
it "
|
|
365
|
-
expect(transaction.
|
|
366
|
-
|
|
367
|
-
|
|
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
|
-
|
|
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 "
|
|
374
|
-
it "
|
|
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.
|
|
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
|
-
|
|
386
|
-
|
|
387
|
-
"custom"
|
|
388
|
-
|
|
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
|
-
|
|
391
|
-
|
|
392
|
-
|
|
431
|
+
expect(transaction.namespace).to eq namespace
|
|
432
|
+
expect(transaction.to_h["namespace"]).to eq(namespace)
|
|
433
|
+
end
|
|
393
434
|
end
|
|
394
435
|
|
|
395
|
-
|
|
396
|
-
|
|
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
|
-
|
|
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 "
|
|
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
|
-
|
|
491
|
-
|
|
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
|
-
|
|
537
|
+
expect(transaction.to_h["metadata"]).to eq({})
|
|
538
|
+
end
|
|
494
539
|
end
|
|
495
|
-
end
|
|
496
540
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 ".
|
|
5
|
-
subject { Appsignal::Utils.
|
|
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.
|
|
26
|
-
it { is_expected.to_not eq Appsignal::Utils.
|
|
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.
|
|
64
|
-
it { is_expected.to_not eq Appsignal::Utils.
|
|
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
|
data/spec/lib/appsignal_spec.rb
CHANGED
|
@@ -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)
|
|
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)
|
|
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)
|
|
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.
|
|
4
|
+
version: 2.7.0.beta.1
|
|
5
5
|
platform: java
|
|
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-
|
|
12
|
+
date: 2018-07-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rack
|
|
@@ -249,7 +249,9 @@ files:
|
|
|
249
249
|
- lib/appsignal/transaction.rb
|
|
250
250
|
- lib/appsignal/transmitter.rb
|
|
251
251
|
- lib/appsignal/utils.rb
|
|
252
|
+
- lib/appsignal/utils/data.rb
|
|
252
253
|
- lib/appsignal/utils/hash_sanitizer.rb
|
|
254
|
+
- lib/appsignal/utils/json.rb
|
|
253
255
|
- lib/appsignal/utils/query_params_sanitizer.rb
|
|
254
256
|
- lib/appsignal/version.rb
|
|
255
257
|
- lib/sequel/extensions/appsignal_integration.rb
|
|
@@ -318,9 +320,10 @@ files:
|
|
|
318
320
|
- spec/lib/appsignal/system_spec.rb
|
|
319
321
|
- spec/lib/appsignal/transaction_spec.rb
|
|
320
322
|
- spec/lib/appsignal/transmitter_spec.rb
|
|
323
|
+
- spec/lib/appsignal/utils/data_spec.rb
|
|
321
324
|
- spec/lib/appsignal/utils/hash_sanitizer_spec.rb
|
|
325
|
+
- spec/lib/appsignal/utils/json_spec.rb
|
|
322
326
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
|
323
|
-
- spec/lib/appsignal/utils_spec.rb
|
|
324
327
|
- spec/lib/appsignal_spec.rb
|
|
325
328
|
- spec/spec_helper.rb
|
|
326
329
|
- spec/support/fixtures/containers/cgroups/docker
|
|
@@ -376,7 +379,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
376
379
|
version: 1.3.1
|
|
377
380
|
requirements: []
|
|
378
381
|
rubyforge_project:
|
|
379
|
-
rubygems_version: 2.
|
|
382
|
+
rubygems_version: 2.7.6
|
|
380
383
|
signing_key:
|
|
381
384
|
specification_version: 4
|
|
382
385
|
summary: Logs performance and exception data from your app to appsignal.com
|
|
@@ -444,9 +447,10 @@ test_files:
|
|
|
444
447
|
- spec/lib/appsignal/system_spec.rb
|
|
445
448
|
- spec/lib/appsignal/transaction_spec.rb
|
|
446
449
|
- spec/lib/appsignal/transmitter_spec.rb
|
|
450
|
+
- spec/lib/appsignal/utils/data_spec.rb
|
|
447
451
|
- spec/lib/appsignal/utils/hash_sanitizer_spec.rb
|
|
452
|
+
- spec/lib/appsignal/utils/json_spec.rb
|
|
448
453
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
|
449
|
-
- spec/lib/appsignal/utils_spec.rb
|
|
450
454
|
- spec/lib/appsignal_spec.rb
|
|
451
455
|
- spec/spec_helper.rb
|
|
452
456
|
- spec/support/fixtures/containers/cgroups/docker
|