-
Notifications
You must be signed in to change notification settings - Fork 375
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
Fix GraphQL integration reconfiguration #3859
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,7 @@ module GraphQL | |
# which is required to use features such as API Catalog. | ||
# DEV-3.0: This tracer should be the default one in the next major version. | ||
module UnifiedTrace | ||
# @param analytics_enabled [Boolean] Deprecated | ||
# @param analytics_sample_rate [Float] Deprecated | ||
# @param service [String|nil] The service name to be set on the spans | ||
def initialize(*args, analytics_enabled: false, analytics_sample_rate: 1.0, service: nil, **kwargs) | ||
@analytics_enabled = analytics_enabled | ||
@analytics_sample_rate = analytics_sample_rate | ||
|
||
@service_name = service | ||
def initialize(*args, **kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚪ Code Quality ViolationOptional arguments should appear at the end (...read more)The rule "Optional arguments should appear at the end" is an important programming practice in Ruby. It is used to ensure that the optional parameters in a method definition are placed after the required parameters. This rule is important because when a method is called, Ruby fills in the arguments from left to right. If an optional argument is placed before a required argument and the method is called with fewer arguments, Ruby will assign the provided arguments to the optional parameters, leaving the required parameters without values and causing an error. Non-compliance with this rule often leads to unexpected behavior or bugs in the code, which can be quite challenging to debug. This is particularly true when the method is called with fewer arguments than defined. The errors caused by this can be hard to track down, as they may not occur at the place where the method is defined, but rather in some distant place where the method is called. To avoid this, always place optional parameters at the end of the list of parameters in your method definitions. This way, Ruby will fill in the required parameters first, and only then use any remaining arguments for the optional ones. If there are no remaining arguments, the optional parameters will be set to their default values. This keeps your code clear, predictable, and free of unnecessary bugs. |
||
@has_prepare_span = respond_to?(:prepare_span) | ||
super | ||
end | ||
|
@@ -139,7 +132,18 @@ def platform_resolve_type_key(type, *args, **kwargs) | |
private | ||
|
||
def trace(callable, trace_key, resource, **kwargs) | ||
Tracing.trace("graphql.#{trace_key}", resource: resource, service: @service_name, type: 'graphql') do |span| | ||
config = Datadog.configuration.tracing[:graphql] | ||
|
||
Tracing.trace( | ||
"graphql.#{trace_key}", | ||
type: 'graphql', | ||
resource: resource, | ||
service: config[:service_name] | ||
) do |span| | ||
if Contrib::Analytics.enabled?(config[:analytics_enabled]) | ||
Contrib::Analytics.set_sample_rate(span, config[:analytics_sample_rate]) | ||
end | ||
|
||
yield(span) if block_given? | ||
|
||
prepare_span(trace_key, kwargs, span) if @has_prepare_span | ||
|
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.
⚪ Code Quality Violation
Optional arguments should appear at the end (...read more)
The rule "Optional arguments should appear at the end" is an important programming practice in Ruby. It is used to ensure that the optional parameters in a method definition are placed after the required parameters. This rule is important because when a method is called, Ruby fills in the arguments from left to right. If an optional argument is placed before a required argument and the method is called with fewer arguments, Ruby will assign the provided arguments to the optional parameters, leaving the required parameters without values and causing an error.
Non-compliance with this rule often leads to unexpected behavior or bugs in the code, which can be quite challenging to debug. This is particularly true when the method is called with fewer arguments than defined. The errors caused by this can be hard to track down, as they may not occur at the place where the method is defined, but rather in some distant place where the method is called.
To avoid this, always place optional parameters at the end of the list of parameters in your method definitions. This way, Ruby will fill in the required parameters first, and only then use any remaining arguments for the optional ones. If there are no remaining arguments, the optional parameters will be set to their default values. This keeps your code clear, predictable, and free of unnecessary bugs.