helios-opentelemetry-sdk 0.1.20 → 0.1.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: a91efee8919de8c1d6ba5535e9bd3e347f3402545739261b272e33e1a64e036e
4
- data.tar.gz: 1d0c7e40082bcb8153aacd08b36ed919589d32836a17cd65ba16ef68db13391c
3
+ metadata.gz: 5f067b2b75fcf692e420c9ac84ac7107e09d736174a855d7fce9ca6fb4198990
4
+ data.tar.gz: 137c32fdde515fbc4a00b191672a6a9188e3434820b8042a287aa715c7b15ad3
5
5
  SHA512:
6
- metadata.gz: 62f535badbe0f1c481f15dd17e110209233c99025b8d544988e264e78ff23d5b70e12bc10579748f33a0cc23fcf0716b8b4bcade9e2ab3509a1150b1795ef88d
7
- data.tar.gz: a935beb8953928cbd407dc71ddad09a6f1134f8d39c5d385e40eafdbf273f1976657f72a5fc114c64595a6ad53b52a2899f8878c8117c699458be3f8867e2568
6
+ metadata.gz: 797b434ff07072ae9c0094f71f889692ff56c6aba9d5c6668bd0ad1c151503cfaf25344f6c6115fe9b9023a3036b4fb5c0299aae83c391405bd7084d1847b1f0
7
+ data.tar.gz: e2939e688efce8f83e971a7dc34752fb5559b7202f0c99db257c13b533f66f99ee8ac150f8f4e064c5daa1de7c8440df3add138816d8769284cd1b8ca1493a2b
@@ -20,7 +20,7 @@ jobs:
20
20
  strategy:
21
21
  fail-fast: false
22
22
  matrix:
23
- ruby-version: ['2.6', '2.7', '3.1']
23
+ ruby-version: ['2.7', '3.1']
24
24
  services:
25
25
  mongodb:
26
26
  image: mongo@sha256:845fd775d7a58f564fae7c17a4eec7ff038e1c4004ebe05cc1cb5fc3767cf6cc
@@ -33,14 +33,15 @@ jobs:
33
33
  --health-retries=3
34
34
  steps:
35
35
  - uses: actions/checkout@v2
36
- - uses: actions/setup-ruby@v1
36
+ - uses: ruby/setup-ruby@v1
37
37
  with:
38
38
  ruby-version: ${{ matrix.ruby-version }}
39
+ bundler-cache: true
39
40
  - name: Install bundler
40
41
  run: gem install bundler -v 2.3.16
41
42
  - name: bundle install
42
43
  run: bundle install
43
44
  - name: Rubocop
44
- run: rubocop lib spec
45
+ run: bundle exec rubocop lib spec
45
46
  - name: Run specs
46
- run: rspec spec
47
+ run: bundle exec rspec spec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helios-opentelemetry-sdk (0.1.20)
4
+ helios-opentelemetry-sdk (0.1.22)
5
5
  opentelemetry-exporter-otlp (~> 0.22.0)
6
6
  opentelemetry-instrumentation-all (~> 0.25.0)
7
7
  opentelemetry-instrumentation-rspec (~> 0.2.0)
@@ -17,7 +17,7 @@ GEM
17
17
  faraday-net_http (~> 2.0)
18
18
  ruby2_keywords (>= 0.0.4)
19
19
  faraday-net_http (2.0.3)
20
- google-protobuf (3.21.1)
20
+ google-protobuf (3.21.7)
21
21
  googleapis-common-protos-types (1.3.1)
22
22
  google-protobuf (~> 3.14)
23
23
  mongo (2.18.1)
@@ -0,0 +1,37 @@
1
+ require 'opentelemetry/sdk'
2
+ require_relative '../semantic_attributes'
3
+
4
+ HELIOS_TEST_TRIGGERED_TRACE = 'hs-triggered-test'.freeze
5
+
6
+ ATTRIBUTES_TO_DROP = [
7
+ Helios::OpenTelemetry::SemanticAttributes::DB_QUERY_RESULT,
8
+ Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_BODY,
9
+ Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_HEADERS,
10
+ Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_BODY,
11
+ Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_HEADERS
12
+ ]
13
+
14
+ class HeliosProcessor < ::OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor
15
+ def initialize(exporter, metadata_only = False)
16
+ @metadata_only = metadata_only
17
+ super(exporter)
18
+ end
19
+
20
+ def on_start(span, parent_context)
21
+ baggage = ::OpenTelemetry::Baggage.values(context: parent_context)
22
+ return unless baggage.key?(HELIOS_TEST_TRIGGERED_TRACE)
23
+
24
+ span.set_attribute(HELIOS_TEST_TRIGGERED_TRACE, 'true')
25
+
26
+ super(span, parent_context)
27
+ end
28
+
29
+ def on_finish(span)
30
+ if @metadata_only
31
+ new_attributes = span.attributes.dup.reject { |k, _| ATTRIBUTES_TO_DROP.include?(k) }
32
+ span.instance_variable_set(:@attributes, new_attributes)
33
+ end
34
+
35
+ super(span)
36
+ end
37
+ end
@@ -1,7 +1,7 @@
1
1
  module Helios
2
2
  module OpenTelemetry
3
3
  module SDK
4
- VERSION = '0.1.20'
4
+ VERSION = '0.1.22'
5
5
  end
6
6
  end
7
7
  end
@@ -3,6 +3,7 @@ require 'opentelemetry/exporter/otlp'
3
3
  require 'opentelemetry/instrumentation/all'
4
4
  require_relative 'sdk/version'
5
5
  require_relative 'sdk/instrumentations'
6
+ require_relative 'sdk/helios_processor'
6
7
 
7
8
  module Helios
8
9
  module OpenTelemetry
@@ -37,11 +38,11 @@ module Helios
37
38
  end
38
39
  c.resource = ::OpenTelemetry::SDK::Resources::Resource.create(resource_attrs)
39
40
  apply_instrumentations(c)
40
- c.add_span_processor(
41
- ::OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
42
- get_span_exporter(helios_config)
43
- )
44
- )
41
+ c.add_span_processor(HeliosProcessor.new(get_span_exporter(helios_config), helios_config[:metadata_only]))
42
+ puts 'Helios tracing initialized (' \
43
+ "service: #{service_name}, " \
44
+ "token: #{api_token[0, 3]}*****, " \
45
+ "environment: #{environment})"
45
46
  end
46
47
 
47
48
  send_debug_span
@@ -88,9 +89,11 @@ if auto_tracing_mode?
88
89
  api_token = ENV['HS_TOKEN']
89
90
  service_name = ENV['HS_SERVICE_NAME']
90
91
  environment = ENV['HS_ENVIRONMENT']
92
+ metadata_only = ENV['HS_METADATA_ONLY'].lowercase == 'true'
91
93
  enable = true
92
94
  Helios::OpenTelemetry::SDK.initialize(api_token: api_token,
93
95
  service_name: service_name,
94
96
  environment: environment,
97
+ metadata_only: metadata_only,
95
98
  enable: enable)
96
99
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helios-opentelemetry-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Helios
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-06 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,7 @@ files:
129
129
  - bin/setup
130
130
  - helios-opentelemetry-sdk.gemspec
131
131
  - lib/helios/opentelemetry/sdk.rb
132
+ - lib/helios/opentelemetry/sdk/helios_processor.rb
132
133
  - lib/helios/opentelemetry/sdk/instrumentations.rb
133
134
  - lib/helios/opentelemetry/sdk/patches/faraday_patch.rb
134
135
  - lib/helios/opentelemetry/sdk/patches/mongo_patch.rb