Skip to content

Commit

Permalink
fix: Remove gemfile group, update README, remove explicit requires in…
Browse files Browse the repository at this point in the history
… targets
  • Loading branch information
joshwestbrook committed Jan 13, 2025
1 parent 201635d commit b7aa0f0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 75 deletions.
14 changes: 5 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in puma-plugin-telemetry.gemspec
gemspec

group :development, :test do
gem 'dogstatsd-ruby'
gem 'opentelemetry-exporter-otlp'
gem 'opentelemetry-exporter-otlp-metrics', github: 'joshwestbrook/opentelemetry-ruby', branch: 'gauge-encoding', glob: 'exporter/otlp-metrics/*.gemspec' # TODO: Once gauge exporting is released, we can switch back to released version: https://github.com/open-telemetry/opentelemetry-ruby/pull/1780
gem 'opentelemetry-metrics-api', github: 'open-telemetry/opentelemetry-ruby', glob: 'metrics_api/*.gemspec' # TODO: Once gauges are released, we can switch back to released version: https://github.com/open-telemetry/opentelemetry-ruby/commit/bb5159598850b42e9da54608a8af2fbe422193b7
gem 'opentelemetry-metrics-sdk', github: 'open-telemetry/opentelemetry-ruby', glob: 'metrics_sdk/*.gemspec' # TODO: Once gauges are released, we can switch back to released version: https://github.com/open-telemetry/opentelemetry-ruby/commit/bb5159598850b42e9da54608a8af2fbe422193b7
gem 'opentelemetry-sdk'
end

gem 'dogstatsd-ruby'
gem 'opentelemetry-exporter-otlp'
gem 'opentelemetry-exporter-otlp-metrics', '~> 0.3'
gem 'opentelemetry-metrics-sdk', '~> 0.5'
gem 'opentelemetry-sdk'
gem 'rack'
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.0'
Expand Down
54 changes: 17 additions & 37 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
GIT
remote: https://github.com/joshwestbrook/opentelemetry-ruby.git
revision: c32f2c0d490189f3bc39322c617cd137d6be8128
branch: gauge-encoding
glob: exporter/otlp-metrics/*.gemspec
specs:
opentelemetry-exporter-otlp-metrics (0.2.1)
google-protobuf (>= 3.18, < 5.0)
googleapis-common-protos-types (~> 1.3)
opentelemetry-api (~> 1.1)
opentelemetry-common (~> 0.20)
opentelemetry-metrics-api (~> 0.1)
opentelemetry-metrics-sdk (~> 0.2)
opentelemetry-sdk (~> 1.2)
opentelemetry-semantic_conventions

GIT
remote: https://github.com/open-telemetry/opentelemetry-ruby.git
revision: 035c32ad9791f6200733e087f2ee49e0a615879a
glob: metrics_api/*.gemspec
specs:
opentelemetry-metrics-api (0.1.1)
opentelemetry-api (~> 1.0)

GIT
remote: https://github.com/open-telemetry/opentelemetry-ruby.git
revision: 035c32ad9791f6200733e087f2ee49e0a615879a
glob: metrics_sdk/*.gemspec
specs:
opentelemetry-metrics-sdk (0.4.1)
opentelemetry-api (~> 1.1)
opentelemetry-metrics-api (~> 0.1.1)
opentelemetry-sdk (~> 1.2)

PATH
remote: .
specs:
Expand Down Expand Up @@ -68,6 +34,21 @@ GEM
opentelemetry-common (~> 0.20)
opentelemetry-sdk (~> 1.2)
opentelemetry-semantic_conventions
opentelemetry-exporter-otlp-metrics (0.3.0)
google-protobuf (>= 3.18, < 5.0)
googleapis-common-protos-types (~> 1.3)
opentelemetry-api (~> 1.1)
opentelemetry-common (~> 0.20)
opentelemetry-metrics-api (~> 0.2)
opentelemetry-metrics-sdk (~> 0.5)
opentelemetry-sdk (~> 1.2)
opentelemetry-semantic_conventions
opentelemetry-metrics-api (0.2.0)
opentelemetry-api (~> 1.0)
opentelemetry-metrics-sdk (0.5.0)
opentelemetry-api (~> 1.1)
opentelemetry-metrics-api (~> 0.2)
opentelemetry-sdk (~> 1.2)
opentelemetry-registry (0.3.1)
opentelemetry-api (~> 1.1)
opentelemetry-sdk (1.6.0)
Expand Down Expand Up @@ -130,9 +111,8 @@ PLATFORMS
DEPENDENCIES
dogstatsd-ruby
opentelemetry-exporter-otlp
opentelemetry-exporter-otlp-metrics!
opentelemetry-metrics-api!
opentelemetry-metrics-sdk!
opentelemetry-exporter-otlp-metrics (~> 0.3)
opentelemetry-metrics-sdk (~> 0.5)
opentelemetry-sdk
puma-plugin-telemetry!
rack
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ Output telemetry as JSON to `STDOUT`

Given gem provides built in target for Datadog StatsD client, that uses batch operation to publish metrics.

**NOTE** Be sure to have `dogstatsd` gem installed.

```ruby
config.add_target :dogstatsd, client: Datadog::Statsd.new
```
Expand All @@ -65,8 +63,6 @@ You can provide all the tags, namespaces, and other configuration options as alw

Given gem provides built in target for OpenTelemetry Metrics SDK, that uses batch operations to publish metrics.

**NOTE** Be sure to have `opentelemetry-metrics-sdk` gem installed.

```ruby
config.add_target :open_telemetry, meter_provider: OpenTelemetry.meter_provider
```
Expand Down
12 changes: 0 additions & 12 deletions lib/puma/plugin/telemetry/targets/datadog_statsd_target.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# frozen_string_literal: true

begin
require 'datadog/statsd'
rescue LoadError
# Gracefully handle the case when Datadog::Statsd is not installed
end

module Puma
class Plugin
module Telemetry
Expand All @@ -28,13 +22,7 @@ module Targets
# DatadogStatsdTarget.new(client: client)
#
class DatadogStatsdTarget
def self.available?
!defined?(Datadog::Statsd).nil?
end

def initialize(client:)
raise ArgumentError, ':dogstatsd target can only be used when `datadog/statsd` gem is installed' unless self.class.available?

@client = client
end

Expand Down
14 changes: 1 addition & 13 deletions lib/puma/plugin/telemetry/targets/open_telemetry_target.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# frozen_string_literal: true

begin
require 'opentelemetry-metrics-sdk'
rescue LoadError
# Gracefully handle the case when OpenTelemetry Metrics SDK is not installed
end

module Puma
class Plugin
module Telemetry
Expand All @@ -19,13 +13,7 @@ module Targets
# OpenTelemetryTarget.new(meter_provider: OpenTelemetry.meter_provider, prefix: 'puma')
#
class OpenTelemetryTarget
def self.available?
!defined?(OpenTelemetry::SDK::Metrics).nil?
end

def initialize(meter_provider:, prefix: nil, suffix: nil, attributes: {})
raise ArgumentError, ':open_telemetry target can only be used when the `opentelemetry-metrics-sdk` and `opentelemetry-exporter-otlp-metrics` gems are installed' unless self.class.available?

@meter_provider = meter_provider
@meter = meter_provider.meter('puma.telemetry')
@prefix = prefix
Expand All @@ -49,7 +37,7 @@ def call(telemetry)
instrument(metric).record(value, attributes: @attributes)
end

@meter_provider.try(:force_flush)
@meter_provider.force_flush
end

def instrument(metric)
Expand Down

0 comments on commit b7aa0f0

Please sign in to comment.