{"id":14991239,"url":"https://github.com/dmathieu/rspec-otel","last_synced_at":"2026-04-14T19:01:10.105Z","repository":{"id":222318745,"uuid":"756784885","full_name":"dmathieu/rspec-otel","owner":"dmathieu","description":"RSpec matchers for the OpenTelemetry framework","archived":false,"fork":false,"pushed_at":"2026-04-14T11:59:00.000Z","size":272,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-14T12:13:23.844Z","etag":null,"topics":["opentelemetry","rspec","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmathieu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-13T10:00:07.000Z","updated_at":"2026-04-14T11:59:00.000Z","dependencies_parsed_at":"2024-04-29T17:54:57.801Z","dependency_job_id":"902faf52-6f53-4b17-9d2b-7c2fb22891c1","html_url":"https://github.com/dmathieu/rspec-otel","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":0.3529411764705882,"last_synced_commit":"211f822a376adadf55d52f9f6a173d92e9655113"},"previous_names":["dmathieu/rspec-otel"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/dmathieu/rspec-otel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Frspec-otel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Frspec-otel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Frspec-otel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Frspec-otel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmathieu","download_url":"https://codeload.github.com/dmathieu/rspec-otel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmathieu%2Frspec-otel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31810741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opentelemetry","rspec","ruby"],"created_at":"2024-09-24T14:21:57.210Z","updated_at":"2026-04-14T19:01:10.099Z","avatar_url":"https://github.com/dmathieu.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RSpec Otel\n\nRSpec matchers to be used with the OpenTelemetry framework\n\n## Installation\n\nAdd this line to your Gemfile:\n\n```ruby\ngem 'rspec-otel'\n```\n\nWithin your spec helper, require the gem:\n\n```ruby\nrequire 'rspec_otel'\n```\n\nAnd include the matchers within the rspec configuration:\n\n```ruby\nRSpec.configure do |config|\n  config.include RspecOtel::Matchers\nend\n```\n\n## Usage\n\n### Matching the presence of a span\n\nYou can match the emission of a span with the `emit_span` matcher:\n\n```ruby\nrequire 'spec_helper'\n\nRSpec.describe 'User API' do\n  it 'emits a span' do\n    expect do\n      get :user, id: 1\n    end.to emit_span('GET /user')\n  end\nend\n```\n\n`emit_span` will also match a regular expression:\n\n```ruby\nrequire 'spec_helper'\n\nRSpec.describe 'User API' do\n  it 'emits a span' do\n    expect do\n      get :user, id: 1\n    end.to emit_span(/^GET /)\n  end\nend\n```\n\nSeveral conditions can be added to the matcher:\n\n* `as_root` - Will match spans that are the root of a trace.\n* `as_child` - Will match spans that are not the root of a trace\n* `with_attributes` - Will match only the spans with the specified attributes.\n* `without_attributes` - Will only match the spans that do not have the specified attributes\n* `with_event` - Will match only the spans with the specified event.\n* `without_event` - Will only match the spans that do not have the specified event\n* `with_link` - Will match only the spans with the specified link.\n* `without_link` - Will only match the spans that do not have the specified link\n* `with_status` - Will match only the spans that have the proper status.\n* `with_exception` - Will match only the spans that have the specified exception event.\n* `without_exception` - Will match only the spans that do not have the specified exception event.\n\n_The `*_event` condition can be called multiple times with different events._\n\n\n### Matching the presence of a metric\n\nYou can match the emission of a metric with the `emit_metric` matcher:\n\n```ruby\nrequire 'spec_helper'\n\nRSpec.describe 'User API' do\n  it 'emits a metric' do\n    expect do\n      get :user, id: 1\n    end.to emit_metric('http.server.duration')\n  end\nend\n```\n\n`emit_metric` will also match a regular expression:\n\n```ruby\nexpect do\n  get :user, id: 1\nend.to emit_metric(/^http\\.server\\./)\n```\n\nSeveral conditions can be added to the matcher:\n\n* `of_type` - Will match only metrics of the specified instrument kind (`:counter`, `:histogram`, `:gauge`, `:up_down_counter`, `:observable_counter`, `:observable_gauge`, `:observable_up_down_counter`).\n* `with_attributes` - Will match only the metrics with the specified attributes on a data point.\n* `without_attributes` - Will only match the metrics that do not have the specified attributes on any data point.\n* `with_value` - Will match only the metrics where a data point has the specified value (applies to counters, gauges, and up-down counters).\n* `with_count` - Will match only the metrics where a histogram data point has the specified recording count (applies to histograms only).\n\n```ruby\nexpect do\n  get :user, id: 1\nend.to emit_metric('http.server.duration')\n       .of_type(:histogram)\n       .with_attributes({ 'http.request.method' =\u003e 'GET' })\n```\n\n\n### Disabling\n\nWe 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`:\n\n```ruby\nrequire 'spec_helper'\n\nRSpec.describe 'User API', :rspec_otel_disable_tracing do\n  it 'tests my code' do\n    expect(true).to be true\n  end\nend\n```\n\n## Compatibility\n\nRSpec Otel ensures compatibility with the currently supported versions of the\n[Ruby Language](https://www.ruby-lang.org/en/downloads/branches/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmathieu%2Frspec-otel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmathieu%2Frspec-otel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmathieu%2Frspec-otel/lists"}