highlight_io 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 47a28a1461841f3bc370c7b8503903f4c34d79250effe6c43b93490ceac2f7d1
4
+ data.tar.gz: f9aa14c6fb798109d8465363360e45c87dce6d32f6a117eff2821aba09bb4867
5
+ SHA512:
6
+ metadata.gz: 57996d96cf10a272655a6894d9bc00e955b203083d34f69af065c64ec1958e48b674b0ba36d61c7b0c7d9a4db35cb1c2cfdcb858e79b222d5108808d9c568ed9
7
+ data.tar.gz: d289373d842644edfa5975515d1597f229746b91fe046946f2bc5ef4b8d5c892b42fa5f526b1cb12f109914a39c4737d64e3694c8c11eefe910fc35c90ac56de
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in highlight.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "minitest", "~> 5.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,218 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ highlight (0.1.0)
5
+ grpc (~> 1.52)
6
+ opentelemetry-exporter-otlp
7
+ opentelemetry-instrumentation-all
8
+ opentelemetry-sdk
9
+ opentelemetry-semantic_conventions
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ google-protobuf (3.22.2)
15
+ googleapis-common-protos-types (1.5.0)
16
+ google-protobuf (~> 3.14)
17
+ grpc (1.52.0)
18
+ google-protobuf (~> 3.21)
19
+ googleapis-common-protos-types (~> 1.0)
20
+ minitest (5.18.0)
21
+ opentelemetry-api (1.1.0)
22
+ opentelemetry-common (0.19.6)
23
+ opentelemetry-api (~> 1.0)
24
+ opentelemetry-exporter-otlp (0.24.0)
25
+ google-protobuf (~> 3.19)
26
+ googleapis-common-protos-types (~> 1.3)
27
+ opentelemetry-api (~> 1.1)
28
+ opentelemetry-common (~> 0.19.6)
29
+ opentelemetry-sdk (~> 1.2)
30
+ opentelemetry-semantic_conventions
31
+ opentelemetry-instrumentation-action_pack (0.5.0)
32
+ opentelemetry-api (~> 1.0)
33
+ opentelemetry-instrumentation-base (~> 0.21.0)
34
+ opentelemetry-instrumentation-rack (~> 0.21)
35
+ opentelemetry-instrumentation-action_view (0.4.0)
36
+ opentelemetry-api (~> 1.0)
37
+ opentelemetry-instrumentation-active_support (~> 0.1)
38
+ opentelemetry-instrumentation-base (~> 0.20)
39
+ opentelemetry-instrumentation-active_job (0.4.0)
40
+ opentelemetry-api (~> 1.0)
41
+ opentelemetry-instrumentation-base (~> 0.21.0)
42
+ opentelemetry-instrumentation-active_model_serializers (0.19.1)
43
+ opentelemetry-api (~> 1.0)
44
+ opentelemetry-instrumentation-base (~> 0.21.0)
45
+ opentelemetry-instrumentation-active_record (0.5.0)
46
+ opentelemetry-api (~> 1.0)
47
+ opentelemetry-instrumentation-base (~> 0.21.0)
48
+ ruby2_keywords
49
+ opentelemetry-instrumentation-active_support (0.3.0)
50
+ opentelemetry-api (~> 1.0)
51
+ opentelemetry-instrumentation-base (~> 0.21.0)
52
+ opentelemetry-instrumentation-all (0.32.0)
53
+ opentelemetry-instrumentation-active_model_serializers (~> 0.19.0)
54
+ opentelemetry-instrumentation-aws_sdk (~> 0.3.0)
55
+ opentelemetry-instrumentation-bunny (~> 0.19.0)
56
+ opentelemetry-instrumentation-concurrent_ruby (~> 0.20.0)
57
+ opentelemetry-instrumentation-dalli (~> 0.22.0)
58
+ opentelemetry-instrumentation-delayed_job (~> 0.19.0)
59
+ opentelemetry-instrumentation-ethon (~> 0.20.0)
60
+ opentelemetry-instrumentation-excon (~> 0.20.0)
61
+ opentelemetry-instrumentation-faraday (~> 0.22.0)
62
+ opentelemetry-instrumentation-graphql (~> 0.23.0)
63
+ opentelemetry-instrumentation-http (~> 0.21.0)
64
+ opentelemetry-instrumentation-http_client (~> 0.21.0)
65
+ opentelemetry-instrumentation-koala (~> 0.19.0)
66
+ opentelemetry-instrumentation-lmdb (~> 0.21.0)
67
+ opentelemetry-instrumentation-mongo (~> 0.21.0)
68
+ opentelemetry-instrumentation-mysql2 (~> 0.22.0)
69
+ opentelemetry-instrumentation-net_http (~> 0.21.0)
70
+ opentelemetry-instrumentation-pg (~> 0.23.0)
71
+ opentelemetry-instrumentation-que (~> 0.5.0)
72
+ opentelemetry-instrumentation-racecar (~> 0.1.0)
73
+ opentelemetry-instrumentation-rack (~> 0.22.0)
74
+ opentelemetry-instrumentation-rails (~> 0.25.0)
75
+ opentelemetry-instrumentation-rake (~> 0.1.0)
76
+ opentelemetry-instrumentation-rdkafka (~> 0.2.0)
77
+ opentelemetry-instrumentation-redis (~> 0.24.0)
78
+ opentelemetry-instrumentation-resque (~> 0.3.0)
79
+ opentelemetry-instrumentation-restclient (~> 0.21.0)
80
+ opentelemetry-instrumentation-ruby_kafka (~> 0.19.0)
81
+ opentelemetry-instrumentation-sidekiq (~> 0.22.0)
82
+ opentelemetry-instrumentation-sinatra (~> 0.21.0)
83
+ opentelemetry-instrumentation-trilogy (~> 0.52.0)
84
+ opentelemetry-instrumentation-aws_sdk (0.3.2)
85
+ opentelemetry-api (~> 1.0)
86
+ opentelemetry-instrumentation-base (~> 0.21.0)
87
+ opentelemetry-instrumentation-base (0.21.1)
88
+ opentelemetry-api (~> 1.0)
89
+ opentelemetry-registry (~> 0.1)
90
+ opentelemetry-instrumentation-bunny (0.19.1)
91
+ opentelemetry-api (~> 1.0)
92
+ opentelemetry-instrumentation-base (~> 0.21.0)
93
+ opentelemetry-instrumentation-concurrent_ruby (0.20.1)
94
+ opentelemetry-api (~> 1.0)
95
+ opentelemetry-instrumentation-base (~> 0.21.0)
96
+ opentelemetry-instrumentation-dalli (0.22.2)
97
+ opentelemetry-api (~> 1.0)
98
+ opentelemetry-common (~> 0.19.3)
99
+ opentelemetry-instrumentation-base (~> 0.21.0)
100
+ opentelemetry-instrumentation-delayed_job (0.19.1)
101
+ opentelemetry-api (~> 1.0)
102
+ opentelemetry-instrumentation-base (~> 0.21.0)
103
+ opentelemetry-instrumentation-ethon (0.20.1)
104
+ opentelemetry-api (~> 1.0)
105
+ opentelemetry-common (~> 0.19.3)
106
+ opentelemetry-instrumentation-base (~> 0.21.0)
107
+ opentelemetry-instrumentation-excon (0.20.1)
108
+ opentelemetry-api (~> 1.0)
109
+ opentelemetry-common (~> 0.19.3)
110
+ opentelemetry-instrumentation-base (~> 0.21.0)
111
+ opentelemetry-instrumentation-faraday (0.22.0)
112
+ opentelemetry-api (~> 1.0)
113
+ opentelemetry-common (~> 0.19.3)
114
+ opentelemetry-instrumentation-base (~> 0.21.0)
115
+ opentelemetry-instrumentation-graphql (0.23.0)
116
+ opentelemetry-api (~> 1.0)
117
+ opentelemetry-instrumentation-base (~> 0.21.0)
118
+ opentelemetry-instrumentation-http (0.21.0)
119
+ opentelemetry-api (~> 1.0)
120
+ opentelemetry-instrumentation-base (~> 0.21.0)
121
+ opentelemetry-instrumentation-http_client (0.21.0)
122
+ opentelemetry-api (~> 1.0)
123
+ opentelemetry-common (~> 0.19.3)
124
+ opentelemetry-instrumentation-base (~> 0.21.0)
125
+ opentelemetry-instrumentation-koala (0.19.1)
126
+ opentelemetry-api (~> 1.0)
127
+ opentelemetry-common (~> 0.19.3)
128
+ opentelemetry-instrumentation-base (~> 0.21.0)
129
+ opentelemetry-instrumentation-lmdb (0.21.1)
130
+ opentelemetry-api (~> 1.0)
131
+ opentelemetry-instrumentation-base (~> 0.21.0)
132
+ opentelemetry-instrumentation-mongo (0.21.1)
133
+ opentelemetry-api (~> 1.0)
134
+ opentelemetry-instrumentation-base (~> 0.21.0)
135
+ opentelemetry-instrumentation-mysql2 (0.22.0)
136
+ opentelemetry-api (~> 1.0)
137
+ opentelemetry-instrumentation-base (~> 0.21.0)
138
+ opentelemetry-instrumentation-net_http (0.21.1)
139
+ opentelemetry-api (~> 1.0)
140
+ opentelemetry-common (~> 0.19.3)
141
+ opentelemetry-instrumentation-base (~> 0.21.0)
142
+ opentelemetry-instrumentation-pg (0.23.0)
143
+ opentelemetry-api (~> 1.0)
144
+ opentelemetry-instrumentation-base (~> 0.21.0)
145
+ opentelemetry-instrumentation-que (0.5.1)
146
+ opentelemetry-api (~> 1.0)
147
+ opentelemetry-instrumentation-base (~> 0.21.0)
148
+ opentelemetry-instrumentation-racecar (0.1.1)
149
+ opentelemetry-api (~> 1.0)
150
+ opentelemetry-instrumentation-base (~> 0.21.0)
151
+ opentelemetry-instrumentation-rack (0.22.1)
152
+ opentelemetry-api (~> 1.0)
153
+ opentelemetry-common (~> 0.19.3)
154
+ opentelemetry-instrumentation-base (~> 0.21.0)
155
+ opentelemetry-instrumentation-rails (0.25.0)
156
+ opentelemetry-api (~> 1.0)
157
+ opentelemetry-instrumentation-action_pack (~> 0.5.0)
158
+ opentelemetry-instrumentation-action_view (~> 0.4.0)
159
+ opentelemetry-instrumentation-active_job (~> 0.4.0)
160
+ opentelemetry-instrumentation-active_record (~> 0.5.0)
161
+ opentelemetry-instrumentation-active_support (~> 0.3.0)
162
+ opentelemetry-instrumentation-base (~> 0.21.0)
163
+ opentelemetry-instrumentation-rake (0.1.1)
164
+ opentelemetry-api (~> 1.0)
165
+ opentelemetry-instrumentation-base (~> 0.21.0)
166
+ opentelemetry-instrumentation-rdkafka (0.2.2)
167
+ opentelemetry-api (~> 1.0)
168
+ opentelemetry-common (~> 0.19.3)
169
+ opentelemetry-instrumentation-base (~> 0.21.0)
170
+ opentelemetry-instrumentation-redis (0.24.1)
171
+ opentelemetry-api (~> 1.0)
172
+ opentelemetry-common (~> 0.19.3)
173
+ opentelemetry-instrumentation-base (~> 0.21.0)
174
+ opentelemetry-instrumentation-resque (0.3.1)
175
+ opentelemetry-api (~> 1.0)
176
+ opentelemetry-instrumentation-base (~> 0.21.0)
177
+ opentelemetry-instrumentation-restclient (0.21.0)
178
+ opentelemetry-api (~> 1.0)
179
+ opentelemetry-common (~> 0.19.3)
180
+ opentelemetry-instrumentation-base (~> 0.21.0)
181
+ opentelemetry-instrumentation-ruby_kafka (0.19.1)
182
+ opentelemetry-api (~> 1.0)
183
+ opentelemetry-instrumentation-base (~> 0.21.0)
184
+ opentelemetry-instrumentation-sidekiq (0.22.1)
185
+ opentelemetry-api (~> 1.0)
186
+ opentelemetry-common (~> 0.19.3)
187
+ opentelemetry-instrumentation-base (~> 0.21.0)
188
+ opentelemetry-instrumentation-sinatra (0.21.5)
189
+ opentelemetry-api (~> 1.0)
190
+ opentelemetry-common (~> 0.19.3)
191
+ opentelemetry-instrumentation-base (~> 0.21.0)
192
+ opentelemetry-instrumentation-rack (~> 0.21)
193
+ opentelemetry-instrumentation-trilogy (0.52.0)
194
+ opentelemetry-api (~> 1.0)
195
+ opentelemetry-instrumentation-base (~> 0.21.0)
196
+ opentelemetry-semantic_conventions (>= 1.8.0)
197
+ opentelemetry-registry (0.2.0)
198
+ opentelemetry-api (~> 1.1)
199
+ opentelemetry-sdk (1.2.0)
200
+ opentelemetry-api (~> 1.1)
201
+ opentelemetry-common (~> 0.19.3)
202
+ opentelemetry-registry (~> 0.2)
203
+ opentelemetry-semantic_conventions
204
+ opentelemetry-semantic_conventions (1.8.0)
205
+ opentelemetry-api (~> 1.0)
206
+ rake (12.3.3)
207
+ ruby2_keywords (0.0.5)
208
+
209
+ PLATFORMS
210
+ ruby
211
+
212
+ DEPENDENCIES
213
+ highlight!
214
+ minitest (~> 5.0)
215
+ rake (~> 12.0)
216
+
217
+ BUNDLED WITH
218
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Zane Mayberry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Highlight
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/highlight`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'highlight'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install highlight
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/highlight.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "highlight"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/highlight.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ require_relative 'lib/highlight/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "highlight_io"
5
+ spec.version = Highlight::VERSION
6
+ spec.authors = ["Highlight"]
7
+ spec.email = ["support@highlight.io"]
8
+
9
+ spec.summary = "The Highlight SDK for Ruby"
10
+ spec.homepage = "https://www.highlight.io"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_runtime_dependency 'opentelemetry-sdk'
26
+ spec.add_runtime_dependency 'opentelemetry-exporter-otlp'
27
+ spec.add_runtime_dependency 'opentelemetry-instrumentation-all'
28
+ spec.add_runtime_dependency 'opentelemetry-semantic_conventions'
29
+ spec.add_runtime_dependency 'grpc', '~> 1.52'
30
+ end
@@ -0,0 +1,3 @@
1
+ module Highlight
2
+ VERSION = "0.1.0"
3
+ end
data/lib/highlight.rb ADDED
@@ -0,0 +1,155 @@
1
+ require "opentelemetry/sdk"
2
+ require "opentelemetry/exporter/otlp"
3
+ require "opentelemetry/instrumentation/all"
4
+ require "opentelemetry/semantic_conventions"
5
+ require "logger"
6
+
7
+ module Highlight
8
+ class H
9
+ HIGHLIGHT_REQUEST_HEADER = "X-Highlight-Request"
10
+ OTLP_HTTP = "https://otel.highlight.io:4318"
11
+ HIGHLIGHT_PROJECT_ATTRIBUTE = "highlight.project_id"
12
+ HIGHLIGHT_SESSION_ATTRIBUTE = "highlight.session_id"
13
+ HIGHLIGHT_TRACE_ATTRIBUTE = "highlight.trace_id"
14
+ LOG_EVENT = "log"
15
+ LOG_SEVERITY_ATTRIBUTE = "log.severity"
16
+ LOG_MESSAGE_ATTRIBUTE = "log.message"
17
+ CODE_FILEPATH = OpenTelemetry::SemanticConventions::Trace::CODE_FILEPATH
18
+ CODE_LINENO = OpenTelemetry::SemanticConventions::Trace::CODE_LINENO
19
+ CODE_FUNCTION = OpenTelemetry::SemanticConventions::Trace::CODE_FUNCTION
20
+
21
+ def self.instance
22
+ return @@instance
23
+ end
24
+
25
+ def initialize(project_id, otlp_endpoint=OTLP_HTTP)
26
+ @@instance = self
27
+
28
+ @project_id = project_id
29
+ @otlp_endpoint = otlp_endpoint
30
+
31
+ OpenTelemetry::SDK.configure do |c|
32
+ c.service_name = "highlight-sdk"
33
+ c.add_span_processor(OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
34
+ OpenTelemetry::Exporter::OTLP::Exporter.new(endpoint: @otlp_endpoint + "/v1/traces")
35
+ ))
36
+ end
37
+
38
+ @tracer_provider = OpenTelemetry.tracer_provider
39
+ @tracer = @tracer_provider.tracer("highlight-tracer")
40
+ end
41
+
42
+ def flush
43
+ @tracer_provider.force_flush
44
+ end
45
+
46
+ def trace(session_id, request_id)
47
+ @tracer.in_span("highlight-ctx", attributes: {
48
+ HIGHLIGHT_PROJECT_ATTRIBUTE => @project_id,
49
+ HIGHLIGHT_SESSION_ATTRIBUTE => session_id,
50
+ HIGHLIGHT_TRACE_ATTRIBUTE => request_id,
51
+ }.compact) do |span|
52
+ begin
53
+ yield
54
+ rescue => e
55
+ record_exception(e)
56
+ raise
57
+ end
58
+ end
59
+ end
60
+
61
+ def record_exception(e)
62
+ span = OpenTelemetry::Trace.current_span
63
+ return unless span
64
+ span.record_exception(e)
65
+ end
66
+
67
+ def record_log(session_id, request_id, level, message)
68
+ caller_info = caller[0].split(":", 3)
69
+ function = caller_info[2]
70
+ if function
71
+ # format: "in `<function_name>""
72
+ function.delete_prefix!("in `")
73
+ function.delete_suffix!("\"")
74
+ end
75
+ @tracer.in_span("highlight-ctx", attributes: {
76
+ HIGHLIGHT_PROJECT_ATTRIBUTE => @project_id,
77
+ HIGHLIGHT_SESSION_ATTRIBUTE => session_id,
78
+ HIGHLIGHT_TRACE_ATTRIBUTE => request_id,
79
+ }.compact) do |span|
80
+ if level == Logger::ERROR || level == Logger::FATAL
81
+ span.status = OpenTelemetry::Trace::Status.error(message)
82
+ end
83
+ span.add_event(LOG_EVENT, attributes: {
84
+ LOG_SEVERITY_ATTRIBUTE => H.log_level_string(level),
85
+ LOG_MESSAGE_ATTRIBUTE => message,
86
+ CODE_FILEPATH => caller_info[0],
87
+ CODE_LINENO => caller_info[1],
88
+ CODE_FUNCTION => function,
89
+ })
90
+ end
91
+ end
92
+
93
+ HighlightHeaders = Struct.new("HighlightHeaders", :session_id, :request_id)
94
+ def self.parse_headers(headers)
95
+ if headers && headers[HIGHLIGHT_REQUEST_HEADER]
96
+ session_id, request_id = headers[HIGHLIGHT_REQUEST_HEADER].split("/")
97
+ return HighlightHeaders.new(session_id, request_id)
98
+ end
99
+ return HighlightHeaders.new(nil, nil)
100
+ end
101
+
102
+ private
103
+
104
+ def self.log_level_string(level)
105
+ case level
106
+ when Logger::UNKNOWN
107
+ "UNKNOWN"
108
+ when Logger::FATAL
109
+ "FATAL"
110
+ when Logger::ERROR
111
+ "ERROR"
112
+ when Logger::WARN
113
+ "WARN"
114
+ when Logger::INFO
115
+ "INFO"
116
+ when Logger::DEBUG
117
+ "DEBUG"
118
+ else
119
+ "UNKNOWN"
120
+ end
121
+ end
122
+ end
123
+
124
+ class Logger < ::Logger
125
+ def add(severity, message = nil, progname = nil)
126
+ # https://github.com/ruby/logger/blob/master/lib/logger.rb
127
+ severity ||= UNKNOWN
128
+ if @logdev.nil? or severity < level
129
+ return true
130
+ end
131
+ if progname.nil?
132
+ progname = @progname
133
+ end
134
+ if message.nil?
135
+ if block_given?
136
+ message = yield
137
+ else
138
+ message = progname
139
+ progname = @progname
140
+ end
141
+ end
142
+ super
143
+ H.instance.record_log(nil, nil, severity, message)
144
+ end
145
+ end
146
+
147
+ module Integrations
148
+ module Rails
149
+ def with_highlight_context
150
+ highlight_headers = H.parse_headers(request.headers)
151
+ H.instance.trace(highlight_headers.session_id, highlight_headers.request_id) { yield }
152
+ end
153
+ end
154
+ end
155
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: highlight_io
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Highlight
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opentelemetry-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opentelemetry-exporter-otlp
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: opentelemetry-instrumentation-all
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: opentelemetry-semantic_conventions
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: grpc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.52'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.52'
83
+ description:
84
+ email:
85
+ - support@highlight.io
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - highlight.gemspec
100
+ - lib/highlight.rb
101
+ - lib/highlight/version.rb
102
+ homepage: https://www.highlight.io
103
+ licenses:
104
+ - MIT
105
+ metadata:
106
+ homepage_uri: https://www.highlight.io
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 2.3.0
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubygems_version: 3.1.4
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: The Highlight SDK for Ruby
126
+ test_files: []