epsagon 0.0.13 → 0.0.18
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/epsagon_rails_middleware.rb +6 -2
- 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/instrumentation/version.rb +0 -0
- data/lib/util.rb +19 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d65d072dcdd60a8e031bd72b9c3a259d499d1e6494171ad9e24d1acf49cd2044
|
4
|
+
data.tar.gz: ad627edaee775675bfd4589e0e8a221f7555a62fd5192d3a3de3926f293d1ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b5209a05093c2822a4da0673f304cd3074c58acc77f057891f34aa2953d4d64685f1069ae2d4136d123a5d792b11cad2edd29edfd404e0867b618acee5dbbf5
|
7
|
+
data.tar.gz: 893fe3823c6335e27efd66dce62ea2d4ffbd80d48bfd2041c4b453506686daa9415a28245a336a3f2d9b1b533f9da228e509d41e369fd58c5795192abcaefec7
|
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
|
@@ -85,7 +85,11 @@ class EpsagonRackMiddleware
|
|
85
85
|
attributes: request_span_attributes(env: env),
|
86
86
|
kind: :server) do |http_span|
|
87
87
|
RackExtension.with_span(http_span) do
|
88
|
-
tracer.in_span(
|
88
|
+
tracer.in_span(
|
89
|
+
env['HTTP_HOST'],
|
90
|
+
kind: :server,
|
91
|
+
attributes: {type: 'rails'}
|
92
|
+
) do |framework_span|
|
89
93
|
@app.call(env).tap do |status, headers, response|
|
90
94
|
set_attributes_after_request(http_span, framework_span, status, headers, response)
|
91
95
|
end
|
@@ -135,7 +139,7 @@ class EpsagonRackMiddleware
|
|
135
139
|
attributes = {
|
136
140
|
'operation' => env['REQUEST_METHOD'],
|
137
141
|
'type' => 'http',
|
138
|
-
'http.scheme' => env['
|
142
|
+
'http.scheme' => env['rack.url_scheme'],
|
139
143
|
'http.request.path' => path,
|
140
144
|
'http.request.headers' => request_headers
|
141
145
|
}
|
@@ -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
|
File without changes
|
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.18
|
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-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -77,6 +77,7 @@ extensions: []
|
|
77
77
|
extra_rdoc_files: []
|
78
78
|
files:
|
79
79
|
- lib/epsagon.rb
|
80
|
+
- lib/epsagon_constants.rb
|
80
81
|
- lib/instrumentation/aws_sdk.rb
|
81
82
|
- lib/instrumentation/aws_sdk_plugin.rb
|
82
83
|
- lib/instrumentation/epsagon_faraday_middleware.rb
|
@@ -85,6 +86,7 @@ files:
|
|
85
86
|
- lib/instrumentation/net_http.rb
|
86
87
|
- lib/instrumentation/rails.rb
|
87
88
|
- lib/instrumentation/sinatra.rb
|
89
|
+
- lib/instrumentation/version.rb
|
88
90
|
- lib/util.rb
|
89
91
|
homepage: https://github.com/epsagon/epsagon-ruby
|
90
92
|
licenses:
|