aspecto-opentelemetry 0.1.8 → 0.1.9

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: c6dc0881d253f1a91182a09ae64a3464bc935b63744ea68654011bb317b1278b
4
- data.tar.gz: b42327874bf790cfa4d4fbcea31f84a4bd9a8e31cf94362329f25c195202ec4f
3
+ metadata.gz: 005e783e20aa54623dca0a11daae40ef3e3d8a6d9b83a13b6fd44f11a0a7f00b
4
+ data.tar.gz: 9edaffde8afa0cbfb8f3547aec3fd4ab3fc236395e70e6ecb1e60b83f5d563b1
5
5
  SHA512:
6
- metadata.gz: da5bc77255107ff1236861ab1ffcf61a98e27af86ad9a12787fa03f6d8d6ef3f32a7bb1de1032a717f0f51c647f59942924fd162e507c039d785f6b0272ea905
7
- data.tar.gz: 905b157c77e02bb808ca5c4e5a2a644156b79be3fd8d39b2f8ebbc2a32c4cb7651d6ef4c6dec5b041d37ef574a05085a1d03dbc21f165ca5b32a217c613f6482
6
+ metadata.gz: a220142b3826b3cf0d95e73c559e0ac5ce0e29828f98883fd6e7f8e7a9c4a486bfe6620a49f73cbc938d23c3b0c48f8782147a69779256719520532112ef1b6d
7
+ data.tar.gz: fd9e2c8b3513d25599411f2718ff1f3aa79b75425fd9d81f75f32e1ceb7b69c4228dfc46abc1f0dc64a7f020c2916ed47f1bc29d11539cabf87e91945ce38851
@@ -16,6 +16,8 @@ module Aspecto
16
16
  def initialize(aspecto_auth, service_name, env, fallback_sampler)
17
17
  @service_name = service_name
18
18
  @env = env
19
+ @error_reported = false
20
+ @got_remote_config = false
19
21
  @fallback_sampler = fallback_sampler
20
22
  aspecto_config_host = ENV.fetch("ASPECTO_CONFIG_HOST", "https://config.aspecto.io")
21
23
  @aspecto_config_url = URI("#{aspecto_config_host}/config/#{aspecto_auth}")
@@ -27,7 +29,10 @@ module Aspecto
27
29
  update_config
28
30
  end
29
31
 
30
- ::OpenTelemetry.logger.info "[Aspecto] SDK client initialized"
32
+ ::OpenTelemetry.logger.info "[Aspecto] initialized remote config polling"
33
+ rescue StandardError => e
34
+ ::OpenTelemetry.logger.error "[Aspecto] failed to initialize remote config polling"
35
+ ::OpenTelemetry.logger.error e
31
36
  end
32
37
 
33
38
  def shutdown
@@ -50,7 +55,7 @@ module Aspecto
50
55
  @http_client.verify_mode = OpenSSL::SSL::VERIFY_PEER
51
56
  end
52
57
 
53
- def update_config # rubocop:disable Metrics/AbcSize
58
+ def update_config
54
59
  ::OpenTelemetry::Common::Utilities.untraced do
55
60
  request = Net::HTTP::Get.new(@aspecto_config_url.path)
56
61
  request["If-None-Match"] = @latest_config_etag unless @latest_config_etag.nil?
@@ -60,7 +65,7 @@ module Aspecto
60
65
  return if response_code == 304
61
66
 
62
67
  if response_code >= 400
63
- ::OpenTelemetry.logger.error("[Aspecto] error when trying to get remote config. will try again in #{@remote_config_poll_frequency}")
68
+ log_config_error "failed to get remote config with http response #{response_code}."
64
69
  return
65
70
  end
66
71
 
@@ -68,13 +73,14 @@ module Aspecto
68
73
  handle_new_config JSON.parse(response.body) if response_code < 300
69
74
  end
70
75
  rescue StandardError => e
71
- ::OpenTelemetry.logger.error "[Aspecto] updating remote config failed. using previous remote config"
72
- ::OpenTelemetry.logger.debug e
76
+ log_config_error "updating remote config failed with exception.", e
73
77
  end
74
78
 
75
79
  def handle_new_config(config)
76
- ::OpenTelemetry.logger.info("[Aspecto] successfully received remote configuration")
77
80
  update_sampler config["samplingRules"]
81
+ @error_reported = false
82
+ @got_remote_config = true
83
+ ::OpenTelemetry.logger.info("[Aspecto] successfully updated remote configuration")
78
84
  end
79
85
 
80
86
  def update_sampler(sampler_config)
@@ -84,6 +90,16 @@ module Aspecto
84
90
  # updating the sampler should be thread safe as it's an atomic setter on a global value
85
91
  ::OpenTelemetry.tracer_provider.sampler = message_process_sampler
86
92
  end
93
+
94
+ def log_config_error(msg, err = nil)
95
+ return if @error_reported # report every issue only once
96
+
97
+ retry_msg = "will try again until success every #{@remote_config_poll_frequency}."
98
+ previous_config_msg = @got_remote_config ? "using previous remote config" : "no previous config is avialable"
99
+ ::OpenTelemetry.logger.info("[Aspecto]: #{msg} #{retry_msg} #{previous_config_msg}")
100
+ ::OpenTelemetry.logger.info(err) if err
101
+ @error_reported = true
102
+ end
87
103
  end
88
104
  end
89
105
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aspecto
4
4
  module OpenTelemetry
5
- VERSION = "0.1.8"
5
+ VERSION = "0.1.9"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aspecto-opentelemetry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aspecto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-03 00:00:00.000000000 Z
11
+ date: 2022-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aspecto-opentelemetry-instrumentation-aws_sdk