Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opentelemetry-instrumentation-active_job

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opentelemetry-instrumentation-active_job

  • 0.7.8
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

OpenTelemetry ActiveJob Instrumentation

The OpenTelemetry Active Job gem is a community maintained instrumentation for ActiveJob.

How do I get started?

Install the gem using:

gem install opentelemetry-instrumentation-active_job

Or, if you use bundler, include opentelemetry-instrumentation-active_job in your Gemfile.

Usage

To use the instrumentation, call use with the name of the instrumentation:

OpenTelemetry::SDK.configure do |c|
  c.use 'OpenTelemetry::Instrumentation::ActiveJob'
end

Alternatively, you can also call use_all to install all the available instrumentation.

OpenTelemetry::SDK.configure do |c|
  c.use_all
end

Active Support Instrumentation

Earlier versions of this instrumentation relied on registering custom around_perform hooks in order to deal with limitations in ActiveSupport::Notifications, however those patches resulted in error reports and inconsistent behavior when combined with other gems.

This instrumentation now relies entirely on ActiveSupport::Notifications and registers a custom Subscriber that listens to relevant events to report as spans.

See the table below for details of what Rails Framework Hook Events are recorded by this instrumentation:

Event NameCreates Span?Notes
enqueue_at.active_job:white_check_mark:Creates an egress span with kind producer
enqueue.active_job:white_check_mark:Creates an egress span with kind producer
enqueue_retry.active_job:white_check_mark:Creates an internal span
perform_start.active_job:x:This is invoked prior to the appropriate ingress point and is therefore ignored
perform.active_job:white_check_mark:Creates an ingress span with kind consumer
retry_stopped.active_job:white_check_mark:Creates and internal span with an exception event
discard.active_job:white_check_mark:Creates and internal span with an exception event

Semantic Conventions

This instrumentation generally uses Messaging semantic conventions by treating job enqueuers as producers and workers as consumers.

Internal spans are named using the name of the ActiveSupport event that was provided.

Attributes that are specific to this instrumentation are recorded under messaging.active_job.*:

Attribute NameTypeNotes
code.namespaceStringActiveJob class name
messaging.systemStringStatic value set to active_job
messaging.destinationStringSet from ActiveJob#queue_name
messaging.message.idStringSet from ActiveJob#job_id
messaging.active_job.adapter.nameStringThe name of the ActiveJob adapter implementation
messaging.active_job.message.priorityStringPresent when set by the client from ActiveJob#priority
messaging.active_job.message.provider_job_idStringPresent if the underlying adapter has backend specific message ids

Differences between ActiveJob versions

ActiveJob 6.1

perform.active_job events do not include timings for ActiveJob callbacks therefore time spent in before and after hooks will be missing

ActiveJob 7+

perform.active_job no longer includes exceptions handled using rescue_from in the payload.

In order to preserve this behavior you will have to update the span yourself, e.g.

  rescue_from MyCustomError do |e|
    # Custom code to handle the error
    span = OpenTelemetry::Instrumentation::ActiveJob.current_span
    span.record_exception(e)
    span.status = OpenTelemetry::Trace::Status.error('Job failed')
  end

Examples

Example usage can be seen in the ./example/active_job.rb file here

How can I get involved?

The opentelemetry-instrumentation-active_job gem source is on github, along with related gems including opentelemetry-api and opentelemetry-sdk.

The OpenTelemetry Ruby gems are maintained by the OpenTelemetry Ruby special interest group (SIG). You can get involved by joining us on our GitHub Discussions, Slack Channel or attending our weekly meeting. See the meeting calendar for dates and times. For more information on this and other language SIGs, see the OpenTelemetry community page.

License

The opentelemetry-instrumentation-active_job gem is distributed under the Apache 2.0 license. See LICENSE for more information.

FAQs

Package last updated on 24 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc