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

rspec-otel

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rspec-otel

  • 0.0.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

RSpec Otel

RSpec matchers to be used with the OpenTelemetry framework

Installation

Add this line to your Gemfile:

gem 'rspec-otel'

Within your spec helper, require the gem:

require 'rspec_otel'

And include the matchers within the rspec configuration:

RSpec.configure do |config|
  config.include RspecOtel::Matchers
end

Usage

Matching the presence of a span

You can match the emission of a span with the emit_span matcher:

require 'spec_helper'

RSpec.describe 'User API' do
  it 'emits a span' do
    expect do
      get :user, id: 1
    end.to emit_span('GET /user')
  end
end

emit_span will also match a regular expression:

require 'spec_helper'

RSpec.describe 'User API' do
  it 'emits a span' do
    expect do
      get :user, id: 1
    end.to emit_span(/^GET /)
  end
end

Several conditions can be added to the matcher:

  • as_root - Will match spans that are the root of a trace.
  • as_child - Will match spans that are not the root of a trace
  • with_attributes - Will match only the spans with the specified attributes.
  • without_attributes - Will only match the spans that do not have the specified attributes
  • with_event - Will match only the spans with the specified event.
  • without_event - Will only match the spans that do not have the specified event
  • with_link - Will match only the spans with the specified link.
  • without_link - Will only match the spans that do not have the specified link
  • with_status - Will match only the spans that have the proper status.
  • with_exception - Will match only the spans that have the specified exception event.
  • without_exception - Will match only the spans that do not have the specified exception event.

The *_event condition can be called multiple times with different events.

Disabling

We wrap every example in a new OpenTelemetry SDK configuration by default, if you wish to disable this you can tag your example with :rspec_otel_disable_tracing:

require 'spec_helper'

RSpec.describe 'User API', :rspec_otel_disable_tracing do
  it 'tests my code' do
    expect(true).to be true
  end
end

Compatibility

RSpec Otel ensures compatibility with the currently supported versions of the Ruby Language.

FAQs

Package last updated on 23 Sep 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