Skip to content
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

Namespacing: Profiling #1849

Merged
merged 5 commits into from
Jan 27, 2022
Merged

Namespacing: Profiling #1849

merged 5 commits into from
Jan 27, 2022

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jan 22, 2022

This PR moves the profiler from ddtrace/profiling to datadog/profiling.

The executable ddtracerb was left with its original name, as it today represents an executable for the whole ddtrace gem, despite being used mostly for profiling.

The ddtrace_profiling_native_extension directory was not renamed: this is a more involved change than a simple renaming, and can be done later as this change will have no user impact.

Breaking changes

  • Changed: Profiler files moved from ddtrace/profiling to datadog/profiling.

To do after merge

@marcotc marcotc added breaking-change Involves a breaking change dev/refactor Involves refactoring existing components labels Jan 22, 2022
@marcotc marcotc added this to the 1.0.0 milestone Jan 22, 2022
@marcotc marcotc self-assigned this Jan 22, 2022
@marcotc marcotc requested a review from a team January 22, 2022 01:54
@marcotc marcotc changed the title Refactored: Datadog::Ext --> Datadog::Core::Ext Namespacing: Profiling Jan 22, 2022
@marcotc marcotc marked this pull request as draft January 22, 2022 01:55
@marcotc marcotc removed the request for review from a team January 22, 2022 01:55
@delner
Copy link
Contributor

delner commented Jan 23, 2022

My feeling is that:

  1. ddtracerb --> ddprofrb
  2. Datadog::Tasks --> Datadog::Profiling::Tasks
  3. require 'ddtrace/profiling/preload' --> require 'datadog/profiling/preload'

Thoughts @ivoanjo ?

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable. Some extra notes:

  1. I saw that ./ddtrace/ext/profiling.rb has not been removed, that looks like an oversight.
  2. Inside the ext folder, we also have the ddtrace_profiling_native_extension folder. We probably want to rename that as well; I'd be happy to send a follow-up PR with it (but we can do it at any time, since that name is not a public api)
  3. CI seems to be complaining about a lot of unrelated things; I guess this was branched off of an unstable branch.

Update onboarding documentation with path renaming: https://github.com/DataDog/documentation/blame/eee3812e9a1620455995422bd50b83779b21d537/content/en/tracing/profiler/enabling/ruby.md#L92. Should we keep an alias to ddtrace/profiling/preload for now?

Since we're doing this much cleanup for 1.0, I don't think it quite makes sense to hold on to ddtrace/profiling/preload as an alias.

BUT, I don't like that customers may run into this error and then have figure out on their own what's up:

[1] pry(main)> require 'ddtrace/profiling/preload'
LoadError: cannot load such file -- ddtrace/profiling/preload

So, rather than an alias, I would suggest leaving the following inside ddtrace/profiling/preload.rb:

raise LoadError, "this file has been moved. Please update your require to load `datadog/profiling/preload` instead of `ddtrace/profiling/preload`"

Re:

  1. ddtracerb --> ddprofrb

I would like to keep the current name, for consistency.

Once we decide to rename the gem, I think it makes sense to deprecate and rename this.

  1. Datadog::Tasks --> Datadog::Profiling::Tasks

No special feelings, either one seems reasonable.

lib/datadog/profiling/ext.rb Outdated Show resolved Hide resolved
lib/ddtrace/configuration/components.rb Outdated Show resolved Hide resolved
@delner
Copy link
Contributor

delner commented Jan 25, 2022

Overall I agree with all of @ivoanjo 's feedback.

Regarding ddtracerb:

I would like to keep the current name, for consistency.

This is fine. I think we're aligned.

@marcotc marcotc force-pushed the refactor/profiling-namespacing branch from e7b5269 to 6d00a41 Compare January 25, 2022 19:45
@marcotc marcotc changed the base branch from refactor/core-namespacing to 1.0 January 25, 2022 19:46
@marcotc marcotc force-pushed the refactor/profiling-namespacing branch from 6d00a41 to e979f1d Compare January 25, 2022 19:48
@codecov-commenter
Copy link

Codecov Report

Merging #1849 (e979f1d) into 1.0 (3c4f2dd) will increase coverage by 0.06%.
The diff coverage is 99.01%.

Impacted file tree graph

@@            Coverage Diff             @@
##              1.0    #1849      +/-   ##
==========================================
+ Coverage   98.16%   98.22%   +0.06%     
==========================================
  Files         957      959       +2     
  Lines       47030    47052      +22     
==========================================
+ Hits        46168    46219      +51     
+ Misses        862      833      -29     
Impacted Files Coverage Δ
lib/datadog/ci.rb 69.23% <0.00%> (ø)
lib/datadog/profiling/backtrace_location.rb 100.00% <ø> (ø)
lib/datadog/profiling/buffer.rb 100.00% <ø> (ø)
...ib/datadog/profiling/collectors/code_provenance.rb 100.00% <ø> (ø)
lib/datadog/profiling/event.rb 100.00% <ø> (ø)
lib/datadog/profiling/ext/forking.rb 100.00% <ø> (ø)
lib/datadog/profiling/flush.rb 100.00% <ø> (ø)
lib/datadog/profiling/native_extension.rb 83.33% <ø> (ø)
lib/datadog/profiling/pprof/message_set.rb 100.00% <ø> (ø)
lib/datadog/profiling/pprof/payload.rb 100.00% <ø> (ø)
... and 171 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b3bc033...e979f1d. Read the comment docs.

marcotc added a commit to DataDog/documentation that referenced this pull request Jan 25, 2022
This PR updates the profiler `require` path after changes to `ddtrace`'s namespacing scheme: DataDog/dd-trace-rb#1849

The only namespace change applicable here was that the profiler was moved from `ddtrace/profiling` to `datadog/profiling`.
@marcotc marcotc marked this pull request as ready for review January 25, 2022 20:06
@marcotc marcotc requested review from ivoanjo and delner January 25, 2022 20:06
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems straightforward to me. I think it's reasonable to merge as-is, if necessary.

Only inquiries I have are:

  1. Should Datadog::Profiler become Datadog::Profiling::Profiler? It's wordy but respects namespaces? How it is now would be fine, just exploring. Whatever we do here, Datadog::Tracer should match.
  2. Should we hide Datadog.profiler? Do users actually directly interact with Datadog.profiler? I think we should consider this if they don't.

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

  1. Should we hide Datadog.profiler? Do users actually directly interact with Datadog.profiler? I think we should consider this if they don't.

Yeap, sounds good.

As discussed via chat, I think something like

module Datadog
  module Profiling
    def self.start_if_enabled
      # Getting the profiler instance triggers start as a side-effect;
      # otherwise we get nil
      !!Datadog.send(:components).profiler
    end
  end
end

would be more than enough :)

lib/datadog/profiling/tasks/help.rb Outdated Show resolved Hide resolved
spec/ddtrace/profiling_spec.rb Show resolved Hide resolved
lib/datadog/profiling/profiler.rb Show resolved Hide resolved
@marcotc marcotc force-pushed the refactor/profiling-namespacing branch from 1fb25dd to 8f6708a Compare January 27, 2022 01:02
@marcotc
Copy link
Member Author

marcotc commented Jan 27, 2022

I've made the changes as suggested. I'm having a hard time with the integration apps failures, but getting there.

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally missed this weird bit, but with the fix it LGTM 👍

Comment on lines 91 to 95
def self.start_if_enabled
# Getting the profiler instance triggers start as a side-effect;
# otherwise we get nil
!!Datadog.send(:components).profiler
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAY FOR INTEGRATION TESTS :)

Oops I totally lied to you. 🤦‍♂️ See if you can spot what I totally forgot AND that the tests were catching because the webserver DID fork.

Suggested change
def self.start_if_enabled
# Getting the profiler instance triggers start as a side-effect;
# otherwise we get nil
!!Datadog.send(:components).profiler
end
def self.start_if_enabled
# If the profiler was not previously touched, getting the profiler instance triggers start as a side-effect
# otherwise we get nil
profiler = Datadog.send(:components).profiler
# ...but we still try to start it BECAUSE if the process forks, the profiler will exist but may
# not yet have been started in the fork
profiler.start if profiler
!!profiler
end

@marcotc marcotc force-pushed the refactor/profiling-namespacing branch from afc4868 to 01aa378 Compare January 27, 2022 20:20
@marcotc marcotc merged commit 0b01381 into 1.0 Jan 27, 2022
@marcotc marcotc deleted the refactor/profiling-namespacing branch January 27, 2022 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Involves a breaking change dev/refactor Involves refactoring existing components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants