appsignal 3.1.6-java → 3.2.0-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 +4 -4
- data/.semaphore/semaphore.yml +90 -0
- data/CHANGELOG.md +7 -0
- data/README.md +1 -0
- data/build_matrix.yml +1 -0
- data/ext/agent.yml +27 -27
- data/ext/appsignal_extension.c +22 -0
- data/gemfiles/http5.gemfile +5 -0
- data/lib/appsignal/config.rb +14 -7
- data/lib/appsignal/extension/jruby.rb +14 -0
- data/lib/appsignal/hooks/http.rb +21 -0
- data/lib/appsignal/hooks.rb +1 -0
- data/lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb +1 -1
- data/lib/appsignal/integrations/http.rb +21 -0
- data/lib/appsignal/logger.rb +126 -9
- data/lib/appsignal/utils/integration_logger.rb +19 -0
- data/lib/appsignal/utils.rb +1 -0
- data/lib/appsignal/version.rb +1 -1
- data/lib/appsignal.rb +4 -4
- data/spec/lib/appsignal/config_spec.rb +16 -0
- data/spec/lib/appsignal/hooks/http_spec.rb +39 -0
- data/spec/lib/appsignal/integrations/http_spec.rb +103 -0
- data/spec/lib/appsignal/logger_spec.rb +84 -15
- data/spec/lib/appsignal/utils/integration_logger_spec.rb +25 -0
- data/spec/lib/appsignal_spec.rb +4 -4
- data/spec/support/helpers/dependency_helper.rb +4 -0
- data/spec/support/helpers/log_helpers.rb +1 -1
- metadata +13 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ba59271103947144c9d29a741b03d602449f20e0603e53d775d7a18f7959aaf
|
|
4
|
+
data.tar.gz: ab9233cb944b2f35eaf7639a918306ceac42c4de57a337295eeb72d3249043dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a7f9e30219e7a1178a13fcc1c3595731a5ebe8734b762f8a10465e644428d9b21482dceff1a984af846f1a947a6444d03450600ba71afd63c4973d177c8629f4
|
|
7
|
+
data.tar.gz: 64477a38482899aed37b742fa3b8d76b9c562edb46973881bb2881a2eaa3d469ea390516d3ab90f02e2675d27df492b0b516d5679feec9690f167d6b6a983c7f
|
data/.semaphore/semaphore.yml
CHANGED
|
@@ -570,6 +570,24 @@ blocks:
|
|
|
570
570
|
value: latest
|
|
571
571
|
commands:
|
|
572
572
|
- "./support/bundler_wrapper exec rake test"
|
|
573
|
+
- name: Ruby 2.6.9 for http5
|
|
574
|
+
env_vars:
|
|
575
|
+
- *2
|
|
576
|
+
- *3
|
|
577
|
+
- *4
|
|
578
|
+
- *5
|
|
579
|
+
- name: RUBY_VERSION
|
|
580
|
+
value: 2.6.9
|
|
581
|
+
- name: GEMSET
|
|
582
|
+
value: http5
|
|
583
|
+
- name: BUNDLE_GEMFILE
|
|
584
|
+
value: gemfiles/http5.gemfile
|
|
585
|
+
- name: _RUBYGEMS_VERSION
|
|
586
|
+
value: latest
|
|
587
|
+
- name: _BUNDLER_VERSION
|
|
588
|
+
value: latest
|
|
589
|
+
commands:
|
|
590
|
+
- "./support/bundler_wrapper exec rake test"
|
|
573
591
|
- name: Ruby 2.6.9 for padrino
|
|
574
592
|
env_vars:
|
|
575
593
|
- *2
|
|
@@ -923,6 +941,24 @@ blocks:
|
|
|
923
941
|
value: latest
|
|
924
942
|
commands:
|
|
925
943
|
- "./support/bundler_wrapper exec rake test"
|
|
944
|
+
- name: Ruby 2.7.5 for http5
|
|
945
|
+
env_vars:
|
|
946
|
+
- *2
|
|
947
|
+
- *3
|
|
948
|
+
- *4
|
|
949
|
+
- *5
|
|
950
|
+
- name: RUBY_VERSION
|
|
951
|
+
value: 2.7.5
|
|
952
|
+
- name: GEMSET
|
|
953
|
+
value: http5
|
|
954
|
+
- name: BUNDLE_GEMFILE
|
|
955
|
+
value: gemfiles/http5.gemfile
|
|
956
|
+
- name: _RUBYGEMS_VERSION
|
|
957
|
+
value: latest
|
|
958
|
+
- name: _BUNDLER_VERSION
|
|
959
|
+
value: latest
|
|
960
|
+
commands:
|
|
961
|
+
- "./support/bundler_wrapper exec rake test"
|
|
926
962
|
- name: Ruby 2.7.5 for padrino
|
|
927
963
|
env_vars:
|
|
928
964
|
- *2
|
|
@@ -1294,6 +1330,24 @@ blocks:
|
|
|
1294
1330
|
value: latest
|
|
1295
1331
|
commands:
|
|
1296
1332
|
- "./support/bundler_wrapper exec rake test"
|
|
1333
|
+
- name: Ruby 3.0.3 for http5
|
|
1334
|
+
env_vars:
|
|
1335
|
+
- *2
|
|
1336
|
+
- *3
|
|
1337
|
+
- *4
|
|
1338
|
+
- *5
|
|
1339
|
+
- name: RUBY_VERSION
|
|
1340
|
+
value: 3.0.3
|
|
1341
|
+
- name: GEMSET
|
|
1342
|
+
value: http5
|
|
1343
|
+
- name: BUNDLE_GEMFILE
|
|
1344
|
+
value: gemfiles/http5.gemfile
|
|
1345
|
+
- name: _RUBYGEMS_VERSION
|
|
1346
|
+
value: latest
|
|
1347
|
+
- name: _BUNDLER_VERSION
|
|
1348
|
+
value: latest
|
|
1349
|
+
commands:
|
|
1350
|
+
- "./support/bundler_wrapper exec rake test"
|
|
1297
1351
|
- name: Ruby 3.0.3 for padrino
|
|
1298
1352
|
env_vars:
|
|
1299
1353
|
- *2
|
|
@@ -1611,6 +1665,24 @@ blocks:
|
|
|
1611
1665
|
value: latest
|
|
1612
1666
|
commands:
|
|
1613
1667
|
- "./support/bundler_wrapper exec rake test"
|
|
1668
|
+
- name: Ruby 3.1.1 for http5
|
|
1669
|
+
env_vars:
|
|
1670
|
+
- *2
|
|
1671
|
+
- *3
|
|
1672
|
+
- *4
|
|
1673
|
+
- *5
|
|
1674
|
+
- name: RUBY_VERSION
|
|
1675
|
+
value: 3.1.1
|
|
1676
|
+
- name: GEMSET
|
|
1677
|
+
value: http5
|
|
1678
|
+
- name: BUNDLE_GEMFILE
|
|
1679
|
+
value: gemfiles/http5.gemfile
|
|
1680
|
+
- name: _RUBYGEMS_VERSION
|
|
1681
|
+
value: latest
|
|
1682
|
+
- name: _BUNDLER_VERSION
|
|
1683
|
+
value: latest
|
|
1684
|
+
commands:
|
|
1685
|
+
- "./support/bundler_wrapper exec rake test"
|
|
1614
1686
|
- name: Ruby 3.1.1 for padrino
|
|
1615
1687
|
env_vars:
|
|
1616
1688
|
- *2
|
|
@@ -1910,6 +1982,24 @@ blocks:
|
|
|
1910
1982
|
value: latest
|
|
1911
1983
|
commands:
|
|
1912
1984
|
- "./support/bundler_wrapper exec rake test"
|
|
1985
|
+
- name: Ruby 3.2.0-preview1 for http5
|
|
1986
|
+
env_vars:
|
|
1987
|
+
- *2
|
|
1988
|
+
- *3
|
|
1989
|
+
- *4
|
|
1990
|
+
- *5
|
|
1991
|
+
- name: RUBY_VERSION
|
|
1992
|
+
value: 3.2.0-preview1
|
|
1993
|
+
- name: GEMSET
|
|
1994
|
+
value: http5
|
|
1995
|
+
- name: BUNDLE_GEMFILE
|
|
1996
|
+
value: gemfiles/http5.gemfile
|
|
1997
|
+
- name: _RUBYGEMS_VERSION
|
|
1998
|
+
value: latest
|
|
1999
|
+
- name: _BUNDLER_VERSION
|
|
2000
|
+
value: latest
|
|
2001
|
+
commands:
|
|
2002
|
+
- "./support/bundler_wrapper exec rake test"
|
|
1913
2003
|
- name: Ruby 3.2.0-preview1 for padrino
|
|
1914
2004
|
env_vars:
|
|
1915
2005
|
- *2
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# AppSignal for Ruby gem Changelog
|
|
2
2
|
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- [199d05c0](https://github.com/appsignal/appsignal-ruby/commit/199d05c0f95be7f2496ddcd05613eb816e9ad4e4) minor - Support the http.rb gem. Any outgoing requests will be tracked as events on the incident event timeline. This instrumentation is activated automatically, but can be disable by setting the `instrumentation_http_rb` option to `false`.
|
|
8
|
+
- [9bcd107d](https://github.com/appsignal/appsignal-ruby/commit/9bcd107de955e557744434fc9f953588a9c7bc49) minor - Support log collection from Ruby apps using the new AppSignal Logging feature. Learn more about [AppSignal's Logging on our docs](https://docs.appsignal.com/logging/platforms/integrations/ruby.html).
|
|
9
|
+
|
|
3
10
|
## 3.1.6
|
|
4
11
|
|
|
5
12
|
### Fixed
|
data/README.md
CHANGED
|
@@ -232,6 +232,7 @@ configurations you need to run the spec suite with a specific Gemfile.
|
|
|
232
232
|
BUNDLE_GEMFILE=gemfiles/capistrano2.gemfile bundle exec rspec
|
|
233
233
|
BUNDLE_GEMFILE=gemfiles/capistrano3.gemfile bundle exec rspec
|
|
234
234
|
BUNDLE_GEMFILE=gemfiles/grape.gemfile bundle exec rspec
|
|
235
|
+
BUNDLE_GEMFILE=gemfiles/http5.gemfile bundle exec rspec
|
|
235
236
|
BUNDLE_GEMFILE=gemfiles/no_dependencies.gemfile bundle exec rspec
|
|
236
237
|
BUNDLE_GEMFILE=gemfiles/padrino.gemfile bundle exec rspec
|
|
237
238
|
BUNDLE_GEMFILE=gemfiles/que.gemfile bundle exec rspec
|
data/build_matrix.yml
CHANGED
data/ext/agent.yml
CHANGED
|
@@ -3,99 +3,99 @@
|
|
|
3
3
|
# appsignal-agent repository.
|
|
4
4
|
# Modifications to this file will be overwritten with the next agent release.
|
|
5
5
|
---
|
|
6
|
-
version:
|
|
6
|
+
version: 9b62288
|
|
7
7
|
mirrors:
|
|
8
8
|
- https://appsignal-agent-releases.global.ssl.fastly.net
|
|
9
9
|
- https://d135dj0rjqvssy.cloudfront.net
|
|
10
10
|
triples:
|
|
11
11
|
x86_64-darwin:
|
|
12
12
|
static:
|
|
13
|
-
checksum:
|
|
13
|
+
checksum: 5ff2ec4f16f5089e15188670b2c43866c76ab5db2ac07d72878a9816e63171ca
|
|
14
14
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
|
15
15
|
dynamic:
|
|
16
|
-
checksum:
|
|
16
|
+
checksum: c7b1ddd0efbd5fb5c48e7124ab13202c7b5fa2624354db66ebc2673d7196ce31
|
|
17
17
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
|
18
18
|
universal-darwin:
|
|
19
19
|
static:
|
|
20
|
-
checksum:
|
|
20
|
+
checksum: 5ff2ec4f16f5089e15188670b2c43866c76ab5db2ac07d72878a9816e63171ca
|
|
21
21
|
filename: appsignal-x86_64-darwin-all-static.tar.gz
|
|
22
22
|
dynamic:
|
|
23
|
-
checksum:
|
|
23
|
+
checksum: c7b1ddd0efbd5fb5c48e7124ab13202c7b5fa2624354db66ebc2673d7196ce31
|
|
24
24
|
filename: appsignal-x86_64-darwin-all-dynamic.tar.gz
|
|
25
25
|
aarch64-darwin:
|
|
26
26
|
static:
|
|
27
|
-
checksum:
|
|
27
|
+
checksum: 9dfdfd6697b3eeeb80a30356fdc1d03a79b8601f18cedd1b2c1442e512d2ed6a
|
|
28
28
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
|
29
29
|
dynamic:
|
|
30
|
-
checksum:
|
|
30
|
+
checksum: 1fe7a4e2b9e424ccce17c5c7422c84e29531507f672f6cebdd42a3f74feee0b9
|
|
31
31
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
|
32
32
|
arm64-darwin:
|
|
33
33
|
static:
|
|
34
|
-
checksum:
|
|
34
|
+
checksum: 9dfdfd6697b3eeeb80a30356fdc1d03a79b8601f18cedd1b2c1442e512d2ed6a
|
|
35
35
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
|
36
36
|
dynamic:
|
|
37
|
-
checksum:
|
|
37
|
+
checksum: 1fe7a4e2b9e424ccce17c5c7422c84e29531507f672f6cebdd42a3f74feee0b9
|
|
38
38
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
|
39
39
|
arm-darwin:
|
|
40
40
|
static:
|
|
41
|
-
checksum:
|
|
41
|
+
checksum: 9dfdfd6697b3eeeb80a30356fdc1d03a79b8601f18cedd1b2c1442e512d2ed6a
|
|
42
42
|
filename: appsignal-aarch64-darwin-all-static.tar.gz
|
|
43
43
|
dynamic:
|
|
44
|
-
checksum:
|
|
44
|
+
checksum: 1fe7a4e2b9e424ccce17c5c7422c84e29531507f672f6cebdd42a3f74feee0b9
|
|
45
45
|
filename: appsignal-aarch64-darwin-all-dynamic.tar.gz
|
|
46
46
|
aarch64-linux:
|
|
47
47
|
static:
|
|
48
|
-
checksum:
|
|
48
|
+
checksum: 0e5d89aeda1e883c912ff069bb76029a1e3cad69f493865d877ffaffa2b45142
|
|
49
49
|
filename: appsignal-aarch64-linux-all-static.tar.gz
|
|
50
50
|
dynamic:
|
|
51
|
-
checksum:
|
|
51
|
+
checksum: 58b09bf6ca7761a4d68cd9de87a0bb45b3465ace90b62a88d9fe77f629c26d7d
|
|
52
52
|
filename: appsignal-aarch64-linux-all-dynamic.tar.gz
|
|
53
53
|
i686-linux:
|
|
54
54
|
static:
|
|
55
|
-
checksum:
|
|
55
|
+
checksum: ff3cffb1204afd846ba0bb33c50b03f8ada8305527a5908ccfebed6fdcce0e61
|
|
56
56
|
filename: appsignal-i686-linux-all-static.tar.gz
|
|
57
57
|
dynamic:
|
|
58
|
-
checksum:
|
|
58
|
+
checksum: '0895a85c3df276864807f7b2572c96ea8c8cd3cc770b7cf02656c6bd01981b59'
|
|
59
59
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
|
60
60
|
x86-linux:
|
|
61
61
|
static:
|
|
62
|
-
checksum:
|
|
62
|
+
checksum: ff3cffb1204afd846ba0bb33c50b03f8ada8305527a5908ccfebed6fdcce0e61
|
|
63
63
|
filename: appsignal-i686-linux-all-static.tar.gz
|
|
64
64
|
dynamic:
|
|
65
|
-
checksum:
|
|
65
|
+
checksum: '0895a85c3df276864807f7b2572c96ea8c8cd3cc770b7cf02656c6bd01981b59'
|
|
66
66
|
filename: appsignal-i686-linux-all-dynamic.tar.gz
|
|
67
67
|
x86_64-linux:
|
|
68
68
|
static:
|
|
69
|
-
checksum:
|
|
69
|
+
checksum: 0b6fe4b343461a1a906fc73edb44bc5b12c75214d21fc81ed26d3eb88588003e
|
|
70
70
|
filename: appsignal-x86_64-linux-all-static.tar.gz
|
|
71
71
|
dynamic:
|
|
72
|
-
checksum:
|
|
72
|
+
checksum: 82117daf3e1c550526f74f4ec66c403bed22aa8600459b749858814589ed688b
|
|
73
73
|
filename: appsignal-x86_64-linux-all-dynamic.tar.gz
|
|
74
74
|
x86_64-linux-musl:
|
|
75
75
|
static:
|
|
76
|
-
checksum:
|
|
76
|
+
checksum: b3f52d7a7a1f4ae8095dd5b1207270dc1797766820d925aca0d09133983c9163
|
|
77
77
|
filename: appsignal-x86_64-linux-musl-all-static.tar.gz
|
|
78
78
|
dynamic:
|
|
79
|
-
checksum:
|
|
79
|
+
checksum: 5de9ddc90fc5beb308eadd5381ac0360692cb32e58dcaf0b0d7ecd3dabf44499
|
|
80
80
|
filename: appsignal-x86_64-linux-musl-all-dynamic.tar.gz
|
|
81
81
|
aarch64-linux-musl:
|
|
82
82
|
static:
|
|
83
|
-
checksum:
|
|
83
|
+
checksum: d306c50cc9f1bc8ea3339b4185b2a60a1c27f17d9067a529b1889d74c6c0a8d6
|
|
84
84
|
filename: appsignal-aarch64-linux-musl-all-static.tar.gz
|
|
85
85
|
dynamic:
|
|
86
|
-
checksum:
|
|
86
|
+
checksum: e3015e05a807ef5027ea8929a917873bcdaf714138ab5d6d028e3c855b3a61d3
|
|
87
87
|
filename: appsignal-aarch64-linux-musl-all-dynamic.tar.gz
|
|
88
88
|
x86_64-freebsd:
|
|
89
89
|
static:
|
|
90
|
-
checksum:
|
|
90
|
+
checksum: 135d2ff898f30b15721eca36569d1a0a5deaaee7b4787937d0888ed49f25019b
|
|
91
91
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
|
92
92
|
dynamic:
|
|
93
|
-
checksum:
|
|
93
|
+
checksum: 873aea3c808b7de431881f2f4b4dae686b20b309e76e3eefbb71e399ebea5284
|
|
94
94
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
|
95
95
|
amd64-freebsd:
|
|
96
96
|
static:
|
|
97
|
-
checksum:
|
|
97
|
+
checksum: 135d2ff898f30b15721eca36569d1a0a5deaaee7b4787937d0888ed49f25019b
|
|
98
98
|
filename: appsignal-x86_64-freebsd-all-static.tar.gz
|
|
99
99
|
dynamic:
|
|
100
|
-
checksum:
|
|
100
|
+
checksum: 873aea3c808b7de431881f2f4b4dae686b20b309e76e3eefbb71e399ebea5284
|
|
101
101
|
filename: appsignal-x86_64-freebsd-all-dynamic.tar.gz
|
data/ext/appsignal_extension.c
CHANGED
|
@@ -720,6 +720,26 @@ static VALUE close_span(VALUE self) {
|
|
|
720
720
|
return Qnil;
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
+
static VALUE a_log(VALUE self, VALUE group, VALUE severity, VALUE message, VALUE attributes) {
|
|
724
|
+
appsignal_data_t* attributes_data;
|
|
725
|
+
|
|
726
|
+
Check_Type(group, T_STRING);
|
|
727
|
+
Check_Type(severity, T_FIXNUM);
|
|
728
|
+
Check_Type(message, T_STRING);
|
|
729
|
+
Check_Type(attributes, RUBY_T_DATA);
|
|
730
|
+
|
|
731
|
+
Data_Get_Struct(attributes, appsignal_data_t, attributes_data);
|
|
732
|
+
|
|
733
|
+
appsignal_log(
|
|
734
|
+
make_appsignal_string(group),
|
|
735
|
+
FIX2INT(severity),
|
|
736
|
+
make_appsignal_string(message),
|
|
737
|
+
attributes_data
|
|
738
|
+
);
|
|
739
|
+
|
|
740
|
+
return Qnil;
|
|
741
|
+
}
|
|
742
|
+
|
|
723
743
|
static VALUE set_gauge(VALUE self, VALUE key, VALUE value, VALUE tags) {
|
|
724
744
|
appsignal_data_t* tags_data;
|
|
725
745
|
|
|
@@ -834,6 +854,8 @@ void Init_appsignal_extension(void) {
|
|
|
834
854
|
rb_define_singleton_method(Extension, "stop", stop, 0);
|
|
835
855
|
// Diagnostics
|
|
836
856
|
rb_define_singleton_method(Extension, "diagnose", diagnose, 0);
|
|
857
|
+
// Logging
|
|
858
|
+
rb_define_singleton_method(Extension, "log", a_log, 4);
|
|
837
859
|
|
|
838
860
|
// Server state
|
|
839
861
|
rb_define_singleton_method(Extension, "get_server_state", get_server_state, 1);
|
data/lib/appsignal/config.rb
CHANGED
|
@@ -25,10 +25,12 @@ module Appsignal
|
|
|
25
25
|
:ignore_actions => [],
|
|
26
26
|
:ignore_errors => [],
|
|
27
27
|
:ignore_namespaces => [],
|
|
28
|
+
:instrument_http_rb => true,
|
|
28
29
|
:instrument_net_http => true,
|
|
29
30
|
:instrument_redis => true,
|
|
30
31
|
:instrument_sequel => true,
|
|
31
32
|
:log => "file",
|
|
33
|
+
:logging_endpoint => "https://appsignal-endpoint.net",
|
|
32
34
|
:request_headers => %w[
|
|
33
35
|
HTTP_ACCEPT HTTP_ACCEPT_CHARSET HTTP_ACCEPT_ENCODING
|
|
34
36
|
HTTP_ACCEPT_LANGUAGE HTTP_CACHE_CONTROL HTTP_CONNECTION
|
|
@@ -42,17 +44,17 @@ module Appsignal
|
|
|
42
44
|
}.freeze
|
|
43
45
|
|
|
44
46
|
# @api private
|
|
45
|
-
DEFAULT_LOG_LEVEL = Logger::INFO
|
|
47
|
+
DEFAULT_LOG_LEVEL = ::Logger::INFO
|
|
46
48
|
# Map from the `log_level` config option to Ruby's Logger level value.
|
|
47
49
|
#
|
|
48
50
|
# The trace level doesn't exist in the Ruby logger so it's mapped to debug.
|
|
49
51
|
# @api private
|
|
50
52
|
LOG_LEVEL_MAP = {
|
|
51
|
-
"error" => Logger::ERROR,
|
|
52
|
-
"warn" => Logger::WARN,
|
|
53
|
-
"info" => Logger::INFO,
|
|
54
|
-
"debug" => Logger::DEBUG,
|
|
55
|
-
"trace" => Logger::DEBUG
|
|
53
|
+
"error" => ::Logger::ERROR,
|
|
54
|
+
"warn" => ::Logger::WARN,
|
|
55
|
+
"info" => ::Logger::INFO,
|
|
56
|
+
"debug" => ::Logger::DEBUG,
|
|
57
|
+
"trace" => ::Logger::DEBUG
|
|
56
58
|
}.freeze
|
|
57
59
|
|
|
58
60
|
ENV_TO_KEY_MAPPING = {
|
|
@@ -73,12 +75,14 @@ module Appsignal
|
|
|
73
75
|
"APPSIGNAL_IGNORE_ACTIONS" => :ignore_actions,
|
|
74
76
|
"APPSIGNAL_IGNORE_ERRORS" => :ignore_errors,
|
|
75
77
|
"APPSIGNAL_IGNORE_NAMESPACES" => :ignore_namespaces,
|
|
78
|
+
"APPSIGNAL_INSTRUMENT_HTTP_RB" => :instrument_http_rb,
|
|
76
79
|
"APPSIGNAL_INSTRUMENT_NET_HTTP" => :instrument_net_http,
|
|
77
80
|
"APPSIGNAL_INSTRUMENT_REDIS" => :instrument_redis,
|
|
78
81
|
"APPSIGNAL_INSTRUMENT_SEQUEL" => :instrument_sequel,
|
|
79
82
|
"APPSIGNAL_LOG" => :log,
|
|
80
83
|
"APPSIGNAL_LOG_LEVEL" => :log_level,
|
|
81
84
|
"APPSIGNAL_LOG_PATH" => :log_path,
|
|
85
|
+
"APPSIGNAL_LOGGING_ENDPOINT" => :logging_endpoint,
|
|
82
86
|
"APPSIGNAL_PUSH_API_ENDPOINT" => :endpoint,
|
|
83
87
|
"APPSIGNAL_PUSH_API_KEY" => :push_api_key,
|
|
84
88
|
"APPSIGNAL_REQUEST_HEADERS" => :request_headers,
|
|
@@ -101,6 +105,7 @@ module Appsignal
|
|
|
101
105
|
APPSIGNAL_LOG
|
|
102
106
|
APPSIGNAL_LOG_LEVEL
|
|
103
107
|
APPSIGNAL_LOG_PATH
|
|
108
|
+
APPSIGNAL_LOGGING_ENDPOINT
|
|
104
109
|
APPSIGNAL_PUSH_API_ENDPOINT
|
|
105
110
|
APPSIGNAL_PUSH_API_KEY
|
|
106
111
|
APPSIGNAL_WORKING_DIRECTORY_PATH
|
|
@@ -116,6 +121,7 @@ module Appsignal
|
|
|
116
121
|
APPSIGNAL_ENABLE_MINUTELY_PROBES
|
|
117
122
|
APPSIGNAL_ENABLE_STATSD
|
|
118
123
|
APPSIGNAL_FILES_WORLD_ACCESSIBLE
|
|
124
|
+
APPSIGNAL_INSTRUMENT_HTTP_RB
|
|
119
125
|
APPSIGNAL_INSTRUMENT_NET_HTTP
|
|
120
126
|
APPSIGNAL_INSTRUMENT_REDIS
|
|
121
127
|
APPSIGNAL_INSTRUMENT_SEQUEL
|
|
@@ -260,7 +266,7 @@ module Appsignal
|
|
|
260
266
|
|
|
261
267
|
def log_level
|
|
262
268
|
if config_hash[:debug] || config_hash[:transaction_debug_mode]
|
|
263
|
-
level = Logger::DEBUG
|
|
269
|
+
level = ::Logger::DEBUG
|
|
264
270
|
end
|
|
265
271
|
option = config_hash[:log_level]
|
|
266
272
|
if option
|
|
@@ -320,6 +326,7 @@ module Appsignal
|
|
|
320
326
|
ENV["_APPSIGNAL_LOG"] = config_hash[:log]
|
|
321
327
|
ENV["_APPSIGNAL_LOG_LEVEL"] = config_hash[:log_level]
|
|
322
328
|
ENV["_APPSIGNAL_LOG_FILE_PATH"] = log_file_path.to_s if log_file_path
|
|
329
|
+
ENV["_APPSIGNAL_LOGGING_ENDPOINT"] = config_hash[:logging_endpoint]
|
|
323
330
|
ENV["_APPSIGNAL_PROCESS_NAME"] = $PROGRAM_NAME
|
|
324
331
|
ENV["_APPSIGNAL_PUSH_API_ENDPOINT"] = config_hash[:endpoint]
|
|
325
332
|
ENV["_APPSIGNAL_PUSH_API_KEY"] = config_hash[:push_api_key]
|
|
@@ -81,6 +81,11 @@ module Appsignal
|
|
|
81
81
|
[:appsignal_string, :double, :pointer],
|
|
82
82
|
:void
|
|
83
83
|
|
|
84
|
+
# Logging methods
|
|
85
|
+
attach_function :appsignal_log,
|
|
86
|
+
[:appsignal_string, :int32, :appsignal_string, :pointer],
|
|
87
|
+
:void
|
|
88
|
+
|
|
84
89
|
# Transaction methods
|
|
85
90
|
attach_function :appsignal_free_transaction,
|
|
86
91
|
[:pointer],
|
|
@@ -264,6 +269,15 @@ module Appsignal
|
|
|
264
269
|
make_ruby_string state if state[:len] > 0
|
|
265
270
|
end
|
|
266
271
|
|
|
272
|
+
def log(group, level, message, attributes)
|
|
273
|
+
appsignal_log(
|
|
274
|
+
make_appsignal_string(group),
|
|
275
|
+
level,
|
|
276
|
+
make_appsignal_string(message),
|
|
277
|
+
attributes.pointer
|
|
278
|
+
)
|
|
279
|
+
end
|
|
280
|
+
|
|
267
281
|
def start_transaction(transaction_id, namespace, gc_duration_ms)
|
|
268
282
|
transaction = appsignal_start_transaction(
|
|
269
283
|
make_appsignal_string(transaction_id),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Appsignal
|
|
4
|
+
class Hooks
|
|
5
|
+
# @api private
|
|
6
|
+
class HttpHook < Appsignal::Hooks::Hook
|
|
7
|
+
register :http_rb
|
|
8
|
+
|
|
9
|
+
def dependencies_present?
|
|
10
|
+
defined?(HTTP::Client) && Appsignal.config && Appsignal.config[:instrument_http_rb]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def install
|
|
14
|
+
require "appsignal/integrations/http"
|
|
15
|
+
HTTP::Client.send(:prepend, Appsignal::Integrations::HttpIntegration)
|
|
16
|
+
|
|
17
|
+
Appsignal::Environment.report_enabled("http_rb")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/appsignal/hooks.rb
CHANGED
|
@@ -94,6 +94,7 @@ require "appsignal/hooks/active_job"
|
|
|
94
94
|
require "appsignal/hooks/active_support_notifications"
|
|
95
95
|
require "appsignal/hooks/celluloid"
|
|
96
96
|
require "appsignal/hooks/delayed_job"
|
|
97
|
+
require "appsignal/hooks/http"
|
|
97
98
|
require "appsignal/hooks/mri"
|
|
98
99
|
require "appsignal/hooks/net_http"
|
|
99
100
|
require "appsignal/hooks/passenger"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Appsignal
|
|
4
|
+
module Integrations
|
|
5
|
+
module HttpIntegration
|
|
6
|
+
def request(verb, uri, opts = {})
|
|
7
|
+
parsed_request_uri = URI.parse(uri)
|
|
8
|
+
request_uri = "#{parsed_request_uri.scheme}://#{parsed_request_uri.host}"
|
|
9
|
+
|
|
10
|
+
begin
|
|
11
|
+
Appsignal.instrument("request.http_rb", "#{verb.upcase} #{request_uri}") do
|
|
12
|
+
super
|
|
13
|
+
end
|
|
14
|
+
rescue Exception => error # rubocop:disable Lint/RescueException
|
|
15
|
+
Appsignal.set_error(error)
|
|
16
|
+
raise error
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lib/appsignal/logger.rb
CHANGED
|
@@ -3,20 +3,137 @@
|
|
|
3
3
|
require "logger"
|
|
4
4
|
require "set"
|
|
5
5
|
|
|
6
|
-
# Subclass of logger with method to only log a warning once
|
|
7
|
-
# prevents the log from filling up with repeated messages.
|
|
8
6
|
module Appsignal
|
|
7
|
+
# Logger that flushes logs to the AppSignal logging service
|
|
9
8
|
class Logger < ::Logger
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
# Create a new logger instance
|
|
10
|
+
#
|
|
11
|
+
# @param group Name of the group for this logger.
|
|
12
|
+
# @param level Log level to filter with
|
|
13
|
+
# @return [void]
|
|
14
|
+
def initialize(group, level = INFO)
|
|
15
|
+
raise TypeError, "group must be a string" unless group.is_a? String
|
|
16
|
+
@group = group
|
|
17
|
+
@level = level
|
|
12
18
|
end
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
# We support the various methods in the Ruby
|
|
21
|
+
# logger class by supplying this method.
|
|
22
|
+
# @api private
|
|
23
|
+
def add(severity, message = nil, group = nil)
|
|
24
|
+
severity ||= UNKNOWN
|
|
25
|
+
return true if severity < level
|
|
26
|
+
group = @group if group.nil?
|
|
27
|
+
if message.nil?
|
|
28
|
+
if block_given?
|
|
29
|
+
message = yield
|
|
30
|
+
else
|
|
31
|
+
message = progname
|
|
32
|
+
group = @group
|
|
33
|
+
end
|
|
19
34
|
end
|
|
35
|
+
return if message.nil?
|
|
36
|
+
severity_number = case severity
|
|
37
|
+
when DEBUG
|
|
38
|
+
2
|
|
39
|
+
when INFO
|
|
40
|
+
3
|
|
41
|
+
when WARN
|
|
42
|
+
5
|
|
43
|
+
when ERROR
|
|
44
|
+
6
|
|
45
|
+
when FATAL
|
|
46
|
+
7
|
|
47
|
+
else
|
|
48
|
+
0
|
|
49
|
+
end
|
|
50
|
+
Appsignal::Extension.log(
|
|
51
|
+
group,
|
|
52
|
+
severity_number,
|
|
53
|
+
message,
|
|
54
|
+
Appsignal::Utils::Data.generate({})
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
alias log add
|
|
58
|
+
|
|
59
|
+
# Log a debug level message
|
|
60
|
+
# @param message Mesage to log
|
|
61
|
+
# @param attributes Attributes to tag the log with
|
|
62
|
+
# @return [void]
|
|
63
|
+
def debug(message = nil, attributes = {})
|
|
64
|
+
return if DEBUG < level
|
|
65
|
+
message = yield if message.nil? && block_given?
|
|
66
|
+
return if message.nil?
|
|
67
|
+
Appsignal::Extension.log(
|
|
68
|
+
@group,
|
|
69
|
+
2,
|
|
70
|
+
message,
|
|
71
|
+
Appsignal::Utils::Data.generate(attributes)
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Log an info level message
|
|
76
|
+
# @param message Mesage to log
|
|
77
|
+
# @param attributes Attributes to tag the log with
|
|
78
|
+
# @return [void]
|
|
79
|
+
def info(message = nil, attributes = {})
|
|
80
|
+
return if INFO < level
|
|
81
|
+
message = yield if message.nil? && block_given?
|
|
82
|
+
return if message.nil?
|
|
83
|
+
Appsignal::Extension.log(
|
|
84
|
+
@group,
|
|
85
|
+
3,
|
|
86
|
+
message,
|
|
87
|
+
Appsignal::Utils::Data.generate(attributes)
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Log a warn level message
|
|
92
|
+
# @param message Mesage to log
|
|
93
|
+
# @param attributes Attributes to tag the log with
|
|
94
|
+
# @return [void]
|
|
95
|
+
def warn(message = nil, attributes = {})
|
|
96
|
+
return if WARN < level
|
|
97
|
+
message = yield if message.nil? && block_given?
|
|
98
|
+
return if message.nil?
|
|
99
|
+
Appsignal::Extension.log(
|
|
100
|
+
@group,
|
|
101
|
+
5,
|
|
102
|
+
message,
|
|
103
|
+
Appsignal::Utils::Data.generate(attributes)
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Log an error level message
|
|
108
|
+
# @param message Mesage to log
|
|
109
|
+
# @param attributes Attributes to tag the log with
|
|
110
|
+
# @return [void]
|
|
111
|
+
def error(message = nil, attributes = {})
|
|
112
|
+
return if ERROR < level
|
|
113
|
+
message = yield if message.nil? && block_given?
|
|
114
|
+
return if message.nil?
|
|
115
|
+
Appsignal::Extension.log(
|
|
116
|
+
@group,
|
|
117
|
+
6,
|
|
118
|
+
message,
|
|
119
|
+
Appsignal::Utils::Data.generate(attributes)
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Log a fatal level message
|
|
124
|
+
# @param message Mesage to log
|
|
125
|
+
# @param attributes Attributes to tag the log with
|
|
126
|
+
# @return [void]
|
|
127
|
+
def fatal(message = nil, attributes = {})
|
|
128
|
+
return if FATAL < level
|
|
129
|
+
message = yield if message.nil? && block_given?
|
|
130
|
+
return if message.nil?
|
|
131
|
+
Appsignal::Extension.log(
|
|
132
|
+
@group,
|
|
133
|
+
7,
|
|
134
|
+
message,
|
|
135
|
+
Appsignal::Utils::Data.generate(attributes)
|
|
136
|
+
)
|
|
20
137
|
end
|
|
21
138
|
end
|
|
22
139
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Appsignal
|
|
2
|
+
module Utils
|
|
3
|
+
# Subclass of logger with method to only log a warning once
|
|
4
|
+
# prevents the local log from filling up with repeated messages.
|
|
5
|
+
class IntegrationLogger < ::Logger
|
|
6
|
+
def seen_keys
|
|
7
|
+
@seen_keys ||= Set.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def warn_once_then_debug(key, message)
|
|
11
|
+
if !seen_keys.add?(key).nil?
|
|
12
|
+
warn message
|
|
13
|
+
else
|
|
14
|
+
debug message
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/appsignal/utils.rb
CHANGED
data/lib/appsignal/version.rb
CHANGED
data/lib/appsignal.rb
CHANGED
|
@@ -175,8 +175,8 @@ module Appsignal
|
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
def logger
|
|
178
|
-
@logger ||= Appsignal::
|
|
179
|
-
l.level = Logger::INFO
|
|
178
|
+
@logger ||= Appsignal::Utils::IntegrationLogger.new(in_memory_log).tap do |l|
|
|
179
|
+
l.level = ::Logger::INFO
|
|
180
180
|
l.formatter = log_formatter("appsignal")
|
|
181
181
|
end
|
|
182
182
|
end
|
|
@@ -254,12 +254,12 @@ module Appsignal
|
|
|
254
254
|
private
|
|
255
255
|
|
|
256
256
|
def start_stdout_logger
|
|
257
|
-
@logger = Appsignal::
|
|
257
|
+
@logger = Appsignal::Utils::IntegrationLogger.new($stdout)
|
|
258
258
|
logger.formatter = log_formatter("appsignal")
|
|
259
259
|
end
|
|
260
260
|
|
|
261
261
|
def start_file_logger(path)
|
|
262
|
-
@logger = Appsignal::
|
|
262
|
+
@logger = Appsignal::Utils::IntegrationLogger.new(path)
|
|
263
263
|
logger.formatter = log_formatter
|
|
264
264
|
rescue SystemCallError => error
|
|
265
265
|
start_stdout_logger
|
|
@@ -166,10 +166,12 @@ describe Appsignal::Config do
|
|
|
166
166
|
:ignore_actions => [],
|
|
167
167
|
:ignore_errors => [],
|
|
168
168
|
:ignore_namespaces => [],
|
|
169
|
+
:instrument_http_rb => true,
|
|
169
170
|
:instrument_net_http => true,
|
|
170
171
|
:instrument_redis => true,
|
|
171
172
|
:instrument_sequel => true,
|
|
172
173
|
:log => "file",
|
|
174
|
+
:logging_endpoint => "https://appsignal-endpoint.net",
|
|
173
175
|
:name => "TestApp",
|
|
174
176
|
:push_api_key => "abc",
|
|
175
177
|
:request_headers => [],
|
|
@@ -536,6 +538,18 @@ describe Appsignal::Config do
|
|
|
536
538
|
end
|
|
537
539
|
end
|
|
538
540
|
end
|
|
541
|
+
|
|
542
|
+
describe ":logging_endpoint" do
|
|
543
|
+
subject { config[:logging_endpoint] }
|
|
544
|
+
|
|
545
|
+
context "with a non-standard port" do
|
|
546
|
+
let(:config) { project_fixture_config("production", :logging_endpoint => "http://localhost:4567") }
|
|
547
|
+
|
|
548
|
+
it "keeps the port" do
|
|
549
|
+
expect(subject).to eq "http://localhost:4567"
|
|
550
|
+
end
|
|
551
|
+
end
|
|
552
|
+
end
|
|
539
553
|
end
|
|
540
554
|
|
|
541
555
|
describe "#[]" do
|
|
@@ -577,6 +591,7 @@ describe Appsignal::Config do
|
|
|
577
591
|
describe "#write_to_environment" do
|
|
578
592
|
let(:config) { project_fixture_config(:production) }
|
|
579
593
|
before do
|
|
594
|
+
config[:logging_endpoint] = "http://localhost:123"
|
|
580
595
|
config[:http_proxy] = "http://localhost"
|
|
581
596
|
config[:ignore_actions] = %w[action1 action2]
|
|
582
597
|
config[:ignore_errors] = %w[ExampleStandardError AnotherError]
|
|
@@ -600,6 +615,7 @@ describe Appsignal::Config do
|
|
|
600
615
|
expect(ENV["_APPSIGNAL_DEBUG_LOGGING"]).to eq "false"
|
|
601
616
|
expect(ENV["_APPSIGNAL_LOG"]).to eq "stdout"
|
|
602
617
|
expect(ENV["_APPSIGNAL_LOG_FILE_PATH"]).to end_with("/tmp/appsignal.log")
|
|
618
|
+
expect(ENV["_APPSIGNAL_LOGGING_ENDPOINT"]).to eq "http://localhost:123"
|
|
603
619
|
expect(ENV["_APPSIGNAL_PUSH_API_ENDPOINT"]).to eq "https://push.appsignal.com"
|
|
604
620
|
expect(ENV["_APPSIGNAL_PUSH_API_KEY"]).to eq "abc"
|
|
605
621
|
expect(ENV["_APPSIGNAL_APP_NAME"]).to eq "TestApp"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe Appsignal::Hooks::HttpHook do
|
|
4
|
+
before :context do
|
|
5
|
+
start_agent
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
if DependencyHelper.http_present?
|
|
9
|
+
context "with instrument_http_rb set to true" do
|
|
10
|
+
describe "#dependencies_present?" do
|
|
11
|
+
subject { described_class.new.dependencies_present? }
|
|
12
|
+
|
|
13
|
+
it { is_expected.to be_truthy }
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "installs the HTTP plugin" do
|
|
17
|
+
expect(HTTP::Client.included_modules)
|
|
18
|
+
.to include(Appsignal::Integrations::HttpIntegration)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
context "with instrument_http_rb set to false" do
|
|
23
|
+
before { Appsignal.config.config_hash[:instrument_http_rb] = false }
|
|
24
|
+
after { Appsignal.config.config_hash[:instrument_http_rb] = true }
|
|
25
|
+
|
|
26
|
+
describe "#dependencies_present?" do
|
|
27
|
+
subject { described_class.new.dependencies_present? }
|
|
28
|
+
|
|
29
|
+
it { is_expected.to be_falsy }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
describe "#dependencies_present?" do
|
|
34
|
+
subject { described_class.new.dependencies_present? }
|
|
35
|
+
|
|
36
|
+
it { is_expected.to be_falsy }
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
if DependencyHelper.http_present?
|
|
4
|
+
require "appsignal/integrations/http"
|
|
5
|
+
|
|
6
|
+
describe Appsignal::Integrations::HttpIntegration do
|
|
7
|
+
let(:transaction) { http_request_transaction }
|
|
8
|
+
|
|
9
|
+
around do |example|
|
|
10
|
+
keep_transactions { example.run }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
before :context do
|
|
14
|
+
start_agent
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
before do
|
|
18
|
+
set_current_transaction(transaction)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "instruments a HTTP request" do
|
|
22
|
+
stub_request(:get, "http://www.google.com")
|
|
23
|
+
|
|
24
|
+
HTTP.get("http://www.google.com")
|
|
25
|
+
|
|
26
|
+
transaction_hash = transaction.to_h
|
|
27
|
+
expect(transaction_hash).to include("namespace" => Appsignal::Transaction::HTTP_REQUEST)
|
|
28
|
+
expect(transaction_hash["events"].first).to include(
|
|
29
|
+
"body" => "",
|
|
30
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
|
31
|
+
"name" => "request.http_rb",
|
|
32
|
+
"title" => "GET http://www.google.com"
|
|
33
|
+
)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "instruments a HTTPS request" do
|
|
37
|
+
stub_request(:get, "https://www.google.com")
|
|
38
|
+
|
|
39
|
+
HTTP.get("https://www.google.com")
|
|
40
|
+
|
|
41
|
+
transaction_hash = transaction.to_h
|
|
42
|
+
expect(transaction_hash).to include("namespace" => Appsignal::Transaction::HTTP_REQUEST)
|
|
43
|
+
expect(transaction_hash["events"].first).to include(
|
|
44
|
+
"body" => "",
|
|
45
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
|
46
|
+
"name" => "request.http_rb",
|
|
47
|
+
"title" => "GET https://www.google.com"
|
|
48
|
+
)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "with request parameters" do
|
|
52
|
+
it "does not include the query parameters in the title" do
|
|
53
|
+
stub_request(:get, "https://www.google.com?q=Appsignal")
|
|
54
|
+
|
|
55
|
+
HTTP.get("https://www.google.com", :params => { :q => "Appsignal" })
|
|
56
|
+
|
|
57
|
+
expect(transaction.to_h["events"].first).to include(
|
|
58
|
+
"body" => "",
|
|
59
|
+
"title" => "GET https://www.google.com"
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "does not include the request body in the title" do
|
|
64
|
+
stub_request(:post, "https://www.google.com")
|
|
65
|
+
.with(:body => { :q => "Appsignal" }.to_json)
|
|
66
|
+
|
|
67
|
+
HTTP.post("https://www.google.com", :json => { :q => "Appsignal" })
|
|
68
|
+
|
|
69
|
+
expect(transaction.to_h["events"].first).to include(
|
|
70
|
+
"body" => "",
|
|
71
|
+
"title" => "POST https://www.google.com"
|
|
72
|
+
)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "with an HTTP exception" do
|
|
77
|
+
let(:error) { ExampleException.new("oh no!") }
|
|
78
|
+
|
|
79
|
+
it "reports the exception and re-raises it" do
|
|
80
|
+
stub_request(:get, "https://www.google.com").and_raise(error)
|
|
81
|
+
|
|
82
|
+
expect do
|
|
83
|
+
HTTP.get("https://www.google.com")
|
|
84
|
+
end.to raise_error(ExampleException)
|
|
85
|
+
|
|
86
|
+
transaction_hash = transaction.to_h
|
|
87
|
+
expect(transaction_hash).to include("namespace" => Appsignal::Transaction::HTTP_REQUEST)
|
|
88
|
+
expect(transaction_hash["events"].first).to include(
|
|
89
|
+
"body" => "",
|
|
90
|
+
"body_format" => Appsignal::EventFormatter::DEFAULT,
|
|
91
|
+
"name" => "request.http_rb",
|
|
92
|
+
"title" => "GET https://www.google.com"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
expect(transaction_hash["error"]).to include(
|
|
96
|
+
"backtrace" => kind_of(String),
|
|
97
|
+
"name" => error.class.name,
|
|
98
|
+
"message" => error.message
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -1,25 +1,94 @@
|
|
|
1
1
|
describe Appsignal::Logger do
|
|
2
|
-
let(:
|
|
3
|
-
let(:logger)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
let(:level) { ::Logger::DEBUG }
|
|
3
|
+
let(:logger) { Appsignal::Logger.new("group", level) }
|
|
4
|
+
|
|
5
|
+
it "should not create a logger with a nil group" do
|
|
6
|
+
expect do
|
|
7
|
+
Appsignal::Logger.new(nil, level)
|
|
8
|
+
end.to raise_error(TypeError)
|
|
7
9
|
end
|
|
8
10
|
|
|
9
|
-
describe "#
|
|
10
|
-
it "
|
|
11
|
-
expect(
|
|
11
|
+
describe "#add" do
|
|
12
|
+
it "should log with a level and message" do
|
|
13
|
+
expect(Appsignal::Extension).to receive(:log)
|
|
14
|
+
.with("group", 3, "Log message", instance_of(Appsignal::Extension::Data))
|
|
15
|
+
logger.add(::Logger::INFO, "Log message")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should log with a block" do
|
|
19
|
+
expect(Appsignal::Extension).to receive(:log)
|
|
20
|
+
.with("group", 3, "Log message", instance_of(Appsignal::Extension::Data))
|
|
21
|
+
logger.add(::Logger::INFO) do
|
|
22
|
+
"Log message"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "should log with a level, message and group" do
|
|
27
|
+
expect(Appsignal::Extension).to receive(:log)
|
|
28
|
+
.with("other_group", 3, "Log message", instance_of(Appsignal::Extension::Data))
|
|
29
|
+
logger.add(::Logger::INFO, "Log message", "other_group")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should return with a nil message" do
|
|
33
|
+
expect(Appsignal::Extension).not_to receive(:log)
|
|
34
|
+
logger.add(::Logger::INFO, nil)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context "with debug log level" do
|
|
38
|
+
let(:level) { ::Logger::INFO }
|
|
39
|
+
|
|
40
|
+
it "should skip logging if the level is too low" do
|
|
41
|
+
expect(Appsignal::Extension).not_to receive(:log)
|
|
42
|
+
logger.add(::Logger::DEBUG, "Log message")
|
|
43
|
+
end
|
|
12
44
|
end
|
|
13
45
|
end
|
|
14
46
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
[
|
|
48
|
+
["debug", 2, ::Logger::INFO],
|
|
49
|
+
["info", 3, ::Logger::WARN],
|
|
50
|
+
["warn", 5, ::Logger::ERROR],
|
|
51
|
+
["error", 6, ::Logger::FATAL],
|
|
52
|
+
["fatal", 7, nil]
|
|
53
|
+
].each do |method|
|
|
54
|
+
describe "##{method[0]}" do
|
|
55
|
+
it "should log with a message" do
|
|
56
|
+
expect(Appsignal::Utils::Data).to receive(:generate)
|
|
57
|
+
.with({})
|
|
58
|
+
.and_call_original
|
|
59
|
+
expect(Appsignal::Extension).to receive(:log)
|
|
60
|
+
.with("group", method[1], "Log message", instance_of(Appsignal::Extension::Data))
|
|
61
|
+
|
|
62
|
+
logger.send(method[0], "Log message")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should log with a block" do
|
|
66
|
+
expect(Appsignal::Utils::Data).to receive(:generate)
|
|
67
|
+
.with({})
|
|
68
|
+
.and_call_original
|
|
69
|
+
expect(Appsignal::Extension).to receive(:log)
|
|
70
|
+
.with("group", method[1], "Log message", instance_of(Appsignal::Extension::Data))
|
|
71
|
+
|
|
72
|
+
logger.send(method[0]) do
|
|
73
|
+
"Log message"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should return with a nil message" do
|
|
78
|
+
expect(Appsignal::Extension).not_to receive(:log)
|
|
79
|
+
logger.send(method[0])
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if method[2]
|
|
83
|
+
context "with a lower log level" do
|
|
84
|
+
let(:level) { method[2] }
|
|
19
85
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
86
|
+
it "should skip logging if the level is too low" do
|
|
87
|
+
expect(Appsignal::Extension).not_to receive(:log)
|
|
88
|
+
logger.send(method[0], "Log message")
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
23
92
|
end
|
|
24
93
|
end
|
|
25
94
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
describe Appsignal::Utils::IntegrationLogger do
|
|
2
|
+
let(:log) { std_stream }
|
|
3
|
+
let(:logger) do
|
|
4
|
+
Appsignal::Utils::IntegrationLogger.new(log).tap do |l|
|
|
5
|
+
l.formatter = logger_formatter
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe "#seen_keys" do
|
|
10
|
+
it "returns a Set" do
|
|
11
|
+
expect(logger.seen_keys).to be_a(Set)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe "#warn_once_then_debug" do
|
|
16
|
+
it "only warns once, then uses debug" do
|
|
17
|
+
message = "This is a log line"
|
|
18
|
+
3.times { logger.warn_once_then_debug(:key, message) }
|
|
19
|
+
|
|
20
|
+
logs = log_contents(log)
|
|
21
|
+
expect(logs.scan(/#{Regexp.escape(log_line(:WARN, message))}/).count).to eql(1)
|
|
22
|
+
expect(logs.scan(/#{Regexp.escape(log_line(:DEBUG, message))}/).count).to eql(2)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/spec/lib/appsignal_spec.rb
CHANGED
|
@@ -1127,7 +1127,7 @@ describe Appsignal do
|
|
|
1127
1127
|
Appsignal.start_logger
|
|
1128
1128
|
Appsignal.logger.error("Log to file")
|
|
1129
1129
|
end
|
|
1130
|
-
expect(Appsignal.logger).to be_a(Appsignal::
|
|
1130
|
+
expect(Appsignal.logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
|
1131
1131
|
end
|
|
1132
1132
|
|
|
1133
1133
|
it "logs to file" do
|
|
@@ -1150,7 +1150,7 @@ describe Appsignal do
|
|
|
1150
1150
|
initialize_config
|
|
1151
1151
|
Appsignal.start_logger
|
|
1152
1152
|
Appsignal.logger.error("Log to not writable log file")
|
|
1153
|
-
expect(Appsignal.logger).to be_a(Appsignal::
|
|
1153
|
+
expect(Appsignal.logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
|
1154
1154
|
end
|
|
1155
1155
|
end
|
|
1156
1156
|
|
|
@@ -1181,7 +1181,7 @@ describe Appsignal do
|
|
|
1181
1181
|
Appsignal.start_logger
|
|
1182
1182
|
Appsignal.logger.error("Log to not writable log path")
|
|
1183
1183
|
end
|
|
1184
|
-
expect(Appsignal.logger).to be_a(Appsignal::
|
|
1184
|
+
expect(Appsignal.logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
|
1185
1185
|
end
|
|
1186
1186
|
after do
|
|
1187
1187
|
FileUtils.chmod 0o755, Appsignal::Config.system_tmp_dir
|
|
@@ -1210,7 +1210,7 @@ describe Appsignal do
|
|
|
1210
1210
|
Appsignal.start_logger
|
|
1211
1211
|
Appsignal.logger.error("Log to stdout")
|
|
1212
1212
|
end
|
|
1213
|
-
expect(Appsignal.logger).to be_a(Appsignal::
|
|
1213
|
+
expect(Appsignal.logger).to be_a(Appsignal::Utils::IntegrationLogger)
|
|
1214
1214
|
end
|
|
1215
1215
|
around { |example| recognize_as_heroku { example.run } }
|
|
1216
1216
|
|
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: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Robert Beekman
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2022-11-
|
|
13
|
+
date: 2022-11-18 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rack
|
|
@@ -175,6 +175,7 @@ files:
|
|
|
175
175
|
- gemfiles/capistrano2.gemfile
|
|
176
176
|
- gemfiles/capistrano3.gemfile
|
|
177
177
|
- gemfiles/grape.gemfile
|
|
178
|
+
- gemfiles/http5.gemfile
|
|
178
179
|
- gemfiles/no_dependencies.gemfile
|
|
179
180
|
- gemfiles/padrino.gemfile
|
|
180
181
|
- gemfiles/psych-3.gemfile
|
|
@@ -230,6 +231,7 @@ files:
|
|
|
230
231
|
- lib/appsignal/hooks/data_mapper.rb
|
|
231
232
|
- lib/appsignal/hooks/delayed_job.rb
|
|
232
233
|
- lib/appsignal/hooks/excon.rb
|
|
234
|
+
- lib/appsignal/hooks/http.rb
|
|
233
235
|
- lib/appsignal/hooks/mongo_ruby_driver.rb
|
|
234
236
|
- lib/appsignal/hooks/mri.rb
|
|
235
237
|
- lib/appsignal/hooks/net_http.rb
|
|
@@ -252,6 +254,7 @@ files:
|
|
|
252
254
|
- lib/appsignal/integrations/delayed_job_plugin.rb
|
|
253
255
|
- lib/appsignal/integrations/excon.rb
|
|
254
256
|
- lib/appsignal/integrations/grape.rb
|
|
257
|
+
- lib/appsignal/integrations/http.rb
|
|
255
258
|
- lib/appsignal/integrations/mongo_ruby_driver.rb
|
|
256
259
|
- lib/appsignal/integrations/net_http.rb
|
|
257
260
|
- lib/appsignal/integrations/object.rb
|
|
@@ -284,6 +287,7 @@ files:
|
|
|
284
287
|
- lib/appsignal/utils/data.rb
|
|
285
288
|
- lib/appsignal/utils/deprecation_message.rb
|
|
286
289
|
- lib/appsignal/utils/hash_sanitizer.rb
|
|
290
|
+
- lib/appsignal/utils/integration_logger.rb
|
|
287
291
|
- lib/appsignal/utils/json.rb
|
|
288
292
|
- lib/appsignal/utils/query_params_sanitizer.rb
|
|
289
293
|
- lib/appsignal/utils/rails_helper.rb
|
|
@@ -331,6 +335,7 @@ files:
|
|
|
331
335
|
- spec/lib/appsignal/hooks/data_mapper_spec.rb
|
|
332
336
|
- spec/lib/appsignal/hooks/delayed_job_spec.rb
|
|
333
337
|
- spec/lib/appsignal/hooks/excon_spec.rb
|
|
338
|
+
- spec/lib/appsignal/hooks/http_spec.rb
|
|
334
339
|
- spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
|
|
335
340
|
- spec/lib/appsignal/hooks/mri_spec.rb
|
|
336
341
|
- spec/lib/appsignal/hooks/net_http_spec.rb
|
|
@@ -348,6 +353,7 @@ files:
|
|
|
348
353
|
- spec/lib/appsignal/hooks_spec.rb
|
|
349
354
|
- spec/lib/appsignal/integrations/data_mapper_spec.rb
|
|
350
355
|
- spec/lib/appsignal/integrations/grape_spec.rb
|
|
356
|
+
- spec/lib/appsignal/integrations/http_spec.rb
|
|
351
357
|
- spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
|
|
352
358
|
- spec/lib/appsignal/integrations/object_spec.rb
|
|
353
359
|
- spec/lib/appsignal/integrations/padrino_spec.rb
|
|
@@ -371,6 +377,7 @@ files:
|
|
|
371
377
|
- spec/lib/appsignal/transmitter_spec.rb
|
|
372
378
|
- spec/lib/appsignal/utils/data_spec.rb
|
|
373
379
|
- spec/lib/appsignal/utils/hash_sanitizer_spec.rb
|
|
380
|
+
- spec/lib/appsignal/utils/integration_logger_spec.rb
|
|
374
381
|
- spec/lib/appsignal/utils/json_spec.rb
|
|
375
382
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
|
376
383
|
- spec/lib/appsignal_spec.rb
|
|
@@ -441,7 +448,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
441
448
|
- !ruby/object:Gem::Version
|
|
442
449
|
version: '0'
|
|
443
450
|
requirements: []
|
|
444
|
-
rubygems_version: 3.3.
|
|
451
|
+
rubygems_version: 3.3.12
|
|
445
452
|
signing_key:
|
|
446
453
|
specification_version: 4
|
|
447
454
|
summary: Logs performance and exception data from your app to appsignal.com
|
|
@@ -483,6 +490,7 @@ test_files:
|
|
|
483
490
|
- spec/lib/appsignal/hooks/data_mapper_spec.rb
|
|
484
491
|
- spec/lib/appsignal/hooks/delayed_job_spec.rb
|
|
485
492
|
- spec/lib/appsignal/hooks/excon_spec.rb
|
|
493
|
+
- spec/lib/appsignal/hooks/http_spec.rb
|
|
486
494
|
- spec/lib/appsignal/hooks/mongo_ruby_driver_spec.rb
|
|
487
495
|
- spec/lib/appsignal/hooks/mri_spec.rb
|
|
488
496
|
- spec/lib/appsignal/hooks/net_http_spec.rb
|
|
@@ -500,6 +508,7 @@ test_files:
|
|
|
500
508
|
- spec/lib/appsignal/hooks_spec.rb
|
|
501
509
|
- spec/lib/appsignal/integrations/data_mapper_spec.rb
|
|
502
510
|
- spec/lib/appsignal/integrations/grape_spec.rb
|
|
511
|
+
- spec/lib/appsignal/integrations/http_spec.rb
|
|
503
512
|
- spec/lib/appsignal/integrations/mongo_ruby_driver_spec.rb
|
|
504
513
|
- spec/lib/appsignal/integrations/object_spec.rb
|
|
505
514
|
- spec/lib/appsignal/integrations/padrino_spec.rb
|
|
@@ -523,6 +532,7 @@ test_files:
|
|
|
523
532
|
- spec/lib/appsignal/transmitter_spec.rb
|
|
524
533
|
- spec/lib/appsignal/utils/data_spec.rb
|
|
525
534
|
- spec/lib/appsignal/utils/hash_sanitizer_spec.rb
|
|
535
|
+
- spec/lib/appsignal/utils/integration_logger_spec.rb
|
|
526
536
|
- spec/lib/appsignal/utils/json_spec.rb
|
|
527
537
|
- spec/lib/appsignal/utils/query_params_sanitizer_spec.rb
|
|
528
538
|
- spec/lib/appsignal_spec.rb
|