highlight_io 0.3.0 → 0.4.0

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: 2adbe799337d2c59b751869b529af2a39efe40c2512bc345b133ffbd3e05eb51
4
- data.tar.gz: 24c098762842080dbc45261fe96deb42e1da7da592839eda378a99f22866718c
3
+ metadata.gz: 92d68b8ab3821bca22f10aac336705ea4bb272f9a62572334715dbab501c5940
4
+ data.tar.gz: 9175f4a419f534ff297eb9ad907385a0dcf1b4e2366b738ceb438d947cef4876
5
5
  SHA512:
6
- metadata.gz: 1d2796d575ba7938606af965ba98f72a4dc41d9672d01517e26550fb86e7333233bae97ec6ed769a429b2badd5b7c69fc25c9338205130b6f6185e2342ce451d
7
- data.tar.gz: 12502c3c4dce422ca34bb76201dbdb2b3f5de1642e3e1eecaa3f4a546c73eb88091e955e018dab06c44f3ee4e2cd0a2607d50b853a0348f7c0c1c211f10ecd4c
6
+ metadata.gz: 2c5032942516a6269fab88a89104cceba40b3279603a362142f12cd4340d080b5d484d3314f12076eb2e10c1e7fd8b9d24f7a6a21936665c827c0957139d5a2a
7
+ data.tar.gz: b89a5c22d6a8a9709c13831e535c38b68d3b10fdc48ca0577809978a57b65eccc374964632e7d0c3e8cf4feafe4f4c9676a6811b6d9ffdf2bedd5e2883023298
data/.rubocop.yml CHANGED
@@ -10,6 +10,9 @@ Style/Documentation:
10
10
  Metrics/MethodLength:
11
11
  Enabled: false
12
12
 
13
+ Metrics/CyclomaticComplexity:
14
+ Max: 8
15
+
13
16
  Naming/MethodParameterName:
14
17
  Enabled: false
15
18
 
data/CHANGELOG.md CHANGED
@@ -19,3 +19,9 @@
19
19
  ## 0.2.2
20
20
 
21
21
  - Fix duplicate errors recorded on traces.
22
+
23
+ ## 0.4.0
24
+
25
+ - Add `H.init` alias
26
+ - Auto instrument Rails requests and eliminate need for `around_action`
27
+ - Fix warning about incompatibility with `ActiveSupport::LoggerSilence`
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- highlight_io (0.3.0)
5
- grpc (~> 1.52)
4
+ highlight_io (0.4.0)
5
+ grpc (~> 1.65)
6
6
  opentelemetry-exporter-otlp (~> 0.28.1)
7
7
  opentelemetry-instrumentation-all (~> 0.62.1)
8
8
  opentelemetry-sdk (~> 1.5.0)
@@ -48,17 +48,17 @@ GEM
48
48
  opentelemetry-api (~> 1.0)
49
49
  opentelemetry-instrumentation-base (~> 0.22.1)
50
50
  opentelemetry-instrumentation-rack (~> 0.21)
51
- opentelemetry-instrumentation-action_view (0.7.1)
51
+ opentelemetry-instrumentation-action_view (0.7.2)
52
52
  opentelemetry-api (~> 1.0)
53
53
  opentelemetry-instrumentation-active_support (~> 0.1)
54
54
  opentelemetry-instrumentation-base (~> 0.22.1)
55
- opentelemetry-instrumentation-active_job (0.7.4)
55
+ opentelemetry-instrumentation-active_job (0.7.7)
56
56
  opentelemetry-api (~> 1.0)
57
57
  opentelemetry-instrumentation-base (~> 0.22.1)
58
58
  opentelemetry-instrumentation-active_model_serializers (0.20.2)
59
59
  opentelemetry-api (~> 1.0)
60
60
  opentelemetry-instrumentation-base (~> 0.22.1)
61
- opentelemetry-instrumentation-active_record (0.7.2)
61
+ opentelemetry-instrumentation-active_record (0.7.4)
62
62
  opentelemetry-api (~> 1.0)
63
63
  opentelemetry-instrumentation-base (~> 0.22.1)
64
64
  opentelemetry-instrumentation-active_support (0.6.0)
@@ -105,7 +105,7 @@ GEM
105
105
  opentelemetry-instrumentation-aws_sdk (0.5.4)
106
106
  opentelemetry-api (~> 1.0)
107
107
  opentelemetry-instrumentation-base (~> 0.22.1)
108
- opentelemetry-instrumentation-base (0.22.5)
108
+ opentelemetry-instrumentation-base (0.22.6)
109
109
  opentelemetry-api (~> 1.0)
110
110
  opentelemetry-common (~> 0.21)
111
111
  opentelemetry-registry (~> 0.1)
@@ -176,7 +176,7 @@ GEM
176
176
  opentelemetry-instrumentation-rack (0.24.6)
177
177
  opentelemetry-api (~> 1.0)
178
178
  opentelemetry-instrumentation-base (~> 0.22.1)
179
- opentelemetry-instrumentation-rails (0.31.1)
179
+ opentelemetry-instrumentation-rails (0.31.2)
180
180
  opentelemetry-api (~> 1.0)
181
181
  opentelemetry-instrumentation-action_mailer (~> 0.1.0)
182
182
  opentelemetry-instrumentation-action_pack (~> 0.9.0)
@@ -254,6 +254,7 @@ GEM
254
254
 
255
255
  PLATFORMS
256
256
  arm64-darwin-22
257
+ arm64-darwin-23
257
258
  x86_64-linux
258
259
 
259
260
  DEPENDENCIES
data/highlight.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_runtime_dependency 'grpc', '~> 1.52'
25
+ spec.add_runtime_dependency 'grpc', '~> 1.65'
26
26
  spec.add_runtime_dependency 'opentelemetry-exporter-otlp', '~> 0.28.1'
27
27
  spec.add_runtime_dependency 'opentelemetry-instrumentation-all', '~> 0.62.1'
28
28
  spec.add_runtime_dependency 'opentelemetry-sdk', '~> 1.5.0'
@@ -1,3 +1,3 @@
1
1
  module Highlight
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/highlight.rb CHANGED
@@ -18,6 +18,10 @@ module Highlight
18
18
  end
19
19
  end
20
20
 
21
+ def self.init(project_id, environment: '', otlp_endpoint: OTLP_HTTP, &block)
22
+ H.new(project_id, environment: environment, otlp_endpoint: otlp_endpoint, &block)
23
+ end
24
+
21
25
  def self.start_span(name, attrs = {}, &block)
22
26
  if block_given?
23
27
  H.instance.start_span(name, attrs, &block)
@@ -26,6 +30,18 @@ module Highlight
26
30
  end
27
31
  end
28
32
 
33
+ def self.log(level, message, attrs = {})
34
+ H.instance.record_log(nil, nil, level, message, attrs)
35
+ end
36
+
37
+ def self.exception(error, attrs = {})
38
+ H.instance.record_exception(error, attrs)
39
+ end
40
+
41
+ def self.traceparent_meta
42
+ Helpers.traceparent_meta
43
+ end
44
+
29
45
  class H
30
46
  HIGHLIGHT_REQUEST_HEADER = 'X-Highlight-Request'.freeze
31
47
  OTLP_HTTP = 'https://otel.highlight.io:4318'.freeze
@@ -130,6 +146,7 @@ module Highlight
130
146
  function.delete_prefix!('in `')
131
147
  function.delete_suffix!('"')
132
148
  end
149
+
133
150
  @tracer.in_span('highlight.log', attributes: {
134
151
  HIGHLIGHT_SESSION_ATTRIBUTE => session_id,
135
152
  HIGHLIGHT_TRACE_ATTRIBUTE => request_id
@@ -182,6 +199,8 @@ module Highlight
182
199
  end
183
200
 
184
201
  class Logger < ::Logger
202
+ include ActiveSupport::LoggerSilence if defined?(::ActiveSupport::LoggerSilence)
203
+
185
204
  def initialize(*args)
186
205
  super
187
206
  @local_level = nil
@@ -210,12 +229,18 @@ module Highlight
210
229
  def self.included(base)
211
230
  base.extend(ClassMethods)
212
231
  base.helper_method(:highlight_headers)
232
+ base.around_action(:with_highlight_context)
213
233
  end
214
234
 
215
235
  def with_highlight_context(&block)
216
236
  set_highlight_headers
217
- H.instance.trace(highlight_headers.session_id, highlight_headers.request_id,
218
- name: "#{request.method.upcase} #{request.path}", &block)
237
+
238
+ H.instance.trace(
239
+ highlight_headers.session_id,
240
+ highlight_headers.request_id,
241
+ name: "#{request.method.upcase} #{request.path}",
242
+ &block
243
+ )
219
244
  end
220
245
 
221
246
  private
@@ -255,4 +280,31 @@ module Highlight
255
280
  end
256
281
  end
257
282
  end
283
+
284
+ module Helpers
285
+ if defined?(ActionView)
286
+ include ActionView::Helpers
287
+ extend ActionView::Helpers::TagHelper
288
+ end
289
+
290
+ def self.traceparent_meta
291
+ current_trace = OpenTelemetry::Trace.current_span
292
+ trace_id = current_trace&.context&.trace_id
293
+ span_id = current_trace&.context&.span_id
294
+ hex_trace_id = trace_id&.unpack1('H*') || '00000000000000000000000000000000'
295
+ hex_span_id = span_id&.unpack1('H*') || '0000000000000000'
296
+
297
+ tag(:meta, name: 'traceparent', content: "00-#{hex_trace_id}-#{hex_span_id}-01")
298
+ end
299
+ end
300
+
301
+ if defined?(::Rails::Railtie)
302
+ class Railtie < ::Rails::Railtie
303
+ config.after_initialize do
304
+ ActiveSupport.on_load(:action_controller) do
305
+ include ::Highlight::Integrations::Rails
306
+ end
307
+ end
308
+ end
309
+ end
258
310
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highlight_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Highlight
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-15 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grpc
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.52'
19
+ version: '1.65'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.52'
26
+ version: '1.65'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opentelemetry-exporter-otlp
29
29
  requirement: !ruby/object:Gem::Requirement