epsagon 0.0.26 → 0.0.27

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: 8c6a213fb12b5ded33f1d938b306f56f6de61936197c10be80d53b11258483c1
4
- data.tar.gz: 34890a4a25d8bf528dc442b975504d1e70b177a09a7868b56538a9b6b112f3d0
3
+ metadata.gz: 74f7a24306d3840c295345b485169ffa8bb4bfa2285f7d43ae69440d0b685e53
4
+ data.tar.gz: e043b98f22a6d804fc5692b8ab60c8eb1e05d74de736412fdfef58179afce086
5
5
  SHA512:
6
- metadata.gz: b0ba4c84e5db6f25b6f68c7c31cbd8c694098ac8542c893735955328a18b58f5b49b436dab779dcac6759f246394c8152e0c3ef8791e4169a4abcf2f73e831e0
7
- data.tar.gz: 95f6e44d44be2917c1a6cb9b224c838a1b46aa0866fe991c5aa8e0ebf6cbd9703f71ede6d871c7eaebbd499d391c19bd8d887ee25a637c581628362e2fa7442d
6
+ metadata.gz: bb53cf200be779ba464a58a41bc62d03849ec8be6e161fca6a8d1f8594b124d38c3445155ac3e2582a318dc513415e6a236fd43f9a75b782f9642a29d5795c71
7
+ data.tar.gz: de6b92f478e04c362911160c29eec775553ef16f3714b9f6b78c062d60ee46161291b08d89f254f8bdf0f0d80884e4e41a79146114d87fc84ef758f246710c04
data/lib/epsagon.rb CHANGED
@@ -38,6 +38,14 @@ module Epsagon
38
38
  ignore_domains: ENV['EPSAGON_IGNORE_DOMAINS'] || DEFAULT_IGNORE_DOMAINS
39
39
  }
40
40
  @@epsagon_config.merge!(args)
41
+
42
+ Util.validate_value(@@epsagon_config, :metadata_only, 'Must be a boolean') {|v| !!v == v}
43
+ Util.validate_value(@@epsagon_config, :debug, 'Must be a boolean') {|v| !!v == v}
44
+ Util.validate_value(@@epsagon_config, :token, 'Must be a valid Epsagon token') {|v| v.is_a? String and v.size > 10}
45
+ Util.validate_value(@@epsagon_config, :app_name, 'Must be a String') {|v| v.is_a? String}
46
+ Util.validate_value(@@epsagon_config, :max_attribute_size, 'Must be an Integer') {|v| v.is_a? Integer}
47
+ Util.validate_value(@@epsagon_config, :ignore_domains, 'Must be iterable') {|v| v.respond_to?(:each)}
48
+
41
49
  OpenTelemetry::SDK.configure
42
50
  end
43
51
 
@@ -63,26 +71,18 @@ module Epsagon
63
71
  configurator.use 'OpenTelemetry::Instrumentation::Sidekiq', { epsagon: @@epsagon_config }
64
72
 
65
73
  if @@epsagon_config[:debug]
66
- configurator.add_span_processor OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(
67
- OpenTelemetry::Exporter::OTLP::Exporter.new(headers: {
68
- 'x-epsagon-token' => @@epsagon_config[:token]
69
- },
70
- endpoint: @@epsagon_config[:backend],
71
- insecure: @@epsagon_config[:insecure] || false)
72
- )
73
-
74
74
  configurator.add_span_processor OpenTelemetry::SDK::Trace::Export::SimpleSpanProcessor.new(
75
75
  OpenTelemetry::SDK::Trace::Export::ConsoleSpanExporter.new
76
76
  )
77
- else
78
- configurator.add_span_processor OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
79
- exporter: OpenTelemetry::Exporter::OTLP::Exporter.new(headers: {
80
- 'x-epsagon-token' => @@epsagon_config[:token]
81
- },
82
- endpoint: @@epsagon_config[:backend],
83
- insecure: @@epsagon_config[:insecure] || false)
84
- )
85
77
  end
78
+
79
+ configurator.add_span_processor OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
80
+ exporter: OpenTelemetry::Exporter::OTLP::Exporter.new(headers: {
81
+ 'x-epsagon-token' => @@epsagon_config[:token]
82
+ },
83
+ endpoint: @@epsagon_config[:backend],
84
+ insecure: @@epsagon_config[:insecure] || false)
85
+ )
86
86
  end
87
87
  end
88
88
 
@@ -1,3 +1,3 @@
1
1
  module EpsagonConstants
2
- VERSION = '0.0.26'
2
+ VERSION = '0.0.27'
3
3
  end
data/lib/util.rb CHANGED
@@ -4,6 +4,10 @@ require 'cgi'
4
4
 
5
5
  # Utilities for epsagon opentelemetry solution
6
6
  module Util
7
+ def self.validate_value(h, k, message, &block)
8
+ raise ArgumentError.new( "#{k} #{message}. Got #{h[k].class}: #{h[k]}" ) unless yield(h[k])
9
+ end
10
+
7
11
  def self.epsagon_query_attributes(query_string)
8
12
  if query_string&.include? '='
9
13
  { 'http.request.query_params' => CGI.parse(query_string).to_json }
@@ -25,7 +29,7 @@ module Util
25
29
  end
26
30
  return value
27
31
  elsif value.instance_of? String then
28
- value[0, max_size]
32
+ (value.frozen? ? value.dup : value).force_encoding('utf-8')[0, max_size]
29
33
  else
30
34
  value
31
35
  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.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Epsagon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api