Skip to content

Commit 0d5a73b

Browse files
committed
Add Rakefile, README, API docs, change namespace of Otel tracer/meter
1 parent 199e6de commit 0d5a73b

24 files changed

Lines changed: 337 additions & 111 deletions

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
.byebug_history
99
/.rakeTasks
1010
/.ruby-version
11-
/.yardoc
11+
/**/.yardoc
1212
/_yardoc/
1313
/cmake-build-*/
1414
/build*
1515
/coverage/
16-
/doc/
16+
/**/doc/
1717
/ext/cache/
18-
/pkg/
18+
/**/pkg/
1919
/test/reports/
2020
/tmp/
2121
/logs/

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins:
77
- rubocop-thread_safety
88

99
AllCops:
10-
TargetRubyVersion: 3.1
10+
TargetRubyVersion: 3.2
1111
NewCops: enable
1212
SuggestExtensions: false
1313
Exclude:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Please attach version information to the ticket/post. To obtain this information
1818

1919
## Installation
2020

21-
The library has been tested with MRI 3.1, 3.2, 3.3 and 3.4. Supported platforms are Linux and MacOS.
21+
The library has been tested with MRI 3.2, 3.3, 3.4 and 4.0. Supported platforms are Linux and MacOS.
2222

2323
Add this line to your application's Gemfile:
2424

bin/init-cluster

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
require "set"
1918
require "optparse"
2019

2120
class Object

bin/jenkins/repackage-extension.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
require "rubygems/installer"
99
require "rubygems/package"
1010

11-
def run(*args) # rubocop:disable Naming/PredicateMethod
12-
_, status = Open3.capture2e(*args)
11+
def run(*) # rubocop:disable Naming/PredicateMethod
12+
_, status = Open3.capture2e(*)
1313
status.success?
1414
end
1515

@@ -96,7 +96,7 @@ def repackage(gemspec)
9696
gemspec.platform.version = nil
9797
gemspec.original_platform = gemspec.platform
9898
end
99-
gemspec.required_ruby_version = "> 3.1"
99+
gemspec.required_ruby_version = "> 3.2"
100100

101101
# build new gem
102102
output_gem = nil
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
inherit_from: ../.rubocop.yml

couchbase-opentelemetry/.yardopts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--no-progress --output-dir doc/couchbase-ruby-client-master lib - README.md
2+
--tag couchbase.stability:"Stability"
3+
--transitive-tag couchbase.stability

couchbase-opentelemetry/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Couchbase Ruby Client OpenTelemetry Integration
2+
3+
## Installation
4+
5+
The library has been tested with MRI 3.2, 3.3, 3.4 and 4.0. Supported platforms are Linux and MacOS.
6+
7+
Add this line to your application's Gemfile:
8+
9+
```ruby
10+
gem "couchbase-opentelemetry", "0.1.0"
11+
```
12+
13+
And then execute:
14+
15+
$ bundle install
16+
17+
Or install it yourself as:
18+
19+
$ gem install couchbase-opentelemetry
20+
21+
## Usage
22+
23+
Here is an example on how to set up Tracing and Metrics with OpenTelemetr:
24+
25+
```ruby
26+
require "couchbase"
27+
require "couchbase/opentelemetry"
28+
29+
require "opentelemetry-sdk"
30+
require "opentelemetry-metrics-sdk"
31+
32+
# Initialize a tracer provider
33+
tracer_provider = OpenTelemetry::SDK::Trace::TracerProvider.new
34+
tracer_provider.add_span_processor(
35+
OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
36+
OpenTelemetry::Exporter::OTLP::Exporter.new(endpoint: "https://<hostname>:<port>/v1/traces")
37+
)
38+
)
39+
40+
# Initialize the Couchbase OpenTelemetry Request Tracer
41+
tracer = Couchbase::OpenTelemetry::RequestTracer.new(tracer_provider)
42+
43+
# Initialize a meter provider
44+
meter_provider = OpenTelemetry::SDK::Metrics::MeterProvider.new
45+
meter_provider.add_metric_reader(
46+
OpenTelemetry::SDk::Metrics::Export::PeriodicMetricReader.new(
47+
exporter: OpenTelemetry::Exporter::OTLP::Metrics::MetricsExporter.new(
48+
endpoint: "https://<hostname>:<port>/v1/metrics"
49+
)
50+
)
51+
)
52+
53+
# Initialize the Couchbase OpenTelemetry Meter
54+
meter = Couchbase::OpenTelemetry::Meter.new(meter_provider)
55+
56+
# Configure tracer and meter in cluster options
57+
options = Couchbase::Options::Cluster.new(
58+
authenticator: Couchbase::PasswordAuthenticator.new("Administrator", "password")
59+
tracer: tracer,
60+
meter: meter
61+
)
62+
63+
# Initialize cluster instance
64+
cluster = Cluster.connect("couchbase://127.0.0.1", options)
65+
```
66+
67+
## License
68+
69+
The gem is available as open source under the terms of the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0).
70+
71+
Copyright 2025-Present Couchbase, Inc.
72+
73+
Licensed under the Apache License, Version 2.0 (the "License");
74+
you may not use this file except in compliance with the License.
75+
You may obtain a copy of the License at
76+
77+
http://www.apache.org/licenses/LICENSE-2.0
78+
79+
Unless required by applicable law or agreed to in writing, software
80+
distributed under the License is distributed on an "AS IS" BASIS,
81+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
82+
See the License for the specific language governing permissions and
83+
limitations under the License.

couchbase-opentelemetry/Rakefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright 2026-Present Couchbase, Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
require "bundler/gem_tasks"
18+
require "rubocop/rake_task"
19+
20+
desc "Generate YARD documentation"
21+
task :doc do
22+
require "couchbase/opentelemetry/version"
23+
input_dir = File.join(__dir__, "lib")
24+
output_dir = File.join(__dir__, "doc", "couchbase-ruby-client-#{Couchbase::OpenTelemetry::VERSION}")
25+
rm_rf output_dir
26+
sh "bundle exec yard doc --no-progress --hide-api private --output-dir #{output_dir} #{input_dir} --main README.md"
27+
puts "#{File.realpath(output_dir)}/index.html"
28+
end
29+
30+
desc "An alias for documentation generation task"
31+
task :docs => :doc
32+
33+
desc "Display stats on undocumented things"
34+
task :undocumented => :doc do
35+
sh "yard stats --list-undoc --compact"
36+
end
37+
38+
RuboCop::RakeTask.new

couchbase-opentelemetry/couchbase-opentelemetry.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
2626
spec.description = "OpenTelemetry integration for the Couchbase Ruby Client"
2727
spec.homepage = "https://www.couchbase.com"
2828
spec.license = "Apache-2.0"
29-
spec.required_ruby_version = "> 3.1"
29+
spec.required_ruby_version = "> 3.2"
3030

3131
spec.metadata = {
3232
"homepage_uri" => "https://docs.couchbase.com/ruby-sdk/current/hello-world/start-using-sdk.html",

0 commit comments

Comments
 (0)