-
Notifications
You must be signed in to change notification settings - Fork 534
RUBY-3612 OpenTelemetry #2957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
comandeo
wants to merge
31
commits into
mongodb:master
Choose a base branch
from
comandeo:3612-otel
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
RUBY-3612 OpenTelemetry #2957
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
b78e04a
RUBY-3612 OpenTelemetry support
comandeo-mongo 87e8ac3
wip
comandeo-mongo d6f7509
With nesting
comandeo-mongo 10f5f6c
Disable cursor nesting
comandeo-mongo bf0dd5d
Disable cursor nesting
comandeo-mongo f059514
Spec runner
comandeo-mongo 5310ffb
wip
comandeo-mongo 51eb11a
more specs
comandeo-mongo 564a9b9
wip: fresh spec tests
comandeo 2cfeb87
wip: fresh spec tests
comandeo 1bd96fd
Pass transactions tests
comandeo 814bb1e
Skip unimplemented tests
comandeo c91ccac
Add documenting comments
comandeo 821495d
Refactor command tracer
comandeo d6571d9
Fix rubocop complaints
comandeo 23a3601
Fix lsid
comandeo 9108e72
Fix dependencies
comandeo eac5d9c
Merge branch 'master' into 3612-otel
comandeo 75e5370
Merge remote-tracking branch 'upstream/master' into 3612-otel
comandeo-mongo 8f8e137
wip
comandeo-mongo e047cf0
wip
comandeo-mongo f2f902e
wip
comandeo-mongo cf5395d
wip
comandeo-mongo 1ffd096
wip
comandeo-mongo e1e80c4
wip
comandeo-mongo 15c81ea
wip
comandeo-mongo 83daac8
wip
comandeo-mongo 5846980
wip
comandeo-mongo 6aae681
wip
comandeo-mongo eae217c
wip
comandeo-mongo 1230598
Fix code review remarks
comandeo-mongo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,3 +116,6 @@ RSpec/ExampleLength: | |
|
|
||
| RSpec/MessageSpies: | ||
| EnforcedStyle: receive | ||
|
|
||
| RSpec/NamedSubject: | ||
| Enabled: false | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,6 +112,7 @@ class Client | |
| :ssl_verify_hostname, | ||
| :ssl_verify_ocsp_endpoint, | ||
| :timeout_ms, | ||
| :tracing, | ||
| :truncate_logs, | ||
| :user, | ||
| :wait_queue_timeout, | ||
|
|
@@ -437,6 +438,20 @@ def hash | |
| # See Ruby's Zlib module for valid levels. | ||
| # @option options [ Hash ] :resolv_options For internal driver use only. | ||
| # Options to pass through to Resolv::DNS constructor for SRV lookups. | ||
| # @option options [ Hash ] :tracing OpenTelemetry tracing options. | ||
| # - :enabled => Boolean, whether to enable OpenTelemetry tracing. The default | ||
| # value is nil that means that the configuration will be taken from the | ||
| # OTEL_RUBY_INSTRUMENTATION_MONGODB_ENABLED environment variable. | ||
| # - :tracer => OpenTelemetry::Trace::Tracer, the tracer to use for | ||
| # tracing. Must be an implementation of OpenTelemetry::Trace::Tracer | ||
| # interface. | ||
| # - :query_text_max_length => Integer, the maximum length of the query text | ||
| # to be included in the span attributes. If the query text exceeds this | ||
| # length, it will be truncated. Value 0 means no query text | ||
| # will be included in the span attributes. The default value is nil that | ||
| # means that the configuration will be taken from the | ||
| # OTEL_RUBY_INSTRUMENTATION_MONGODB_QUERY_TEXT_MAX_LENGTH environment | ||
| # variable. | ||
| # @option options [ Hash ] :auto_encryption_options Auto-encryption related | ||
| # options. | ||
| # - :key_vault_client => Client | nil, a client connected to the MongoDB | ||
|
|
@@ -574,8 +589,11 @@ def initialize(addresses_or_uri, options = nil) | |
|
|
||
| @connect_lock = Mutex.new | ||
| @connect_lock.synchronize do | ||
| @cluster = Cluster.new(addresses, @monitoring, | ||
| cluster_options.merge(srv_uri: srv_uri)) | ||
| @cluster = Cluster.new( | ||
| addresses, | ||
| @monitoring, | ||
| cluster_options.merge(srv_uri: srv_uri) | ||
| ) | ||
| end | ||
|
|
||
| begin | ||
|
|
@@ -623,6 +641,7 @@ def cluster_options | |
| # applications should read these values from client, not from cluster | ||
| max_read_retries: options[:max_read_retries], | ||
| read_retry_interval: options[:read_retry_interval], | ||
| tracer: tracer, | ||
| ).tap do |options| | ||
| # If the client has a cluster already, forward srv_uri to the new | ||
| # cluster to maintain SRV monitoring. If the client is brand new, | ||
|
|
@@ -965,7 +984,10 @@ def list_databases(filter = {}, name_only = false, opts = {}) | |
| cmd[:nameOnly] = !!name_only | ||
| cmd[:filter] = filter unless filter.empty? | ||
| cmd[:authorizedDatabases] = true if opts[:authorized_databases] | ||
| use(Database::ADMIN).database.read_command(cmd, opts).first[Database::DATABASES] | ||
| use(Database::ADMIN) | ||
| .database | ||
| .read_command(cmd, opts.merge(op_name: 'listDatabases')) | ||
| .first[Database::DATABASES] | ||
| end | ||
|
|
||
| # Returns a list of Mongo::Database objects. | ||
|
|
@@ -1195,6 +1217,15 @@ def timeout_sec | |
| end | ||
| end | ||
|
|
||
| def tracer | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a public method, this should probably be documented. |
||
| tracing_opts = @options[:tracing] || {} | ||
| @tracer ||= Tracing.create_tracer( | ||
| enabled: tracing_opts[:enabled], | ||
| query_text_max_length: tracing_opts[:query_text_max_length], | ||
| otel_tracer: tracing_opts[:tracer], | ||
| ) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| # Attempts to parse the given list of addresses, using the provided options. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? It looks like
opentelemetry-sdkdeclaresopentelemtry-apias a dependency (here)