labkit-ruby

LabKit is minimalist library to provide functionality for Ruby services at GitLab.

Active Pure Nim score 66/100 · last commit 2026-11-21 · 7 stars · tests present · no docs generated

Summary

Latest Version Unknown
License Unknown
CI Status Failing
Stars 7
Forks 11
Open Issues 0
Last Commit 2026-11-21
Downloads 0
Last Indexed 2026-11-23 09:07

Installation

nimble install labkit-ruby
choosenim install labkit-ruby
git clone https://gitlab.com/gitlab-org/ruby/gems/labkit-ruby

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
labkit-ruby ✓ ✓ ✓ - - - - - - -

README

LabKit-Ruby 🔬🔬🔬🔬🔬

LabKit-Ruby is minimalist library to provide functionality for Ruby services at GitLab.

LabKit-Ruby is the Ruby companion for LabKit, a minimalist library to provide functionality for Go services at GitLab.

LabKit-Ruby and LabKit are intended to provide similar functionality, but use the semantics of their respective languages, so are not intended to provide identical APIS.

Documentation

API Documentation is available at the Rubydoc site.

Changelog

The changelog is available via tagged release notes

Functionality

LabKit-Ruby provides functionality in a number of areas:

  1. Labkit::Context used for providing context information to log messages.
  2. Labkit::Correlation for accessing the correlation id. (Generated and propagated by Labkit::Context)
  3. Labkit::UserExperienceSli for tracking User Experience SLIs. More on the README.
  4. Labkit::ApplicationSli for tracking Application SLIs (Apdex and error-rate). More on the README.
  5. Labkit::FIPS for checking for FIPS mode and using FIPS-compliant algorithms.
  6. Labkit::Logging for sanitizing log messages.
  7. Labkit::Metrics for metrics. More on the README.
  8. Labkit::RateLimit for rules-based, Redis-backed rate limiting. More on the README.
  9. Labkit::RSpec for RSpec matchers to test Labkit functionality (requires selective loading). More on the README.
  10. Labkit::Tracing for handling and propagating distributed traces.

Developing

Anyone can contribute!

$ git clone git@gitlab.com:gitlab-org/labkit-ruby.git
$ cd labkit-ruby
$ bundle install

$ # Autoformat code and auto-correct linters
$ bundle exec rake fix

$ # Run tests, linters
$ bundle exec rake verify

Some specs require a real Redis instance. When you run the suite locally, it will automatically start one via docker compose up -d redis (see docker-compose.yml) and tear it down again when the test process exits. Redis is exposed on localhost:6390 so it does not collide with a local GDK/Caproni Redis on the default port.

To opt out of autostart (e.g. you've started Redis some other way), set LABKIT_TEST_REDIS_URL to a reachable instance, or LABKIT_TEST_REDIS_NO_AUTOSTART=1 to fail loudly instead of spawning.

The conformance-spec CI job gates merge requests on the labkit-spec conformance harness. It triggers a downstream pipeline in labkit-spec that checks out the MR's commit and runs the Ruby conformance suite against it, with the gitlab-labkit gem installed from that checkout instead of the released version. A change to logging, lifecycle, or rate limiting is therefore checked against the cross-SDK scenarios before it merges, and the downstream result is mirrored here, so a red run blocks the merge. To run it locally, clone labkit-spec and replace the gitlab-labkit line in conformance/servers/ruby/Gemfile with

gem "gitlab-labkit", path: "/path/to/labkit-ruby"

then run mise run conformance:ruby from the spec checkout (the rate-limit aspect needs Docker or CONFORMANCE_REDIS_ADDR).

If your change also needs a labkit-spec change (a new scenario, or an update to its Ruby server), open and merge that MR first. The trigger always runs labkit-spec main, so the spec side has to land before the gate here can pass.

Please also review the development section of the LabKit (go) README for details of the LabKit architectural philosophy.

Releasing a new version

Releases are cut automatically by semantic-release when changes are merged to master or to an N-N-stable branch. The Conventional Commits type of each commit decides the version bump (see AGENTS.md), and the release notes are generated from those commit messages.

The new version will automatically be published to gitlab-labkit on rubygems when the pipeline for the tag completes. It might take a few minutes before the update is available.

A gem called labkit-ruby is also published to RubyGems.org as a placeholder. The same bot that pushes this gem has access.