-
Notifications
You must be signed in to change notification settings - Fork 401
add rails.application to process tags when available #5468
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
7ebfb9e
Add rails.application to process tags when available
wantsui b549b5a
Merge branch 'master' into add-application-name-rails-process-tags
wantsui 3dbbb52
Refactor app_name from utils because sometimes the namespace can be n…
wantsui b30dfad
add a failsafe because some of the CI spins up apps that don't have a…
wantsui 4b52af0
Add a recompute of process tags after the rails app has initialized a…
wantsui 1b62ed6
Update lib/datadog/core/contrib/rails/utils.rb
wantsui 56d4346
Refactor a module syntax for the utils spec
wantsui 0ae28c5
Remove the let for the rails major version
wantsui c8049a0
Add debug log
wantsui 7919c9f
refactor out rails after_initialize logic in one centralized place so…
wantsui 8509732
Swap to if defined because of uninitialized constant Rails
wantsui b2a67b0
Fix undefined method after_initialize' for Datadog::Core::Contrib::Ra…
wantsui eefd266
refactor out the public_send
wantsui a474904
Update comment to be more general
wantsui e9cf9cb
Remove unneeded import
wantsui ba91576
Add a future todo for using a real rails app class
wantsui 3574f43
Merge branch 'master' into add-application-name-rails-process-tags
wantsui f2a8646
Merge branch 'master' into add-application-name-rails-process-tags
wantsui 7f7be92
Update lib/datadog/core/contrib/rails/utils.rb
wantsui df14399
Update spec/datadog/core/contrib/rails/utils_spec.rb
wantsui c173fde
Merge branch 'master' into add-application-name-rails-process-tags
wantsui a2c819d
Fix tests from suggestion
wantsui 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative 'utils' | ||
| require_relative '../../environment/process' | ||
|
|
||
| module Datadog | ||
| module Core | ||
| module Contrib | ||
| module Rails | ||
| # Railtie for core Rails setup that benefits all Datadog products. | ||
| class Railtie < ::Rails::Railtie | ||
| def self.after_initialize | ||
| return unless Datadog.configuration.experimental_propagate_process_tags_enabled | ||
|
|
||
| Datadog::Core::Environment::Process.rails_application_name = | ||
| Datadog::Core::Contrib::Rails::Utils.app_name | ||
| end | ||
|
|
||
| # Registered after the method definition so the method exists if on_load fires immediately | ||
| # (which happens when the Railtie is loaded into an already-initialized Rails app). | ||
| ::ActiveSupport.on_load(:after_initialize) do | ||
| Datadog::Core::Contrib::Rails::Railtie.after_initialize | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
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
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 |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module Datadog | ||
| module Core | ||
| module Contrib | ||
| module Rails | ||
| class Railtie < ::Rails::Railtie | ||
| def self.after_initialize: () -> void | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'spec_helper' | ||
| require 'active_support/lazy_load_hooks' | ||
|
|
||
| # Provide a minimal stub base class for testing without loading the full Rails framework. | ||
| # utils_spec.rb uses the same pattern (stub_const '::Rails') for the same reason. | ||
| module Rails | ||
| class Railtie; end unless defined?(Railtie) | ||
| end | ||
|
|
||
| require 'lib/datadog/core/contrib/rails/railtie' | ||
|
|
||
| RSpec.describe Datadog::Core::Contrib::Rails::Railtie do | ||
| describe '.after_initialize' do | ||
| subject(:after_initialize) { described_class.after_initialize } | ||
|
|
||
| before do | ||
| allow(Datadog::Core::Contrib::Rails::Utils).to receive(:app_name).and_return('test_app') | ||
| end | ||
|
|
||
| after do | ||
| Datadog::Core::Environment::Process.rails_application_name = nil | ||
| end | ||
|
|
||
| context 'when experimental_propagate_process_tags_enabled is true' do | ||
| before do | ||
| allow(Datadog.configuration).to receive(:experimental_propagate_process_tags_enabled).and_return(true) | ||
| end | ||
|
|
||
| it 'includes the rails application name in process tags' do | ||
| after_initialize | ||
| expect(Datadog::Core::Environment::Process.tags).to include('rails.application:test_app') | ||
| end | ||
| end | ||
|
|
||
| context 'when experimental_propagate_process_tags_enabled is false' do | ||
| before do | ||
| allow(Datadog.configuration).to receive(:experimental_propagate_process_tags_enabled).and_return(false) | ||
| end | ||
|
|
||
| it 'does not include the rails application name in process tags' do | ||
| after_initialize | ||
| expect(Datadog::Core::Environment::Process.tags).not_to include(a_string_starting_with('rails.application:')) | ||
| end | ||
| end | ||
| end | ||
| end |
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.
Uh oh!
There was an error while loading. Please reload this page.