-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'logger-instrumentation' of github.com:kaylareopelle/ope…
…ntelemetry-ruby-contrib into logger-instrumentation
- Loading branch information
Showing
92 changed files
with
1,270 additions
and
119 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Ruby 3.0 has reached EoL 2024-04-23. OTel Ruby Contrib gems will no longer accept new features or bug fixes for Ruby 3.0 after 2025-01-15. Please upgrade to Ruby 3.1 or higher to continue receiving updates. | ||
|
||
Rails 6.1 has reached EoL 2024-10-01. OTel Ruby Contrib gems will no longer accept new features or bug fixes for Rails 6.1 after 2025-01-15. Please upgrade to Rails 7.0 or higher to continue receiving updates. |
This file contains 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 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
module OpenTelemetry | ||
module Helpers | ||
module MySQL | ||
VERSION = '0.1.1' | ||
VERSION = '0.1.2' | ||
end | ||
end | ||
end |
This file contains 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 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 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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
module OpenTelemetry | ||
module Helpers | ||
module SqlObfuscation | ||
VERSION = '0.2.0' | ||
VERSION = '0.2.1' | ||
end | ||
end | ||
end |
This file contains 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 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 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 was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
instrumentation/active_model_serializers/example/active_model_serializers.rb
This file was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
instrumentation/active_model_serializers/example/rails_app.rb
This file contains 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
require 'bundler/inline' | ||
|
||
gemfile(true) do | ||
source 'https://rubygems.org' | ||
|
||
gem 'rails' | ||
gem 'active_model_serializers' | ||
gem 'opentelemetry-api' | ||
gem 'opentelemetry-common' | ||
gem 'opentelemetry-instrumentation-active_model_serializers', path: '../' | ||
gem 'opentelemetry-sdk' | ||
gem 'opentelemetry-exporter-otlp' | ||
end | ||
|
||
ENV['OTEL_TRACES_EXPORTER'] ||= 'console' | ||
OpenTelemetry::SDK.configure do |c| | ||
c.service_name = 'active_model_serializers_example' | ||
c.use 'OpenTelemetry::Instrumentation::ActiveModelSerializers' | ||
end | ||
|
||
# no manual subscription trigger | ||
|
||
at_exit do | ||
OpenTelemetry.tracer_provider.shutdown | ||
end | ||
|
||
# TraceRequestApp is a minimal Rails application inspired by the Rails | ||
# bug report template for Action Controller. | ||
# The configuration is compatible with Rails 6.0 | ||
class TraceRequestApp < Rails::Application | ||
config.root = __dir__ | ||
config.hosts << 'example.org' | ||
credentials.secret_key_base = 'secret_key_base' | ||
|
||
config.eager_load = false | ||
|
||
config.logger = Logger.new($stdout) | ||
Rails.logger = config.logger | ||
end | ||
|
||
# Rails app initialization will pick up the instrumentation Railtie | ||
# and subscribe to Active Support notifications | ||
TraceRequestApp.initialize! | ||
|
||
ExampleAppTracer = OpenTelemetry.tracer_provider.tracer('example_app') | ||
|
||
class TestModel | ||
include ActiveModel::API | ||
include ActiveModel::Serialization | ||
|
||
attr_accessor :name | ||
|
||
def attributes | ||
{ 'name' => nil, | ||
'screaming_name' => nil } | ||
end | ||
|
||
def screaming_name | ||
ExampleAppTracer.in_span('screaming_name transform') do |span| | ||
name.upcase | ||
end | ||
end | ||
end | ||
|
||
model = TestModel.new(name: 'test object') | ||
serialized_model = ActiveModelSerializers::SerializableResource.new(model).serializable_hash | ||
|
||
puts "\n*** The serialized object: #{serialized_model}" |
57 changes: 57 additions & 0 deletions
57
instrumentation/active_model_serializers/example/standalone.rb
This file contains 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
require 'bundler/inline' | ||
|
||
gemfile(true) do | ||
source 'https://rubygems.org' | ||
|
||
gem 'active_model_serializers' | ||
gem 'opentelemetry-api' | ||
gem 'opentelemetry-common' | ||
gem 'opentelemetry-instrumentation-active_model_serializers', path: '../' | ||
gem 'opentelemetry-sdk' | ||
gem 'opentelemetry-exporter-otlp' | ||
end | ||
|
||
ENV['OTEL_TRACES_EXPORTER'] ||= 'console' | ||
OpenTelemetry::SDK.configure do |c| | ||
c.service_name = 'active_model_serializers_example' | ||
c.use_all | ||
end | ||
|
||
# without Rails and the Railtie automation, must manually trigger | ||
# instrumentation subscription after SDK is configured | ||
OpenTelemetry::Instrumentation::ActiveModelSerializers.subscribe | ||
|
||
at_exit do | ||
OpenTelemetry.tracer_provider.shutdown | ||
end | ||
|
||
ExampleAppTracer = OpenTelemetry.tracer_provider.tracer('example_app') | ||
|
||
class TestModel | ||
include ActiveModel::API | ||
include ActiveModel::Serialization | ||
|
||
attr_accessor :name | ||
|
||
def attributes | ||
{ 'name' => nil, | ||
'screaming_name' => nil } | ||
end | ||
|
||
def screaming_name | ||
ExampleAppTracer.in_span('screaming_name transform') do |span| | ||
name.upcase | ||
end | ||
end | ||
end | ||
|
||
model = TestModel.new(name: 'test object') | ||
serialized_model = ActiveModelSerializers::SerializableResource.new(model).serializable_hash | ||
|
||
puts "\n*** The serialized object: #{serialized_model}" |
48 changes: 0 additions & 48 deletions
48
...l_serializers/lib/opentelemetry/instrumentation/active_model_serializers/event_handler.rb
This file was deleted.
Oops, something went wrong.
This file contains 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
24 changes: 24 additions & 0 deletions
24
...e_model_serializers/lib/opentelemetry/instrumentation/active_model_serializers/railtie.rb
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
module OpenTelemetry | ||
module Instrumentation | ||
module ActiveModelSerializers # :nodoc: | ||
def self.subscribe | ||
Instrumentation.instance.subscribe | ||
end | ||
|
||
if defined?(::Rails::Railtie) | ||
# This Railtie sets up subscriptions to relevant ActiveModelSerializers notifications | ||
class Railtie < ::Rails::Railtie | ||
config.after_initialize do | ||
::OpenTelemetry::Instrumentation::ActiveModelSerializers.subscribe | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.