Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions instrumentation/mongo/Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# SPDX-License-Identifier: Apache-2.0

appraise 'mongo-latest' do
gem 'mongo'
appraise 'mongo-2.22' do
gem 'mongo', '~> 2.22.0'

# TODO: bson 5.1.0 isn't compatible with JRuby as of 2025/06/17
gem 'bson', '< 5.1.0' if defined?(JRUBY_VERSION)
Expand Down
11 changes: 11 additions & 0 deletions instrumentation/mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

The OpenTelemetry Mongo Ruby gem is a community maintained instrumentation for [Mongo][mongo-home].

> [!NOTE]
>
> **Development Frozen:**
>
> Mongo Ruby Driver 2.23.0+ includes native OpenTelemetry instrumentation. For the best experience and continued support, we recommend:
>
> - **Mongo Ruby Driver < 2.23.0**: Use `opentelemetry-instrumentation-mongo` gem
> - **Mongo Ruby Driver ≥ 2.23.0**: Use Mongo Ruby Driver's built-in OpenTelemetry support (remove `opentelemetry-instrumentation-mongo` gem)
>
> Community instrumentation is compatible with Mongo Ruby Driver versions up to 2.23.x. Development of this gem is frozen for newer Mongo Ruby Driver versions in favor of the native integration.

## How do I get started?

Install the gem using:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Mongo
# Instrumentation class that detects and installs the Mongo instrumentation
class Instrumentation < OpenTelemetry::Instrumentation::Base
MINIMUM_VERSION = Gem::Version.new('2.5.0')
MAX_VERSION = Gem::Version.new('2.22.0') # Mongo 2.23.0+ has native OpenTelemetry instrumentation

install do |_config|
require_dependencies
Expand All @@ -21,7 +22,14 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
end

compatible do
gem_version >= MINIMUM_VERSION
if gem_version < MINIMUM_VERSION
false
elsif gem_version > MAX_VERSION
OpenTelemetry.logger.info("Mongo #{gem_version} has native OpenTelemetry support. Skipping community instrumentation.")
false
else
true
end
end

option :peer_service, default: nil, validate: :string
Expand Down
Loading