-
Notifications
You must be signed in to change notification settings - Fork 3
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
NH-90184: add doc for add_tracer api call #174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reran one of the failed 3.1.0 tests and it still failed, could you take a look?
Regarding the README, i think add_tracer
belongs in the convenience category, so how about updating that section to talk both about our in_span
and our add_tracer
methods.
And replace the introduction part To instrument a custom function outside the default scope...
(which i think is a given, that if a customer bothers using the API, it's because they'd like to instrument something not covered by autoinsrumentation) with how add_tracer
should be used, e.g. does it:
- add a custom span to the specified instance or class method
- require the target method be already defined?
- take optional parameters like examples you gave in NH-90184: add feature - add_tracer on function #153
And we need the docstring in the source code so things show up in RubyDoc.
Updated.
It's caused by old activerecord gem inside the marginalia test case. It's removed so I just remove the gemfile as well (it's done in pg dbo pr). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting close! Made a few wording changes and one larger change/question on the instance vs class example.
Also, how about the docstring (or are you waiting for this README content to finish revising before adding)?
README.md
Outdated
# instrument class function create_session | ||
def create_session(user) | ||
end | ||
add_tracer :create_session, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer } | ||
|
||
# instrument instance function self.create_session | ||
def self.create_session(user) | ||
end | ||
|
||
class << self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# instrument class function create_session | |
def create_session(user) | |
end | |
add_tracer :create_session, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer } | |
# instrument instance function self.create_session | |
def self.create_session(user) | |
end | |
class << self | |
def create_session(user) | |
end | |
def self.create_session(user) | |
end | |
# instrument instance method create_session | |
add_tracer :create_session, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer } | |
# instrument class method create_session | |
class << self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think create_session
is the instance method, while self.create_session
is the class method. And is the include SolarWindsAPM::API::Tracer
on line 93 needed by the "instrument instance method" usage? It might be clearer if we just show the instrument instance vs class method as two separate snippets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean like putting them in separate code block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how about the docstring
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i mean two separate code blocks, because currently it's unclear where include SolarWindsAPM::API::Tracer
is needed for each scenario--the current example has it once at the start of class definition, then again via the class << self
construct. If we keep a single code block example it would be good to clarify why.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
Co-authored-by: Lin Lin <[email protected]>
Co-authored-by: Lin Lin <[email protected]>
Co-authored-by: Lin Lin <[email protected]>
Co-authored-by: Lin Lin <[email protected]>
Co-authored-by: Lin Lin <[email protected]>
README.md
Outdated
# instrument class function create_session | ||
def create_session(user) | ||
end | ||
add_tracer :create_session, 'custom_name', { attributes: { 'foo' => 'bar' }, kind: :consumer } | ||
|
||
# instrument instance function self.create_session | ||
def self.create_session(user) | ||
end | ||
|
||
class << self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, i mean two separate code blocks, because currently it's unclear where include SolarWindsAPM::API::Tracer
is needed for each scenario--the current example has it once at the start of class definition, then again via the class << self
construct. If we keep a single code block example it would be good to clarify why.
@@ -14,6 +14,37 @@ def self.included(base) | |||
end | |||
|
|||
module ClassMethods | |||
# Helper function to instrument custom function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be consistent and just use "method" instead of sometimes "function"? Please check for all instances in this docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use method
# | ||
# * +method_name+ - (String) A non-empty string that match the function name that need to be instrumented | ||
# * +span_name+ - (String, optional, default = method_name) A non-empty string that define the span name (default to method_name) | ||
# * +options+ - (Hash, optional, default = {}) A hash with desired attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and span kind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
span kind is part of options hash. Updated the docstring.
# * +span_name+ - (String, optional, default = method_name) A non-empty string that define the span name (default to method_name) | ||
# * +options+ - (Hash, optional, default = {}) A hash with desired attributes | ||
# | ||
# === Example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this example there is no include SolarWindsAPM::API::Tracer
, should there be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, updated.
Co-authored-by: Lin Lin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @xuan-cao-swi!
Description
Test (if applicable)