epsagon 0.0.16 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/epsagon.rb +42 -1
- data/lib/epsagon_constants.rb +3 -0
- data/lib/instrumentation/aws_sdk.rb +2 -1
- data/lib/instrumentation/aws_sdk_plugin.rb +1 -1
- data/lib/instrumentation/epsagon_faraday_middleware.rb +2 -0
- data/lib/instrumentation/faraday.rb +1 -1
- data/lib/instrumentation/net_http.rb +2 -1
- data/lib/instrumentation/rails.rb +2 -0
- data/lib/instrumentation/sinatra.rb +2 -1
- data/lib/util.rb +19 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73d94ad48a8190e090468c50a16752fca266145da6dacaa9f050c7c9709f4a08
|
4
|
+
data.tar.gz: ce72f581f6e6c7cb1923685c86619750dad00d3c902477e76fd7fd0fce9ddaeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1fcdc94c369e2dad0f40c6e50c788a7fde75f9f61f8188769fb24b6ca67b3dadc8519e2964720758129ffcd462fb1a573afa9e192503d72a2532b614f537fde
|
7
|
+
data.tar.gz: 7fa7173eb476645bf4b3b116719bf9cdca8f84f63e301e82ff7925ea3240438ddb8ca00b6e84074a4540e5694518269d71bf5e243f47cfa50c1a9aab438f0365
|
data/lib/epsagon.rb
CHANGED
@@ -12,11 +12,13 @@ require_relative 'instrumentation/faraday'
|
|
12
12
|
require_relative 'instrumentation/aws_sdk'
|
13
13
|
require_relative 'instrumentation/rails'
|
14
14
|
require_relative 'util'
|
15
|
+
require_relative 'epsagon_constants'
|
15
16
|
|
16
17
|
Bundler.require
|
17
18
|
|
18
19
|
# Epsagon tracing main entry point
|
19
20
|
module Epsagon
|
21
|
+
|
20
22
|
DEFAULT_BACKEND = 'opentelemetry.tc.epsagon.com:443/traces'
|
21
23
|
|
22
24
|
@@epsagon_config = {
|
@@ -24,6 +26,7 @@ module Epsagon
|
|
24
26
|
debug: ENV['EPSAGON_DEBUG']&.to_s&.downcase == 'true',
|
25
27
|
token: ENV['EPSAGON_TOKEN'],
|
26
28
|
app_name: ENV['EPSAGON_APP_NAME'],
|
29
|
+
max_attribute_size: ENV['EPSAGON_MAX_ATTRIBUTE_SIZE'] || 5000,
|
27
30
|
backend: ENV['EPSAGON_BACKEND'] || DEFAULT_BACKEND
|
28
31
|
}
|
29
32
|
|
@@ -34,17 +37,26 @@ module Epsagon
|
|
34
37
|
OpenTelemetry::SDK.configure
|
35
38
|
end
|
36
39
|
|
40
|
+
def get_config
|
41
|
+
@@epsagon_config
|
42
|
+
end
|
43
|
+
|
37
44
|
# config opentelemetry with epsaon extensions:
|
38
45
|
|
39
46
|
def epsagon_confs(configurator)
|
40
47
|
configurator.resource = OpenTelemetry::SDK::Resources::Resource.telemetry_sdk.merge(
|
41
|
-
OpenTelemetry::SDK::Resources::Resource.create({
|
48
|
+
OpenTelemetry::SDK::Resources::Resource.create({
|
49
|
+
'application' => @@epsagon_config[:app_name],
|
50
|
+
'epsagon.version' => EpsagonConstants::VERSION
|
51
|
+
})
|
42
52
|
)
|
43
53
|
configurator.use 'EpsagonSinatraInstrumentation', { epsagon: @@epsagon_config }
|
44
54
|
configurator.use 'EpsagonNetHTTPInstrumentation', { epsagon: @@epsagon_config }
|
45
55
|
configurator.use 'EpsagonFaradayInstrumentation', { epsagon: @@epsagon_config }
|
46
56
|
configurator.use 'EpsagonAwsSdkInstrumentation', { epsagon: @@epsagon_config }
|
47
57
|
configurator.use 'EpsagonRailsInstrumentation', { epsagon: @@epsagon_config }
|
58
|
+
configurator.use 'OpenTelemetry::Instrumentation::Sidekiq'
|
59
|
+
|
48
60
|
|
49
61
|
if @@epsagon_config[:debug]
|
50
62
|
configurator.add_span_processor OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(
|
@@ -70,6 +82,29 @@ module Epsagon
|
|
70
82
|
end
|
71
83
|
end
|
72
84
|
|
85
|
+
|
86
|
+
module SpanExtension
|
87
|
+
|
88
|
+
BLANKS = [nil, [], '']
|
89
|
+
|
90
|
+
def set_attribute(key, value)
|
91
|
+
unless BLANKS.include?(value)
|
92
|
+
value = Util.trim_attr(value, Epsagon.get_config[:max_attribute_size])
|
93
|
+
super(key, value)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def initialize(*args)
|
98
|
+
super(*args)
|
99
|
+
if @attributes
|
100
|
+
@attributes = Hash[@attributes.map { |k,v|
|
101
|
+
[k, Util.trim_attr(v, Epsagon.get_config[:max_attribute_size])]
|
102
|
+
}]
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
73
108
|
# monkey patch to include epsagon confs
|
74
109
|
module OpenTelemetry
|
75
110
|
# monkey patch inner SDK module
|
@@ -80,5 +115,11 @@ module OpenTelemetry
|
|
80
115
|
Epsagon.epsagon_confs c
|
81
116
|
end
|
82
117
|
end
|
118
|
+
|
119
|
+
module Trace
|
120
|
+
class Span
|
121
|
+
prepend SpanExtension
|
122
|
+
end
|
123
|
+
end
|
83
124
|
end
|
84
125
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative '../util'
|
4
|
+
require_relative '../epsagon_constants'
|
4
5
|
|
5
6
|
# AWS SDK epsagon instrumentation
|
6
7
|
class EpsagonAwsSdkInstrumentation < OpenTelemetry::Instrumentation::Base
|
7
|
-
VERSION =
|
8
|
+
VERSION = EpsagonConstants::VERSION
|
8
9
|
SERVICES = %w[
|
9
10
|
ACM
|
10
11
|
APIGateway
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'opentelemetry'
|
4
4
|
|
5
5
|
require_relative '../util'
|
6
|
+
require_relative '../epsagon_constants'
|
6
7
|
|
7
8
|
# Net::HTTP patch for epsagon instrumentaton
|
8
9
|
module EpsagonNetHTTPExtension
|
@@ -74,7 +75,7 @@ end
|
|
74
75
|
|
75
76
|
# Net::HTTP epsagon instrumentaton
|
76
77
|
class EpsagonNetHTTPInstrumentation < OpenTelemetry::Instrumentation::Base
|
77
|
-
VERSION =
|
78
|
+
VERSION = EpsagonConstants::VERSION
|
78
79
|
|
79
80
|
install do |_|
|
80
81
|
::Net::HTTP.prepend(EpsagonNetHTTPExtension)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'opentelemetry'
|
4
4
|
|
5
5
|
require_relative '../util'
|
6
|
+
require_relative '../epsagon_constants'
|
6
7
|
|
7
8
|
# Sinatra middleware for epsagon instrumentation
|
8
9
|
class EpsagonTracerMiddleware
|
@@ -111,7 +112,7 @@ end
|
|
111
112
|
|
112
113
|
# Sinatra epsagon instrumentation
|
113
114
|
class EpsagonSinatraInstrumentation < OpenTelemetry::Instrumentation::Base
|
114
|
-
VERSION =
|
115
|
+
VERSION = EpsagonConstants::VERSION
|
115
116
|
|
116
117
|
install do |_|
|
117
118
|
::Sinatra::Base.register EpsagonTracerExtension
|
data/lib/util.rb
CHANGED
@@ -11,4 +11,23 @@ module Util
|
|
11
11
|
{ 'http.request.query' => query_string }
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
def self.trim_attr(value, max_size)
|
16
|
+
if value.instance_of? Array then
|
17
|
+
current_size = 2
|
18
|
+
value.each_with_index do |el, i|
|
19
|
+
el_size = el.to_s.size + (i==0 ? 0 : 2)
|
20
|
+
if current_size + el_size > max_size then
|
21
|
+
return value[0,i] + [Util.trim_attr(el, max_size - current_size)]
|
22
|
+
else
|
23
|
+
current_size += el_size
|
24
|
+
end
|
25
|
+
end
|
26
|
+
return value
|
27
|
+
elsif value.instance_of? String then
|
28
|
+
value[0, max_size]
|
29
|
+
else
|
30
|
+
value
|
31
|
+
end
|
32
|
+
end
|
14
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epsagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Epsagon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04
|
11
|
+
date: 2021-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.11.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: opentelemetry-instrumentation-sidekiq
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.11.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.11.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: opentelemetry-sdk
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,6 +91,7 @@ extensions: []
|
|
77
91
|
extra_rdoc_files: []
|
78
92
|
files:
|
79
93
|
- lib/epsagon.rb
|
94
|
+
- lib/epsagon_constants.rb
|
80
95
|
- lib/instrumentation/aws_sdk.rb
|
81
96
|
- lib/instrumentation/aws_sdk_plugin.rb
|
82
97
|
- lib/instrumentation/epsagon_faraday_middleware.rb
|