hoss-agent 1.0.9
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 +7 -0
- data/.github/ISSUE_TEMPLATE/Bug_report.md +40 -0
- data/.github/ISSUE_TEMPLATE/Feature_request.md +17 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +60 -0
- data/.gitignore +27 -0
- data/.rspec +2 -0
- data/Dockerfile +43 -0
- data/Gemfile +105 -0
- data/LICENSE +201 -0
- data/hoss-agent.gemspec +42 -0
- data/lib/hoss-agent.rb +210 -0
- data/lib/hoss.rb +21 -0
- data/lib/hoss/agent.rb +235 -0
- data/lib/hoss/central_config.rb +184 -0
- data/lib/hoss/central_config/cache_control.rb +51 -0
- data/lib/hoss/child_durations.rb +64 -0
- data/lib/hoss/config.rb +315 -0
- data/lib/hoss/config/bytes.rb +42 -0
- data/lib/hoss/config/duration.rb +40 -0
- data/lib/hoss/config/options.rb +154 -0
- data/lib/hoss/config/regexp_list.rb +30 -0
- data/lib/hoss/config/wildcard_pattern_list.rb +54 -0
- data/lib/hoss/context.rb +64 -0
- data/lib/hoss/context/request.rb +28 -0
- data/lib/hoss/context/request/socket.rb +36 -0
- data/lib/hoss/context/request/url.rb +59 -0
- data/lib/hoss/context/response.rb +47 -0
- data/lib/hoss/context/user.rb +59 -0
- data/lib/hoss/context_builder.rb +112 -0
- data/lib/hoss/deprecations.rb +39 -0
- data/lib/hoss/error.rb +49 -0
- data/lib/hoss/error/exception.rb +70 -0
- data/lib/hoss/error/log.rb +41 -0
- data/lib/hoss/error_builder.rb +90 -0
- data/lib/hoss/event.rb +131 -0
- data/lib/hoss/instrumenter.rb +107 -0
- data/lib/hoss/internal_error.rb +23 -0
- data/lib/hoss/logging.rb +70 -0
- data/lib/hoss/metadata.rb +36 -0
- data/lib/hoss/metadata/process_info.rb +35 -0
- data/lib/hoss/metadata/service_info.rb +76 -0
- data/lib/hoss/metadata/system_info.rb +47 -0
- data/lib/hoss/metadata/system_info/container_info.rb +136 -0
- data/lib/hoss/naively_hashable.rb +38 -0
- data/lib/hoss/rails.rb +68 -0
- data/lib/hoss/railtie.rb +42 -0
- data/lib/hoss/report.rb +9 -0
- data/lib/hoss/sinatra.rb +53 -0
- data/lib/hoss/spies.rb +104 -0
- data/lib/hoss/spies/faraday.rb +106 -0
- data/lib/hoss/spies/http.rb +86 -0
- data/lib/hoss/spies/net_http.rb +101 -0
- data/lib/hoss/stacktrace.rb +33 -0
- data/lib/hoss/stacktrace/frame.rb +66 -0
- data/lib/hoss/stacktrace_builder.rb +124 -0
- data/lib/hoss/transport/base.rb +191 -0
- data/lib/hoss/transport/connection.rb +55 -0
- data/lib/hoss/transport/connection/http.rb +139 -0
- data/lib/hoss/transport/connection/proxy_pipe.rb +94 -0
- data/lib/hoss/transport/filters.rb +60 -0
- data/lib/hoss/transport/filters/hash_sanitizer.rb +77 -0
- data/lib/hoss/transport/filters/secrets_filter.rb +48 -0
- data/lib/hoss/transport/headers.rb +74 -0
- data/lib/hoss/transport/serializers.rb +113 -0
- data/lib/hoss/transport/serializers/context_serializer.rb +112 -0
- data/lib/hoss/transport/serializers/error_serializer.rb +92 -0
- data/lib/hoss/transport/serializers/event_serializer.rb +73 -0
- data/lib/hoss/transport/serializers/metadata_serializer.rb +92 -0
- data/lib/hoss/transport/serializers/report_serializer.rb +33 -0
- data/lib/hoss/transport/user_agent.rb +48 -0
- data/lib/hoss/transport/worker.rb +330 -0
- data/lib/hoss/util.rb +54 -0
- data/lib/hoss/util/inflector.rb +110 -0
- data/lib/hoss/util/lru_cache.rb +65 -0
- data/lib/hoss/util/throttle.rb +52 -0
- data/lib/hoss/version.rb +22 -0
- metadata +147 -0
@@ -0,0 +1,110 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
module Hoss
|
21
|
+
# rubocop:disable all
|
22
|
+
module Util
|
23
|
+
# From https://github.com/rails/rails/blob/v5.2.0/activesupport/lib/active_support/inflector/methods.rb#L254-L332
|
24
|
+
module Inflector
|
25
|
+
extend self
|
26
|
+
|
27
|
+
#
|
28
|
+
# Tries to find a constant with the name specified in the argument string.
|
29
|
+
#
|
30
|
+
# constantize('Module') # => Module
|
31
|
+
# constantize('Foo::Bar') # => Foo::Bar
|
32
|
+
#
|
33
|
+
# The name is assumed to be the one of a top-level constant, no matter
|
34
|
+
# whether it starts with "::" or not. No lexical context is taken into
|
35
|
+
# account:
|
36
|
+
#
|
37
|
+
# C = 'outside'
|
38
|
+
# module M
|
39
|
+
# C = 'inside'
|
40
|
+
# C # => 'inside'
|
41
|
+
# constantize('C') # => 'outside', same as ::C
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# NameError is raised when the name is not in CamelCase or the constant is
|
45
|
+
# unknown.
|
46
|
+
def constantize(camel_cased_word)
|
47
|
+
names = camel_cased_word.split("::".freeze)
|
48
|
+
|
49
|
+
# Trigger a built-in NameError exception including the ill-formed constant in the message.
|
50
|
+
Object.const_get(camel_cased_word) if names.empty?
|
51
|
+
|
52
|
+
# Remove the first blank element in case of '::ClassName' notation.
|
53
|
+
names.shift if names.size > 1 && names.first.empty?
|
54
|
+
|
55
|
+
names.inject(Object) do |constant, name|
|
56
|
+
if constant == Object
|
57
|
+
constant.const_get(name)
|
58
|
+
else
|
59
|
+
candidate = constant.const_get(name)
|
60
|
+
next candidate if constant.const_defined?(name, false)
|
61
|
+
next candidate unless Object.const_defined?(name)
|
62
|
+
|
63
|
+
# Go down the ancestors to check if it is owned directly. The check
|
64
|
+
# stops when we reach Object or the end of ancestors tree.
|
65
|
+
constant = constant.ancestors.inject(constant) do |const, ancestor|
|
66
|
+
break const if ancestor == Object
|
67
|
+
break ancestor if ancestor.const_defined?(name, false)
|
68
|
+
const
|
69
|
+
end
|
70
|
+
|
71
|
+
# owner is in Object, so raise
|
72
|
+
constant.const_get(name, false)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Tries to find a constant with the name specified in the argument string.
|
78
|
+
#
|
79
|
+
# safe_constantize('Module') # => Module
|
80
|
+
# safe_constantize('Foo::Bar') # => Foo::Bar
|
81
|
+
#
|
82
|
+
# The name is assumed to be the one of a top-level constant, no matter
|
83
|
+
# whether it starts with "::" or not. No lexical context is taken into
|
84
|
+
# account:
|
85
|
+
#
|
86
|
+
# C = 'outside'
|
87
|
+
# module M
|
88
|
+
# C = 'inside'
|
89
|
+
# C # => 'inside'
|
90
|
+
# safe_constantize('C') # => 'outside', same as ::C
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# +nil+ is returned when the name is not in CamelCase or the constant (or
|
94
|
+
# part of it) is unknown.
|
95
|
+
#
|
96
|
+
# safe_constantize('blargle') # => nil
|
97
|
+
# safe_constantize('UnknownModule') # => nil
|
98
|
+
# safe_constantize('UnknownModule::Foo::Bar') # => nil
|
99
|
+
def safe_constantize(camel_cased_word)
|
100
|
+
constantize(camel_cased_word)
|
101
|
+
rescue NameError => e
|
102
|
+
raise if e.name && !(camel_cased_word.to_s.split("::").include?(e.name.to_s) ||
|
103
|
+
e.name.to_s == camel_cased_word.to_s)
|
104
|
+
rescue ArgumentError => e
|
105
|
+
raise unless /not missing constant #{const_regexp(camel_cased_word)}!$/.match(e.message)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
# rubocop:enable all
|
110
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
module Hoss
|
21
|
+
module Util
|
22
|
+
# @api private
|
23
|
+
class LruCache
|
24
|
+
def initialize(max_size = 512, &block)
|
25
|
+
@max_size = max_size
|
26
|
+
@data = Hash.new(&block)
|
27
|
+
@mutex = Mutex.new
|
28
|
+
end
|
29
|
+
|
30
|
+
def [](key)
|
31
|
+
@mutex.synchronize do
|
32
|
+
val = @data[key]
|
33
|
+
return unless val
|
34
|
+
add(key, val)
|
35
|
+
val
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def []=(key, val)
|
40
|
+
@mutex.synchronize do
|
41
|
+
add(key, val)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def length
|
46
|
+
@data.length
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_a
|
50
|
+
@data.to_a
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def add(key, val)
|
56
|
+
@data.delete(key)
|
57
|
+
@data[key] = val
|
58
|
+
|
59
|
+
return unless @data.length > @max_size
|
60
|
+
|
61
|
+
@data.delete(@data.first[0])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
module Hoss
|
21
|
+
module Util
|
22
|
+
# @api private
|
23
|
+
|
24
|
+
# Usage example:
|
25
|
+
# Throttle.new(5) { thing to only do once per 5 secs }
|
26
|
+
class Throttle
|
27
|
+
def initialize(buffer_secs, &block)
|
28
|
+
@buffer_secs = buffer_secs
|
29
|
+
@block = block
|
30
|
+
end
|
31
|
+
|
32
|
+
def call
|
33
|
+
if @last_call && seconds_since_last_call < @buffer_secs
|
34
|
+
return @last_result
|
35
|
+
end
|
36
|
+
|
37
|
+
@last_call = now
|
38
|
+
@last_result = @block.call
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def now
|
44
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
45
|
+
end
|
46
|
+
|
47
|
+
def seconds_since_last_call
|
48
|
+
now - @last_call
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/hoss/version.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
18
|
+
# frozen_string_literal: true
|
19
|
+
|
20
|
+
module Hoss
|
21
|
+
VERSION = '1.0.9'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hoss-agent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.9
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cameron Cooper
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: concurrent-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: http
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- cameron@hoss.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".github/ISSUE_TEMPLATE/Bug_report.md"
|
49
|
+
- ".github/ISSUE_TEMPLATE/Feature_request.md"
|
50
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
51
|
+
- ".gitignore"
|
52
|
+
- ".rspec"
|
53
|
+
- Dockerfile
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE
|
56
|
+
- hoss-agent.gemspec
|
57
|
+
- lib/hoss-agent.rb
|
58
|
+
- lib/hoss.rb
|
59
|
+
- lib/hoss/agent.rb
|
60
|
+
- lib/hoss/central_config.rb
|
61
|
+
- lib/hoss/central_config/cache_control.rb
|
62
|
+
- lib/hoss/child_durations.rb
|
63
|
+
- lib/hoss/config.rb
|
64
|
+
- lib/hoss/config/bytes.rb
|
65
|
+
- lib/hoss/config/duration.rb
|
66
|
+
- lib/hoss/config/options.rb
|
67
|
+
- lib/hoss/config/regexp_list.rb
|
68
|
+
- lib/hoss/config/wildcard_pattern_list.rb
|
69
|
+
- lib/hoss/context.rb
|
70
|
+
- lib/hoss/context/request.rb
|
71
|
+
- lib/hoss/context/request/socket.rb
|
72
|
+
- lib/hoss/context/request/url.rb
|
73
|
+
- lib/hoss/context/response.rb
|
74
|
+
- lib/hoss/context/user.rb
|
75
|
+
- lib/hoss/context_builder.rb
|
76
|
+
- lib/hoss/deprecations.rb
|
77
|
+
- lib/hoss/error.rb
|
78
|
+
- lib/hoss/error/exception.rb
|
79
|
+
- lib/hoss/error/log.rb
|
80
|
+
- lib/hoss/error_builder.rb
|
81
|
+
- lib/hoss/event.rb
|
82
|
+
- lib/hoss/instrumenter.rb
|
83
|
+
- lib/hoss/internal_error.rb
|
84
|
+
- lib/hoss/logging.rb
|
85
|
+
- lib/hoss/metadata.rb
|
86
|
+
- lib/hoss/metadata/process_info.rb
|
87
|
+
- lib/hoss/metadata/service_info.rb
|
88
|
+
- lib/hoss/metadata/system_info.rb
|
89
|
+
- lib/hoss/metadata/system_info/container_info.rb
|
90
|
+
- lib/hoss/naively_hashable.rb
|
91
|
+
- lib/hoss/rails.rb
|
92
|
+
- lib/hoss/railtie.rb
|
93
|
+
- lib/hoss/report.rb
|
94
|
+
- lib/hoss/sinatra.rb
|
95
|
+
- lib/hoss/spies.rb
|
96
|
+
- lib/hoss/spies/faraday.rb
|
97
|
+
- lib/hoss/spies/http.rb
|
98
|
+
- lib/hoss/spies/net_http.rb
|
99
|
+
- lib/hoss/stacktrace.rb
|
100
|
+
- lib/hoss/stacktrace/frame.rb
|
101
|
+
- lib/hoss/stacktrace_builder.rb
|
102
|
+
- lib/hoss/transport/base.rb
|
103
|
+
- lib/hoss/transport/connection.rb
|
104
|
+
- lib/hoss/transport/connection/http.rb
|
105
|
+
- lib/hoss/transport/connection/proxy_pipe.rb
|
106
|
+
- lib/hoss/transport/filters.rb
|
107
|
+
- lib/hoss/transport/filters/hash_sanitizer.rb
|
108
|
+
- lib/hoss/transport/filters/secrets_filter.rb
|
109
|
+
- lib/hoss/transport/headers.rb
|
110
|
+
- lib/hoss/transport/serializers.rb
|
111
|
+
- lib/hoss/transport/serializers/context_serializer.rb
|
112
|
+
- lib/hoss/transport/serializers/error_serializer.rb
|
113
|
+
- lib/hoss/transport/serializers/event_serializer.rb
|
114
|
+
- lib/hoss/transport/serializers/metadata_serializer.rb
|
115
|
+
- lib/hoss/transport/serializers/report_serializer.rb
|
116
|
+
- lib/hoss/transport/user_agent.rb
|
117
|
+
- lib/hoss/transport/worker.rb
|
118
|
+
- lib/hoss/util.rb
|
119
|
+
- lib/hoss/util/inflector.rb
|
120
|
+
- lib/hoss/util/lru_cache.rb
|
121
|
+
- lib/hoss/util/throttle.rb
|
122
|
+
- lib/hoss/version.rb
|
123
|
+
homepage: https://hoss.com/
|
124
|
+
licenses:
|
125
|
+
- Apache-2.0
|
126
|
+
metadata:
|
127
|
+
source_code_uri: https://github.com/hossapp/ruby-agent
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 2.3.0
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubygems_version: 3.1.2
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: The official Hoss SDK for Ruby
|
147
|
+
test_files: []
|