sqreen-kit 0.1.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/sqreen-kit.rb +5 -0
- data/lib/sqreen/kit.rb +7 -4
- data/lib/sqreen/kit/configuration.rb +14 -0
- data/lib/sqreen/kit/http_client.rb +6 -0
- data/lib/sqreen/kit/http_client/authentication_error.rb +5 -0
- data/lib/sqreen/kit/http_client/unexpected_status_error.rb +5 -0
- data/lib/sqreen/kit/loggable.rb +5 -0
- data/lib/sqreen/kit/retry_policy.rb +5 -0
- data/lib/sqreen/kit/signals/actor.rb +5 -0
- data/lib/sqreen/kit/signals/auth_signals_client.rb +5 -0
- data/lib/sqreen/kit/signals/batch_collector.rb +5 -0
- data/lib/sqreen/kit/signals/context/http_context.rb +18 -2
- data/lib/sqreen/kit/signals/dto_helper.rb +25 -4
- data/lib/sqreen/kit/signals/metric.rb +5 -0
- data/lib/sqreen/kit/signals/point.rb +5 -0
- data/lib/sqreen/kit/signals/signal.rb +5 -0
- data/lib/sqreen/kit/signals/signal_attributes.rb +17 -2
- data/lib/sqreen/kit/signals/signals_client.rb +5 -0
- data/lib/sqreen/kit/signals/stack_trace.rb +5 -0
- data/lib/sqreen/kit/signals/trace.rb +5 -0
- data/lib/sqreen/kit/string_sanitizer.rb +5 -0
- data/lib/sqreen/kit/version.rb +15 -0
- metadata +9 -9
- data/lib/sqreen.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8cbb82a739997ab9d4faa9689df9d3854ddb32a45361b4a572f2e13b4104dfa
|
4
|
+
data.tar.gz: 456792fc273fce1cd31c9b4d8d60f94321ac8315dd968cd992ffb1c42607c9d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd0f3f2a07777f0996eee497e87c4a843fb20d1b8d9cab255383b89d489c067ed83442ea77ccd12f5d463073b9b7ab4200e84067bbef21abdf04773773a41187
|
7
|
+
data.tar.gz: 4e8b6b71afc3e951de917e4a712f2fdabb0f70f627d7253c6e87e07bbe29efab839cf4e6a23de125ce752fb3856c8314adf4b2a636588c824c95d10776dd7506
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.2
|
4
|
+
|
5
|
+
* Make user agent optional for HTTP context payload
|
6
|
+
|
7
|
+
## 0.2.1
|
8
|
+
|
9
|
+
* Add configurable certificate store
|
10
|
+
|
11
|
+
## 0.2.0
|
12
|
+
|
13
|
+
* Add configurable source information
|
14
|
+
* Fix wire-level formats
|
15
|
+
|
16
|
+
## 0.1.1
|
17
|
+
|
18
|
+
* Fixed a potential conflict prefenting agent startup
|
19
|
+
|
3
20
|
## 0.1.0
|
4
21
|
|
5
22
|
* Extracted code from Ruby agent
|
data/lib/sqreen-kit.rb
CHANGED
data/lib/sqreen/kit.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
6
|
+
require 'sqreen/kit/version'
|
1
7
|
require 'sqreen/kit/configuration'
|
2
8
|
require 'sqreen/kit/retry_policy'
|
3
9
|
require 'sqreen/kit/http_client'
|
@@ -12,10 +18,6 @@ module Sqreen
|
|
12
18
|
module Kit
|
13
19
|
# Factories using the global configuration
|
14
20
|
class << self
|
15
|
-
def version
|
16
|
-
@version ||= Gem.loaded_specs['sqreen-kit'].version
|
17
|
-
end
|
18
|
-
|
19
21
|
def auth_signals_client
|
20
22
|
@auth_signals_client ||=
|
21
23
|
Signals::AuthSignalsClient.new(
|
@@ -55,6 +57,7 @@ module Sqreen
|
|
55
57
|
@http_client ||=
|
56
58
|
HttpClient.new(Configuration.ingestion_url,
|
57
59
|
retry_policy,
|
60
|
+
certificate_store: Configuration.certificate_store,
|
58
61
|
proxy_address: Configuration.proxy_address,
|
59
62
|
proxy_port: Configuration.proxy_port,
|
60
63
|
proxy_user: Configuration.proxy_user,
|
@@ -1,4 +1,10 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
1
6
|
require 'logger'
|
7
|
+
require 'sqreen/kit/version'
|
2
8
|
|
3
9
|
module Sqreen
|
4
10
|
module Kit
|
@@ -8,6 +14,7 @@ module Sqreen
|
|
8
14
|
|
9
15
|
# http client related
|
10
16
|
attr_accessor :ingestion_url,
|
17
|
+
:certificate_store,
|
11
18
|
:proxy_address,
|
12
19
|
:proxy_port,
|
13
20
|
:proxy_user,
|
@@ -29,6 +36,11 @@ module Sqreen
|
|
29
36
|
:batch_flush_size,
|
30
37
|
:batch_max_size
|
31
38
|
|
39
|
+
# Default value for source in signals taking a generic value
|
40
|
+
# Something like 'sqreen:agent:ruby:1.11.1'
|
41
|
+
# XXX: do not provide default and force user to explicitly set source?
|
42
|
+
attr_accessor :default_source
|
43
|
+
|
32
44
|
# @param [String] url
|
33
45
|
def proxy_url=(url)
|
34
46
|
if url.nil?
|
@@ -59,6 +71,8 @@ module Sqreen
|
|
59
71
|
logger.progname = 'sqreen-kit'
|
60
72
|
|
61
73
|
self.ingestion_url = 'https://ingestion.sqreen.com/'
|
74
|
+
|
75
|
+
self.default_source = "sqreen:kit:#{Sqreen::Kit.version}"
|
62
76
|
end
|
63
77
|
|
64
78
|
set_defaults
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
1
6
|
require 'net/http'
|
2
7
|
require 'uri'
|
3
8
|
|
@@ -32,6 +37,7 @@ module Sqreen
|
|
32
37
|
opts[:proxy_port], opts[:proxy_user],
|
33
38
|
opts[:proxy_pass])
|
34
39
|
@http.use_ssl = @base_url.scheme.downcase == 'https'
|
40
|
+
@http.cert_store = opts[:certificate_store]
|
35
41
|
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ENV['SQREEN_SSL_NO_VERIFY'] # for testing
|
36
42
|
|
37
43
|
@http.open_timeout = opts[:connect_timeout] || DEFAULT_CONNECT_TIMEOUT_S
|
data/lib/sqreen/kit/loggable.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
1
6
|
require 'sqreen/kit/signals/dto_helper'
|
2
7
|
|
3
8
|
# reference: https://github.com/sqreen/SignalsSchemas/blob/master/schemas/context/http/2020-01-01T00_00_00_000Z/schema.cue
|
@@ -18,7 +23,7 @@ class Sqreen::Kit::Signals::Context::HttpContext
|
|
18
23
|
:params_json, :params_other].freeze
|
19
24
|
|
20
25
|
SCHEMA_VERSION = 'http/2020-01-01T00:00:00.000Z'.freeze
|
21
|
-
add_mandatory_attrs :headers, :
|
26
|
+
add_mandatory_attrs :headers, :scheme, :verb,
|
22
27
|
:host, :port, :remote_ip, :remote_port, :path
|
23
28
|
|
24
29
|
# @return [String]
|
@@ -102,6 +107,14 @@ class Sqreen::Kit::Signals::Context::HttpContext
|
|
102
107
|
# @return [String]
|
103
108
|
attr_accessor :content_type
|
104
109
|
|
110
|
+
# Datadog trace id
|
111
|
+
# @return [Integer]
|
112
|
+
attr_accessor :datadog_trace_id
|
113
|
+
|
114
|
+
# Datadog span id
|
115
|
+
# @return [Integer]
|
116
|
+
attr_accessor :datadog_span_id
|
117
|
+
|
105
118
|
def to_h
|
106
119
|
check_mandatories
|
107
120
|
|
@@ -134,6 +147,9 @@ class Sqreen::Kit::Signals::Context::HttpContext
|
|
134
147
|
content_type: content_type,
|
135
148
|
content_length: content_length,
|
136
149
|
}),
|
137
|
-
}
|
150
|
+
}.merge!(compact_hash(
|
151
|
+
datadog_trace_id: datadog_trace_id,
|
152
|
+
datadog_span_id: datadog_span_id,
|
153
|
+
))
|
138
154
|
end
|
139
155
|
end
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
1
6
|
require 'json'
|
2
7
|
|
3
8
|
module Sqreen
|
@@ -9,6 +14,8 @@ module Sqreen
|
|
9
14
|
NilClass, Hash, Array, Numeric, TrueClass, FalseClass
|
10
15
|
].freeze
|
11
16
|
|
17
|
+
RFC_3339_FMT = '%Y-%m-%dT%H:%M:%S.%3N%:z'.freeze
|
18
|
+
|
12
19
|
module ClassMethods
|
13
20
|
# method should have been defined initially in an ancestor
|
14
21
|
def validate_str_attr(attr, regex)
|
@@ -49,8 +56,17 @@ module Sqreen
|
|
49
56
|
@self_mandatory_attrs += args
|
50
57
|
end
|
51
58
|
|
59
|
+
def readonly_attrs(*attrs)
|
60
|
+
attrs.each do |attr|
|
61
|
+
define_method :"#{attr}=" do |value|
|
62
|
+
raise "Attribute #{attr} is read-only" unless public_send(attr).nil?
|
63
|
+
super(value)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
52
68
|
def self_mandatory_attrs
|
53
|
-
@self_mandatory_attrs
|
69
|
+
@self_mandatory_attrs ||= []
|
54
70
|
end
|
55
71
|
|
56
72
|
def mandatory_attrs
|
@@ -76,11 +92,14 @@ module Sqreen
|
|
76
92
|
end
|
77
93
|
|
78
94
|
define_method attr do
|
79
|
-
|
95
|
+
var = "@#{attr}"
|
96
|
+
return nil unless instance_variable_defined?(var)
|
97
|
+
|
98
|
+
cur_val = instance_variable_get(var)
|
80
99
|
|
81
100
|
return nil if cur_val.nil?
|
82
101
|
return cur_val if cur_val.is_a?(String)
|
83
|
-
cur_val.strftime(
|
102
|
+
cur_val.strftime(RFC_3339_FMT)
|
84
103
|
end
|
85
104
|
end
|
86
105
|
|
@@ -128,7 +147,9 @@ module Sqreen
|
|
128
147
|
end
|
129
148
|
|
130
149
|
def to_json
|
131
|
-
|
150
|
+
return to_h.to_json unless instance_variable_defined?(:@filters)
|
151
|
+
|
152
|
+
res = @filters.reduce(to_h) { |accum, filter| filter[accum] }
|
132
153
|
res.to_json
|
133
154
|
end
|
134
155
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
1
6
|
require 'sqreen/kit/signals/dto_helper'
|
2
7
|
require 'sqreen/kit/signals/stack_trace'
|
3
8
|
require 'sqreen/kit/signals/actor'
|
@@ -55,6 +60,14 @@ module Sqreen
|
|
55
60
|
# @param [Exception] e
|
56
61
|
attr_writer :exception
|
57
62
|
|
63
|
+
# Datadog trace id
|
64
|
+
# @return [Integer]
|
65
|
+
attr_accessor :datadog_trace_id
|
66
|
+
|
67
|
+
# Datadog span id
|
68
|
+
# @return [Integer]
|
69
|
+
attr_accessor :datadog_span_id
|
70
|
+
|
58
71
|
def stack_trace
|
59
72
|
if @exception
|
60
73
|
Sqreen::Kit::StackTrace.parse(@exception)
|
@@ -95,8 +108,10 @@ module Sqreen
|
|
95
108
|
|
96
109
|
def to_h
|
97
110
|
{
|
98
|
-
|
99
|
-
|
111
|
+
infra: {
|
112
|
+
agent_type: 'ruby',
|
113
|
+
}.merge(super()),
|
114
|
+
}
|
100
115
|
end
|
101
116
|
end
|
102
117
|
end # module Signals
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
1
6
|
# Includes code from Airbrake Technologies, Inc., under the MIT licence
|
2
7
|
# see https://github.com/airbrake/airbrake-ruby/blob/c172657dcd4eeaf62ea23f0f7d6111be2373ea59/LICENSE.md
|
3
8
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
1
6
|
require 'sqreen/kit/signals/dto_helper'
|
2
7
|
require 'sqreen/kit/signals/signal'
|
3
8
|
require 'sqreen/kit/signals/signal_attributes'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# typed: ignore
|
2
|
+
|
3
|
+
# Copyright (c) 2015 Sqreen. All Rights Reserved.
|
4
|
+
# Please refer to our terms for more information: https://www.sqreen.com/terms.html
|
5
|
+
|
6
|
+
# Split to avoid a circular dependency between kit.rb and configuration.rb
|
7
|
+
module Sqreen
|
8
|
+
module Kit
|
9
|
+
class << self
|
10
|
+
def version
|
11
|
+
@version ||= Gem.loaded_specs['sqreen-kit'].version
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqreen-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loic Nageleisen
|
8
8
|
- Gustavo Lopes
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqreen-backport
|
@@ -25,8 +25,8 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.1.0
|
28
|
-
description:
|
29
|
-
email:
|
28
|
+
description:
|
29
|
+
email:
|
30
30
|
executables: []
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
@@ -34,7 +34,6 @@ files:
|
|
34
34
|
- CHANGELOG.md
|
35
35
|
- LICENSE
|
36
36
|
- lib/sqreen-kit.rb
|
37
|
-
- lib/sqreen.rb
|
38
37
|
- lib/sqreen/kit.rb
|
39
38
|
- lib/sqreen/kit/configuration.rb
|
40
39
|
- lib/sqreen/kit/http_client.rb
|
@@ -55,12 +54,13 @@ files:
|
|
55
54
|
- lib/sqreen/kit/signals/stack_trace.rb
|
56
55
|
- lib/sqreen/kit/signals/trace.rb
|
57
56
|
- lib/sqreen/kit/string_sanitizer.rb
|
57
|
+
- lib/sqreen/kit/version.rb
|
58
58
|
homepage: https://sqreen.com
|
59
59
|
licenses:
|
60
60
|
- Sqreen
|
61
61
|
metadata:
|
62
62
|
source_code_uri: https://github.com/sqreen/ruby-sdk
|
63
|
-
post_install_message:
|
63
|
+
post_install_message:
|
64
64
|
rdoc_options: []
|
65
65
|
require_paths:
|
66
66
|
- lib
|
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
79
|
-
signing_key:
|
78
|
+
rubygems_version: 3.2.3
|
79
|
+
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Sqreen development kit for Ruby
|
82
82
|
test_files: []
|
data/lib/sqreen.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
module Sqreen; end
|