aspecto-opentelemetry 0.1.6 → 0.1.7.rc0

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: c8d67f2909e02b637a0342f01aaab45d1cbb0b5fae5cc27271b76113fe7af183
4
- data.tar.gz: 1615052d3f62bb92ac80f91e3bc5a4f5f035ed9f361cefd4e7f459b6b3849d77
3
+ metadata.gz: 96878fe3288dcffacdf45867d12864608617b5b18a5b108b6a3a765f6fba667d
4
+ data.tar.gz: 20cacce2828f81bc7a2d828d041dcb14eb05b085a2b888cd3b8b6a04d2eb5463
5
5
  SHA512:
6
- metadata.gz: 7133ce0b64d98585b535fac5791f77b84850ed98c561ec820ea5ba9ebd282b04249810eae0af36cb34f7d52dcd0eb54c020432d03a0d0d967884362d49401f94
7
- data.tar.gz: 8686004ce06bb37f4b4e92623b708d7905e1b9dfdf26220853f0887bfb19293123e58b3a633b251f92f6c91bce788ee5b4bb5879b37ce36176a163488b2c3c36
6
+ metadata.gz: 01045ec39c7a9375f4fb0c7503ca48ac3b6110005e53b747986af05633aa1b57a8568ddecad9a129b68d832255fa787354536ea1be14577fd394dca48cdcc99e
7
+ data.tar.gz: 670c6c00d5bfcceccb1784ed960fbf9c0a6103a6b308a7271eaefd2a5dba73e0cec00f0504ea003868e5c3e83b399dd52b6ac01f944f5f47dff7b919bb27f890
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Aspecto::OpenTelemetry
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/aspecto-opentelemetry.svg)](https://badge.fury.io/rb/aspecto-opentelemetry)
4
+
3
5
  Aspecto's SDK for ruby.
4
6
  This gem is a distribution of OpenTelemetry pre-configured to use all available instrumentations and export trace data to Aspecto.
5
7
 
@@ -97,16 +99,20 @@ The only required config options are [`aspecto_auth`](https://app.aspecto.io/app
97
99
 
98
100
  ### Configuration Options
99
101
 
100
- | Option Name | Environment Variable | Type | Default | Description |
101
- | ------------------------------------ | ------------------------------------ | ----------- | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
102
- | `aspecto_auth` | `ASPECTO_AUTH` | UUID string | - | Aspecto's [API key for authentication](https://app.aspecto.io/app/integration/api-key) |
103
- | `service_name` | `OTEL_SERVICE_NAME` | string | - | name of the service which is sending telemetry |
104
- | `env` | `ASPECTO_ENV` | string | extracted from rails or sinatra if used | deployment environment: `production` / `staging` / `development`, etc. |
105
- | `log_level` | `OTEL_LOG_LEVEL` | string | `ERROR` | `ERROR` / `WARN` / `INFO`, etc. |
106
- | `sampling_ratio` | `ASPECTO_SAMPLING_RATIO` | float | 1.0 | How many of the traces starting in this service should be sampled. set to number in range [0.0, 1.0] where 0.0 is no sampling, and 1.0 is sample all |
107
- | `otel_exporter_otlp_traces_endpoint` | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | URL | "https://otelcol.aspecto.io/v1/trace" | Url |
108
- | `require_config_for_traces` | `ASPECTO_REQUIRE_CONFIG_FOR_TRACES` | boolean | False | When `True`, the SDK will not trace anything until remote sampling configuration arrives (few hundreds ms). Can be used to enforce sampling configuration is always applied, with the cost of losing traces generated during service startup.
109
- |
102
+ | Option Name | Environment Variable | Type | Default | Description |
103
+ | ------------------------------------ | ----------------------------------------- | ----------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
104
+ | `aspecto_auth` | `ASPECTO_AUTH` | UUID string | - | Aspecto's [API key for authentication](https://app.aspecto.io/app/integration/api-key) |
105
+ | `service_name` | `OTEL_SERVICE_NAME` | string | - | name of the service which is sending telemetry |
106
+ | `env` | `ASPECTO_ENV` | string | extracted from rails or sinatra if used | deployment environment: `production` / `staging` / `development`, etc. |
107
+ | `log_level` | `OTEL_LOG_LEVEL` | string | `ERROR` | `ERROR` / `WARN` / `INFO`, etc. |
108
+ | `sampling_ratio` | `ASPECTO_SAMPLING_RATIO` | float | 1.0 | How many of the traces starting in this service should be sampled. set to number in range [0.0, 1.0] where 0.0 is no sampling, and 1.0 is sample all |
109
+ | `otel_exporter_otlp_traces_endpoint` | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | URL | "https://otelcol.aspecto.io/v1/trace" | Url |
110
+ | `require_config_for_traces` | `ASPECTO_REQUIRE_CONFIG_FOR_TRACES` | boolean | False | When `True`, the SDK will not trace anything until remote sampling configuration arrives (few hundreds ms). Can be used to enforce sampling configuration is always applied, with the cost of losing traces generated during service startup. |
111
+ | `extract_b3_context` | `ASPECTO_EXTRACT_B3_CONTEXT` | boolean | False | set to `True` when the service receives requests from another instrumented component that propagate context via B3 protocol multi or single header. for example: envoy proxy, ambassador and istio |
112
+ | `inject_b3_context_single_header` | `ASPECTO_INJECT_B3_CONTEXT_SINGLE_HEADER` | boolean | False | should be `True` when the service send traffic to another instrumented component that propagate context via B3 **single header** protocol |
113
+ | `inject_b3_context_multi_header` | `ASPECTO_INJECT_B3_CONTEXT_MULTI_HEADER` | boolean | False | should be `True` when the service send traffic to another instrumented component that propagate context via B3 **multi header** protocol. for example: envoy proxy, istio |
114
+
115
+ | |
110
116
 
111
117
  ## Contributing
112
118
 
@@ -6,7 +6,7 @@ module Aspecto
6
6
  class Configurator
7
7
  TRUTHY_VALUES = %w[1 T t true TRUE True].freeze
8
8
 
9
- def initialize
9
+ def initialize # rubocop:disable Metrics/AbcSize
10
10
  # initialize config options from environment variables.
11
11
  # they can later be overwritten with configurator attribute setters
12
12
  # that have precedence over env
@@ -16,7 +16,12 @@ module Aspecto
16
16
  self.env = ENV["ASPECTO_ENV"] if ENV["ASPECTO_ENV"]
17
17
  self.sampling_ratio = Float(ENV.fetch("ASPECTO_SAMPLING_RATIO", 1.0))
18
18
  self.otel_exporter_otlp_traces_endpoint = ENV.fetch("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT", "https://otelcol.aspecto.io/v1/trace")
19
- self.require_config_for_traces = TRUTHY_VALUES.include?(ENV["ASPECTO_REQUIRE_CONFIG_FOR_TRACES"]&.strip)
19
+ self.require_config_for_traces = self.class.bool_env_variable "ASPECTO_REQUIRE_CONFIG_FOR_TRACES", false
20
+
21
+ # b3 propagattor
22
+ self.extract_b3_context = self.class.bool_env_variable "ASPECTO_EXTRACT_B3_CONTEXT", false
23
+ self.inject_b3_context_single_header = self.class.bool_env_variable "ASPECTO_INJECT_B3_CONTEXT_SINGLE_HEADER", false
24
+ self.inject_b3_context_multi_header = self.class.bool_env_variable "ASPECTO_INJECT_B3_CONTEXT_MULTI_HEADER", false
20
25
  end
21
26
 
22
27
  def service_name=(service_name)
@@ -27,7 +32,7 @@ module Aspecto
27
32
  @override_resource_attributes[::OpenTelemetry::SemanticConventions::Resource::DEPLOYMENT_ENVIRONMENT] = env
28
33
  end
29
34
 
30
- attr_accessor :sampling_ratio, :log_level, :otel_exporter_otlp_traces_endpoint, :require_config_for_traces
35
+ attr_accessor :sampling_ratio, :log_level, :otel_exporter_otlp_traces_endpoint, :require_config_for_traces, :extract_b3_context, :inject_b3_context_single_header, :inject_b3_context_multi_header
31
36
  attr_reader :aspecto_auth
32
37
 
33
38
  def aspecto_auth=(aspecto_auth)
@@ -38,6 +43,15 @@ module Aspecto
38
43
  def config_override_resource
39
44
  ::OpenTelemetry::SDK::Resources::Resource.create(@override_resource_attributes)
40
45
  end
46
+
47
+ def self.bool_env_variable(env_variable_name, default_value)
48
+ env_value = ENV[env_variable_name]
49
+ if env_value.nil?
50
+ default_value
51
+ else
52
+ TRUTHY_VALUES.include?(env_value.strip)
53
+ end
54
+ end
41
55
  end
42
56
  end
43
57
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "opentelemetry"
4
+ require "opentelemetry-propagator-b3"
5
+
6
+ module Aspecto
7
+ module OpenTelemetry
8
+ module Propagator
9
+ # Aspecto OpenTelemetry Propagator Configuration
10
+ module Aspecto
11
+ extend self
12
+
13
+ W3C_PROPAGATOR = ::OpenTelemetry::Trace::Propagation::TraceContext.text_map_propagator
14
+ B3_SINGLE_PROPAGATOR = ::OpenTelemetry::Propagator::B3::Single.text_map_propagator
15
+ B3_MULTI_PROPAGATOR = ::OpenTelemetry::Propagator::B3::Multi.text_map_propagator
16
+
17
+ def from_configurator(configurator)
18
+ injectors = [W3C_PROPAGATOR]
19
+ injectors.push(B3_SINGLE_PROPAGATOR) if configurator.inject_b3_context_single_header
20
+ injectors.push(B3_MULTI_PROPAGATOR) if configurator.inject_b3_context_multi_header
21
+
22
+ extractors = [W3C_PROPAGATOR]
23
+ extractors.push(B3_SINGLE_PROPAGATOR, B3_MULTI_PROPAGATOR) if configurator.extract_b3_context
24
+
25
+ ::OpenTelemetry::Context::Propagation::CompositeTextMapPropagator.compose(injectors: injectors, extractors: extractors)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Aspecto
4
4
  module OpenTelemetry
5
- VERSION = "0.1.6"
5
+ VERSION = "0.1.7.rc0"
6
6
  end
7
7
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "opentelemetry/version"
4
4
  require_relative "opentelemetry/configurator"
5
+ require_relative "opentelemetry/propagator/aspecto"
5
6
  require_relative "opentelemetry/resource/detectors/aspecto"
6
7
  require_relative "opentelemetry/resource/detectors/deployment"
7
8
  require_relative "opentelemetry/config/remote_config"
@@ -50,6 +51,10 @@ module Aspecto
50
51
  end
51
52
  end
52
53
 
54
+ # Propagation
55
+ ::OpenTelemetry.propagation = ::Aspecto::OpenTelemetry::Propagator::Aspecto.from_configurator configurator
56
+
57
+ # Sampling
53
58
  if configurator.require_config_for_traces
54
59
  ::OpenTelemetry.logger.info "[Aspecto] Require config for traces. Applying ALWAYS_OFF sampler"
55
60
  ::OpenTelemetry.tracer_provider.sampler = ::OpenTelemetry::SDK::Trace::Samplers::ALWAYS_OFF
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.6
4
+ version: 0.1.7.rc0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aspecto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-23 00:00:00.000000000 Z
11
+ date: 2021-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aspecto-opentelemetry-instrumentation-aws_sdk
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.22.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: opentelemetry-propagator-b3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.19.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.19.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: opentelemetry-sdk
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -167,6 +181,7 @@ files:
167
181
  - lib/aspecto/opentelemetry.rb
168
182
  - lib/aspecto/opentelemetry/config/remote_config.rb
169
183
  - lib/aspecto/opentelemetry/configurator.rb
184
+ - lib/aspecto/opentelemetry/propagator/aspecto.rb
170
185
  - lib/aspecto/opentelemetry/resource/detectors/aspecto.rb
171
186
  - lib/aspecto/opentelemetry/resource/detectors/deployment.rb
172
187
  - lib/aspecto/opentelemetry/sampler/condition.rb
@@ -193,9 +208,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
208
  version: 2.5.0
194
209
  required_rubygems_version: !ruby/object:Gem::Requirement
195
210
  requirements:
196
- - - ">="
211
+ - - ">"
197
212
  - !ruby/object:Gem::Version
198
- version: '0'
213
+ version: 1.3.1
199
214
  requirements: []
200
215
  rubygems_version: 3.1.6
201
216
  signing_key: