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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 808ee2781331d674be9e661fdb982402a9fa118a7e530226334dac758ce80dbb
4
- data.tar.gz: 370aad1ea87d60e10ffa0b0c6777951c290aaacb2074a6556b6b77a41f9606d3
3
+ metadata.gz: 73d94ad48a8190e090468c50a16752fca266145da6dacaa9f050c7c9709f4a08
4
+ data.tar.gz: ce72f581f6e6c7cb1923685c86619750dad00d3c902477e76fd7fd0fce9ddaeb
5
5
  SHA512:
6
- metadata.gz: 223f608c05ddf216c1db46709d234604af81dca746fe16d5c4f24e89618450313c6e8a972f35fa2c2f5c6aa4b5811cd97e638d625dde9a1d5b0bc9a00575cf92
7
- data.tar.gz: 5317d3432c01890de86919a5415322ed151002d12058027fa890cffa34ee32818d3e87e1d4484b5317aa1ab7c9047bf9347c2d5cf71e5718791ac6766e0163eb
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({ 'application' => @@epsagon_config[:app_name] })
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
@@ -0,0 +1,3 @@
1
+ module EpsagonConstants
2
+ VERSION = '0.0.22'
3
+ 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 = '0.0.0'
8
+ VERSION = EpsagonConstants::VERSION
8
9
  SERVICES = %w[
9
10
  ACM
10
11
  APIGateway
@@ -31,6 +31,6 @@ class EpsagonAwsHandler < Seahorse::Client::Handler
31
31
  end
32
32
 
33
33
  def tracer
34
- EpsagonAwsSdkInstrumentation.instance.tracer
34
+ EpsagonAwsSdkInstrumentation.instance.tracer()
35
35
  end
36
36
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../util'
4
+ require_relative '../epsagon_constants'
5
+
4
6
  require 'faraday'
5
7
 
6
8
  # Faraday middleware for epsagon instrumentaton
@@ -13,7 +13,7 @@ end
13
13
 
14
14
  # Faraday epsagon instrumentaton
15
15
  class EpsagonFaradayInstrumentation < OpenTelemetry::Instrumentation::Base
16
- VERSION = '0.0.0'
16
+ VERSION = EpsagonConstants::VERSION
17
17
 
18
18
  install do |_config|
19
19
  require_relative 'epsagon_faraday_middleware'
@@ -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 = '0.0.0'
78
+ VERSION = EpsagonConstants::VERSION
78
79
 
79
80
  install do |_|
80
81
  ::Net::HTTP.prepend(EpsagonNetHTTPExtension)
@@ -5,6 +5,8 @@ require 'rails'
5
5
  require 'action_controller/railtie'
6
6
 
7
7
  require_relative '../util'
8
+ require_relative '../epsagon_constants'
9
+
8
10
 
9
11
  module RackExtension
10
12
  module_function
@@ -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 = '0.0.0'
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.16
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-19 00:00:00.000000000 Z
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