From edcc00b62591b180f22cb9f5ddd2ae8398ca8779 Mon Sep 17 00:00:00 2001 From: kohbis <18735471+kohbis@users.noreply.github.com> Date: Thu, 18 Jan 2024 23:42:27 +0900 Subject: [PATCH 1/4] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20fix=20yard=20f?= =?UTF-8?q?or=20sidekiq=20instrumentation=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../instrumentation/sidekiq/instrumentation.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb index 5f374c0ca..84299a8f7 100644 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb +++ b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb @@ -38,6 +38,10 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base # - `:queue` - the span names will be set to ' '. # - `:job_class` - the span names will be set to ' '. option :span_naming, default: :queue, validate: %I[job_class queue] + # @!macro + # @!method $1 + # @instrumentation_option_default `:$2` + # @!scope class # Controls how the job's execution is traced and related # to the trace where the job was enqueued. Can be one of: # @@ -51,7 +55,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base option :propagation_style, default: :link, validate: %i[link child none] # @!macro # @!method $1 - # @instrumentation_option_default `:$2` + # @instrumentation_option_default $2 # @!scope class # Allows tracing Sidekiq::Launcher#heartbeat. option :trace_launcher_heartbeat, default: false, validate: :boolean From 9ea801ad175efd67a807dc8cc70ddd1c9061ee27 Mon Sep 17 00:00:00 2001 From: kohbis <18735471+kohbis@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:33:19 +0900 Subject: [PATCH 2/4] docs: Refactor Sidekiq instrumentation and add configuration options --- .../opentelemetry/instrumentation/sidekiq.rb | 2 +- .../sidekiq/instrumentation.rb | 127 +++++++++++------- 2 files changed, 76 insertions(+), 53 deletions(-) diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb index 77fc78d76..108c45282 100644 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb +++ b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb @@ -9,7 +9,7 @@ module OpenTelemetry module Instrumentation - # Contains the OpenTelemetry instrumentation for the Sidekiq gem + # (see OpenTelemetry::Instrumentation::Sidekiq::Instrumentation) module Sidekiq end end diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb index 84299a8f7..65b0af1d3 100644 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb +++ b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb @@ -7,8 +7,81 @@ module OpenTelemetry module Instrumentation module Sidekiq - # The Instrumentation class contains logic to detect and install the Sidekiq - # instrumentation + # The {OpenTelemetry::Instrumentation::Sidekiq::Instrumentation} class contains logic to detect and install the Sidekiq instrumentation + # + # Installation and configuration of this instrumentation is done within the + # {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry/SDK#configure-instance_method OpenTelemetry::SDK#configure} + # block, calling {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use use()} + # or {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry%2FSDK%2FConfigurator:use_all use_all()}. + # + # ## Configuration keys and options + # + # ### `:span_naming` + # + # Specifies how the span names are set. Can be one of: + # + # - `:queue` **(default)** - The job span name will appear as ' ', + # for example `default process`. + # - `:job_class` - The job span name will appear as ' ', + # for example `SimpleJob process`. + # + # ### `:propagation_style` + # + # Specifies how the job's execution is traced and related to the trace where the job was enqueued. + # + # - `:link` **(default)** - The job will be represented by a separate trace from the span that enqueued the job. + # - The initial span of the job trace will be associated with the span that enqueued the job, via a + # {https://opentelemetry.io/docs/concepts/signals/traces/#span-links Span Link}. + # - `:child` - The job will be represented within the same logical trace, as a direct + # child of the span that enqueued the job. + # - `:none` - The job will be represented by a separate trace from the span that enqueued the job. + # There will be no explicit relationship between the job trace and the trace containing the span that + # enqueued the job. + # + # ### `:trace_launcher_heartbeat` + # + # Allows tracing Sidekiq::Launcher#heartbeat. + # + # - `false` **(default)** - Sidekiq::Launcher#heartbeat will not be traced. + # - `true` - Sidekiq::Launcher#heartbeat will be traced. + # + # ### `:trace_poller_enqueue` + # + # Allows tracing Sidekiq::Scheduled#enqueue. + # + # - `false` **(default)** - Sidekiq::Scheduled#enqueue will not be traced. + # - `true` - Sidekiq::Scheduled#enqueue will be traced. + # + # ### `:trace_poller_wait` + # + # Allows tracing Sidekiq::Scheduled#wait. + # + # - `false` **(default)** - Sidekiq::Scheduled#wait will not be traced. + # - `true` - Sidekiq::Scheduled#wait will be traced. + # + # ### `:trace_processor_process_one` + # + # Allows tracing Sidekiq::Processor#process_one. + # + # - `false` **(default)** - Sidekiq::Processor#process_one will not be traced. + # - `true` - Sidekiq::Processor#process_one will be traced. + # + # ### `:peer_service` + # + # Sets service name of the remote service. + # + # - `nil` **(default)** + # + # @example An explicit default configuration + # OpenTelemetry::SDK.configure do |c| + # c.use_all({ + # 'OpenTelemetry::Instrumentation::Sidekiq' => { + # span_naming: :queue, + # propagation_style: :link, + # trace_launcher_heartbeat: true, + # }, + # }) + # end class Instrumentation < OpenTelemetry::Instrumentation::Base MINIMUM_VERSION = Gem::Version.new('4.2.10') @@ -27,63 +100,13 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base gem_version >= MINIMUM_VERSION end - # @!group Instrumentation Options - # @!macro - # @!method $1 - # @instrumentation_option_default `:$2` - # @!scope class - # - # Specify how the span names are set. Can be one of: - # - # - `:queue` - the span names will be set to ' '. - # - `:job_class` - the span names will be set to ' '. option :span_naming, default: :queue, validate: %I[job_class queue] - # @!macro - # @!method $1 - # @instrumentation_option_default `:$2` - # @!scope class - # Controls how the job's execution is traced and related - # to the trace where the job was enqueued. Can be one of: - # - # - `:link` - the job will be executed in a separate trace. The - # initial span of the execution trace will be linked to the span that - # enqueued the job, via a Span Link. - # - `:child` - the job will be executed in the same logical trace, as a direct - # child of the span that enqueued the job. - # - `:none` - the job's execution will not be explicitly linked to the span that - # enqueued the job. option :propagation_style, default: :link, validate: %i[link child none] - # @!macro - # @!method $1 - # @instrumentation_option_default $2 - # @!scope class - # Allows tracing Sidekiq::Launcher#heartbeat. option :trace_launcher_heartbeat, default: false, validate: :boolean - # @!macro - # @!method $1 - # @instrumentation_option_default $2 - # @!scope class - # Allows tracing Sidekiq::Scheduled#enqueue. option :trace_poller_enqueue, default: false, validate: :boolean - # @!macro - # @!method $1 - # @instrumentation_option_default $2 - # @!scope class - # Allows trasing Sidekiq::Scheduled#wait option :trace_poller_wait, default: false, validate: :boolean - # @!macro - # @!method $1 - # @instrumentation_option_default $2 - # @!scope class - # Allows tracing Sidekiq::Processor#process_one. option :trace_processor_process_one, default: false, validate: :boolean - # @!macro - # @!method $1 - # @instrumentation_option_default $2 - # @!scope class - # Sets service name of the remote service. option :peer_service, default: nil, validate: :string - # @!endgroup private From 0f3539d04175fc7676cc96d495a45c91bda7f360 Mon Sep 17 00:00:00 2001 From: kohbis <18735471+kohbis@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:24:44 +0900 Subject: [PATCH 3/4] Update instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com> --- .../sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb index 108c45282..530464dde 100644 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb +++ b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq.rb @@ -9,7 +9,7 @@ module OpenTelemetry module Instrumentation - # (see OpenTelemetry::Instrumentation::Sidekiq::Instrumentation) + # (see {OpenTelemetry::Instrumentation::Sidekiq::Instrumentation}) module Sidekiq end end From 7632fa152825b77cab62abb96cd6837439978fca Mon Sep 17 00:00:00 2001 From: kohbis <18735471+kohbis@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:25:12 +0900 Subject: [PATCH 4/4] Update instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com> --- .../opentelemetry/instrumentation/sidekiq/instrumentation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb index 65b0af1d3..1f3fe2720 100644 --- a/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb +++ b/instrumentation/sidekiq/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb @@ -7,7 +7,7 @@ module OpenTelemetry module Instrumentation module Sidekiq - # The {OpenTelemetry::Instrumentation::Sidekiq::Instrumentation} class contains logic to detect and install the Sidekiq instrumentation + # The `OpenTelemetry::Instrumentation::Sidekiq::Instrumentation` class contains logic to detect and install the Sidekiq instrumentation # # Installation and configuration of this instrumentation is done within the # {https://www.rubydoc.info/gems/opentelemetry-sdk/OpenTelemetry/SDK#configure-instance_method OpenTelemetry::SDK#configure}