{"id":15605321,"url":"https://github.com/iaintshine/ruby-spanmanager","last_synced_at":"2025-06-10T08:04:31.350Z","repository":{"id":56896548,"uuid":"99167747","full_name":"iaintshine/ruby-spanmanager","owner":"iaintshine","description":"Current span management for OpenTracing in Ruby","archived":false,"fork":false,"pushed_at":"2017-09-02T22:26:32.000Z","size":27,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T08:41:54.141Z","etag":null,"topics":["opentracing","ruby","span-management","tracing"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iaintshine.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}},"created_at":"2017-08-02T22:55:09.000Z","updated_at":"2021-02-26T13:34:00.000Z","dependencies_parsed_at":"2022-08-21T00:50:42.162Z","dependency_job_id":null,"html_url":"https://github.com/iaintshine/ruby-spanmanager","commit_stats":null,"previous_names":["iaintshine/ruby-activespan"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iaintshine%2Fruby-spanmanager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iaintshine%2Fruby-spanmanager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iaintshine%2Fruby-spanmanager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iaintshine%2Fruby-spanmanager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iaintshine","download_url":"https://codeload.github.com/iaintshine/ruby-spanmanager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iaintshine%2Fruby-spanmanager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258450382,"owners_count":22702947,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["opentracing","ruby","span-management","tracing"],"created_at":"2024-10-03T04:04:06.623Z","updated_at":"2025-06-10T08:04:31.325Z","avatar_url":"https://github.com/iaintshine.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/iaintshine/ruby-spanmanager.svg?branch=master)](https://travis-ci.org/iaintshine/ruby-spanmanager)\n\n# SpanManager\n\nCurrent span management for OpenTracing in Ruby.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'spanmanager'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install spanmanager\n\n\n## ManagedSpanSource\n\n`ManagedSpanSource` is a pluggable class that keeps track of the current active span. It relieves application developers from passing the current span around through their code. Application developers won't need to interact with a `ManagedSpanSource` reference directly, only implicitly through `SpanManager::Tracer`.\n\n`ManagedSpanSource` provides the following methods:\n\n1. `make_active(span)`  wraps and makes the given span active.\n2. `active_span` returns the current active span.\n3. `clear` unconditionally cleans up all manages spans.\n\n## ThreadLocalManagedSpanSource\n\n`ThreadLocalManagedSpanSource` is an actual implementation of `ManagedSpanSource`. Allows an application access and manipulation of the current span state on per thread basis. Maintains a stack-like thread-local storage of managed spans.\n\n## ManagedSpan\n\n`ManagedSpan` is a wrapper that forwards all calls to another `OpenTracing::Span` and layers on an in-process propagation capabilities.\nThe behaviour of `finish` method is changed. In addition to calling finish on wrapped span, if not yet deactivated, marks the end of active period for the span.\n\nProvides the following additional methods:\n\n1. `deactivate` marks the end of active period for the current span.\n2. `active?` returns whether the span is active or not.\n3. `wrapped` returns the wrapped span.\n\n## SpanManager::Tracer\n\nThe library exposes a convenience `OpenTracing::Tracer` that automates managing current span.\n\nIt's a wrapper that forwards all calls to another `OpenTracing::Tracer` implementation e.g. Lightstep, Jaeger etc.\nSpans which you will create through this tracer will be automatically activated when started, and\ndeactivated when they finish.\n\nProvides the following additional methods:\n\n1. `wrapped` returns the wrapped tracer.\n\n## Usage\n\n```ruby\nrequire 'spanmanager'\n\nOpenTracing.global_tracer = SpanManager::Tracer.new(Jaeger::Client.build, SpanManager::ThreadLocalManagedSpanSource.new)\n```\n\nTo start a new active span, use the regular and known `start_span` method. If you use the default argument for `child_of` argument\nthen the currently active span becomes an implicit parent of a newly-started span. It means that you no longer have to \npass the current span through the code.\n\nWhen you finish the span, and if not yet deactivated, marks the end of the active period for the span. For `ThreadLocalManagedSpanSource`\nit means it's removed from the top of the stack on a per-thread basis.\n\n```ruby\nrack_span = tracer.start_span(\"/GET users\")\ndb_span = tracer.start_span(\"GetUsers\") # rack_span became an implicit parent of db_span\ndb_span.finish\nrack_span.finish\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/iaintshine/ruby-spanmanager. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## Thanks\n\nThe development of the gem was heavily inspired by [Span manager implementation for Java](https://github.com/opentracing-contrib/java-spanmanager/).\n\nThank You for inspiration!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiaintshine%2Fruby-spanmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiaintshine%2Fruby-spanmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiaintshine%2Fruby-spanmanager/lists"}