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

GraphQL: Report multiple query errors #4177

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Nov 30, 2024

Change log entry
GraphQL query errors are now reported as Span Events. This includes support for multiple errors, if present.

How to test the change?
All changes are tested.

@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Nov 30, 2024
@datadog-datadog-prod-us1
Copy link
Contributor

datadog-datadog-prod-us1 bot commented Nov 30, 2024

Datadog Report

Branch report: graphql-error-event
Commit report: af565a0
Test service: dd-trace-rb

❌ 5 Failed (0 Known Flaky), 20330 Passed, 1419 Skipped, 5m 47.5s Total Time

❌ Failed Tests (5)

  • Datadog::OpenTelemetry with Datadog TraceProvider OpenTelemetry.propagation #extract with Datadog headers sucessive calls to #with_current leave tracer in a consistent state - rspec

  • Datadog::Tracing::Contrib::Rails::Runner from an inline code snippet creates span for an inline code snippet - rspec - Details

    Expand for error
     expected block to output "OK" to stdout, but output "trace:rails.runner.inline,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
     Diff:
     @@ -1 +1,2 @@
     +trace:rails.runner.inline,caller:["/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/command.rb:28:in \`run'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'"]
      OK
     
     Failure/Error: expect { run }.to output('OK').to_stdout
     
       expected block to output "OK" to stdout, but output "trace:rails.runner.inline,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
       Diff:
     ...
    
  • Datadog::Tracing::Contrib::Rails::Runner from an inline code snippet when a current span isn't detected doesn't error when a span can't be identified to set the source tag on - rspec - Details

    Expand for error
     expected block to output "OK" to stdout, but output "trace:rails.runner.inline,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
     Diff:
     @@ -1 +1,2 @@
     +trace:rails.runner.inline,caller:["/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/command.rb:28:in \`run'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'"]
      OK
     
     Failure/Error: expect { run }.to output('OK').to_stdout
     
       expected block to output "OK" to stdout, but output "trace:rails.runner.inline,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
       Diff:
     ...
    
  • Datadog::Tracing::Contrib::Rails::Runner from STDIN creates span for an STDIN runner - rspec - Details

    Expand for error
     expected block to output "OK" to stdout, but output "trace:rails.runner.stdin,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\"... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
     Diff:
     @@ -1 +1,2 @@
     +trace:rails.runner.stdin,caller:["/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/command.rb:28:in \`run'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'"]
      OK
     
     Failure/Error: expect { run }.to output('OK').to_stdout
     
       expected block to output "OK" to stdout, but output "trace:rails.runner.stdin,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\"... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
       Diff:
     ...
    
  • Datadog::Tracing::Contrib::Rails::Runner with a file path creates span for a file runner - rspec - Details

    Expand for error
     expected block to output "OK" to stdout, but output "trace:rails.runner.file,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\",... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
     Diff:
     @@ -1 +1,2 @@
     +trace:rails.runner.file,caller:["/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/command.rb:28:in \`run'", "/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'"]
      OK
     
     Failure/Error: expect { run }.to output('OK').to_stdout
     
       expected block to output "OK" to stdout, but output "trace:rails.runner.file,caller:[\"/app/lib/datadog/tracing/contrib/rails/runner.rb:37:in \`runner'\",... \`run'\", \"/usr/local/bundle/gems/thor-1.3.1/lib/thor/invocation.rb:127:in \`invoke_command'\"]\nOK"
       Diff:
     ...
    

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 97.56098% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.75%. Comparing base (28675b6) to head (d917334).

Files with missing lines Patch % Lines
...b/datadog/tracing/contrib/graphql/unified_trace.rb 98.14% 1 Missing ⚠️
...cing/contrib/graphql/support/application_schema.rb 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4177      +/-   ##
==========================================
- Coverage   97.76%   97.75%   -0.01%     
==========================================
  Files        1351     1351              
  Lines       81733    81789      +56     
  Branches     4147     4149       +2     
==========================================
+ Hits        79904    79955      +51     
- Misses       1829     1834       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pr-commenter
Copy link

pr-commenter bot commented Nov 30, 2024

Benchmarks

Benchmark execution time: 2025-01-16 23:39:48

Comparing candidate commit af565a0 in PR branch graphql-error-event with baseline commit 3d54001 in branch master.

Found 0 performance improvements and 9 performance regressions! Performance is the same for 23 metrics, 1 unstable metrics.

scenario:library - Gem loading

  • 🟥 throughput [-1.369op/s; -1.361op/s] or [-50.384%; -50.088%]

scenario:profiler - Major GC runs (profiling disabled)

  • 🟥 throughput [-31.493op/s; -31.037op/s] or [-27.398%; -27.001%]

scenario:profiler - Major GC runs (profiling enabled)

  • 🟥 throughput [-28.171op/s; -27.911op/s] or [-26.076%; -25.835%]

scenario:tracing - 1 span trace - no network

  • 🟥 throughput [-3450.037op/s; -3085.984op/s] or [-30.351%; -27.149%]

scenario:tracing - 1 span trace - no writer

  • 🟥 throughput [-3629.997op/s; -3585.927op/s] or [-27.765%; -27.428%]

scenario:tracing - 10 span trace - no network

  • 🟥 throughput [-1681.713op/s; -1535.535op/s] or [-67.654%; -61.773%]

scenario:tracing - 10 span trace - no writer

  • 🟥 throughput [-1833.875op/s; -1828.815op/s] or [-63.842%; -63.666%]

scenario:tracing - 100 span trace - no network

  • 🟥 throughput [-272.744op/s; -246.348op/s] or [-96.071%; -86.773%]

scenario:tracing - 100 span trace - no writer

  • 🟥 throughput [-325.409op/s; -324.639op/s] or [-93.670%; -93.448%]

@@ -89,9 +125,10 @@ def execute_field_lazy(*args, **kwargs)
execute_field_span(proc { super }, 'resolve_lazy', **kwargs)
end

def authorized_span(callable, span_key, **kwargs)
def authorized_span(callable, span_key, *args, **kwargs)
Copy link
Contributor

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.

View in Datadog  Leave us feedback  Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants