Skip to content

Commit

Permalink
Merge branch 'main' into lambda-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
xuan-cao-swi authored May 10, 2024
2 parents ecc8b54 + a466ae3 commit 1b4d969
Show file tree
Hide file tree
Showing 41 changed files with 158 additions and 54 deletions.
4 changes: 4 additions & 0 deletions instrumentation/dalli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-dalli

### v0.25.2 / 2024-05-09

* FIXED: Untrace entire request

### v0.25.1 / 2024-04-30

* FIXED: Bundler conflict warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module Dalli
VERSION = '0.25.1'
VERSION = '0.25.2'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/ethon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-ethon

### v0.21.5 / 2024-05-09

* FIXED: Untrace entire request

### v0.21.4 / 2024-04-30

* FIXED: Bundler conflict warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module Ethon
VERSION = '0.21.4'
VERSION = '0.21.5'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/excon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-excon

### v0.22.2 / 2024-05-09

* FIXED: Untrace entire request

### v0.22.1 / 2024-04-30

* FIXED: Bundler conflict warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module Excon
VERSION = '0.22.1'
VERSION = '0.22.2'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/faraday/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-faraday

### v0.24.3 / 2024-05-09

* FIXED: Untrace entire request

### v0.24.2 / 2024-04-30

* FIXED: Bundler conflict warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module Faraday
VERSION = '0.24.2'
VERSION = '0.24.3'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/http_client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-http_client

### v0.22.5 / 2024-05-09

* FIXED: Untrace entire request

### v0.22.4 / 2024-04-30

* FIXED: Bundler conflict warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module HttpClient
VERSION = '0.22.4'
VERSION = '0.22.5'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/koala/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-koala

### v0.20.4 / 2024-05-09

* FIXED: Untrace entire request

### v0.20.3 / 2024-04-30

* FIXED: Bundler conflict warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module Koala
VERSION = '0.20.3'
VERSION = '0.20.4'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
4 changes: 4 additions & 0 deletions instrumentation/net_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release History: opentelemetry-instrumentation-net_http

### v0.22.5 / 2024-05-09

* FIXED: Untrace entire request

### v0.22.4 / 2023-11-23

* CHANGED: Applied Rubocop Performance Recommendations [#727](https://github.com/open-telemetry/opentelemetry-ruby-contrib/pull/727)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module OpenTelemetry
module Instrumentation
module Net
module HTTP
VERSION = '0.22.4'
VERSION = '0.22.5'
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'bundler', '~> 2.4'
Expand Down
8 changes: 8 additions & 0 deletions instrumentation/rack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release History: opentelemetry-instrumentation-rack

### v0.24.4 / 2024-05-09

* FIXED: Untrace entire request

### v0.24.3 / 2024-05-08

* FIXED: Rack event baggage handling

### v0.24.2 / 2024-04-30

* FIXED: Bundler conflict warnings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module Middlewares
class EventHandler
include ::Rack::Events::Abstract

TOKENS_KEY = 'otel.context.tokens'
OTEL_TOKEN_AND_SPAN = 'otel.rack.token_and_span'
GOOD_HTTP_STATUSES = (100..499)

# Creates a server span for this current request using the incoming parent context
Expand All @@ -52,11 +52,16 @@ class EventHandler
# @param [Rack::Response] This is nil in practice
# @return [void]
def on_start(request, _)
return if untraced_request?(request.env)
parent_context = if untraced_request?(request.env)
extract_remote_context(request, OpenTelemetry::Common::Utilities.untraced)
else
extract_remote_context(request)
end

parent_context = extract_remote_context(request)
span = create_span(parent_context, request)
request.env[TOKENS_KEY] = register_current_span(span)
span_ctx = OpenTelemetry::Trace.context_with_span(span, parent_context: parent_context)
rack_ctx = OpenTelemetry::Instrumentation::Rack.context_with_span(span, parent_context: span_ctx)
request.env[OTEL_TOKEN_AND_SPAN] = [OpenTelemetry::Context.attach(rack_ctx), span]
rescue StandardError => e
OpenTelemetry.handle_error(exception: e)
end
Expand Down Expand Up @@ -108,7 +113,7 @@ def on_finish(request, response)
rescue StandardError => e
OpenTelemetry.handle_error(exception: e)
ensure
detach_contexts(request)
detach_context(request)
end

private
Expand Down Expand Up @@ -171,9 +176,10 @@ def create_request_span_name(request)
end
end

def extract_remote_context(request)
def extract_remote_context(request, context = Context.current)
OpenTelemetry.propagation.extract(
request.env,
context: context,
getter: OpenTelemetry::Common::Propagation.rack_env_getter
)
end
Expand All @@ -191,11 +197,12 @@ def request_span_attributes(env)
attributes
end

def detach_contexts(request)
request.env[TOKENS_KEY]&.reverse_each do |token|
OpenTelemetry::Context.detach(token)
OpenTelemetry::Trace.current_span.finish
end
def detach_context(request)
return nil unless request.env[OTEL_TOKEN_AND_SPAN]

token, span = request.env[OTEL_TOKEN_AND_SPAN]
span.finish
OpenTelemetry::Context.detach(token)
rescue StandardError => e
OpenTelemetry.handle_error(exception: e)
end
Expand Down Expand Up @@ -244,15 +251,6 @@ def config
OpenTelemetry::Instrumentation::Rack::Instrumentation.instance.config
end

def register_current_span(span)
ctx = OpenTelemetry::Trace.context_with_span(span)
rack_ctx = OpenTelemetry::Instrumentation::Rack.context_with_span(span, parent_context: ctx)

contexts = [ctx, rack_ctx]
contexts.compact!
contexts.map { |context| OpenTelemetry::Context.attach(context) }
end

def create_span(parent_context, request)
span = tracer.start_span(
create_request_span_name(request),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module OpenTelemetry
module Instrumentation
module Rack
VERSION = '0.24.2'
VERSION = '0.24.4'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 3.0'

spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common', '~> 0.20.0'
spec.add_dependency 'opentelemetry-common', '~> 0.21.0'
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.22.1'

spec.add_development_dependency 'appraisal', '~> 2.5'
Expand Down
Loading

0 comments on commit 1b4d969

Please sign in to comment.