Skip to content

feat(contrib/99designs/gqlgen): Add WithShouldStartSpanFunc option#3711

Merged
dd-mergequeue[bot] merged 4 commits intoDataDog:mainfrom
tomoikey:impl/add_new_gqlgen_trace_span_config
Oct 7, 2025
Merged

feat(contrib/99designs/gqlgen): Add WithShouldStartSpanFunc option#3711
dd-mergequeue[bot] merged 4 commits intoDataDog:mainfrom
tomoikey:impl/add_new_gqlgen_trace_span_config

Conversation

@tomoikey
Copy link
Copy Markdown
Contributor

@tomoikey tomoikey commented Jul 1, 2025

What does this PR do?

This pull request introduces a new configuration option that allows users to flexibly filter the spans traced in a GraphQL environment using dd-trace-go and gqlgen.

Motivation

Due to its nature of fetching graphed data, GraphQL tends to generate a large number of spans. This issue is particularly prominent in environments that combine dd-trace-go with gqlgen.

While existing options like withoutTraceIntrospectionQuery and withoutTraceTrivialResolvedFields can suppress span generation under certain conditions, they lack flexibility. They are insufficient for handling cases where the span count inevitably increases due to schema design, such as with Relay's GraphQL Pagination. Currently, there is no mechanism to dynamically control span generation based on criteria like a field's path.

If left unaddressed, this issue can lead to serious consequences:

  • Performance Degradation: In environments like a Lambda extension running the Datadog Agent, the large volume of span data can lead to memory pressure and increased latency. Additionally, the high volume of spans being sent also significantly impacts performance.
  • Poor APM Experience: When viewing traces in the Datadog APM, an excessive number of spans can cause the UI to become extremely slow, significantly degrading the debugging and analysis experience.

To resolve these problems, I have added a new configuration option that allows users to suppress span generation based on custom rules. This enables flexible control, such as disabling spans for resolvers with a specific field path, tailored to the project's requirements. Corresponding tests to validate this new configuration option have also been created.

Thank you.

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • New code is free of linting errors. You can check this by running golangci-lint run locally.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.

Unsure? Have a question? Request a review!

@tomoikey tomoikey requested review from a team as code owners July 1, 2025 13:46
@tomoikey
Copy link
Copy Markdown
Contributor Author

tomoikey commented Sep 30, 2025

@darccio @rarguelloF (@DataDog/apm-go @Datadog/apm-idm-go)

It's been about three months since this was opened. Would it be possible to get a review?

@darccio
Copy link
Copy Markdown
Member

darccio commented Sep 30, 2025

@tomoikey We'll take a look. Sorry for the inconvenience.

@rarguelloF rarguelloF added the apm:ecosystem contrib/* related feature requests or bugs label Oct 3, 2025
Copy link
Copy Markdown
Contributor

@rarguelloF rarguelloF left a comment

Choose a reason for hiding this comment

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

@tomoikey LGTM! thanks for your contribution and apologies for the delay 🙇

@rarguelloF rarguelloF changed the title feat(contrib/gqlgen): Add a configuration option to flexibly suppress GraphQL span generation feat(contrib/gqlgen): Add a configuration option to flexibly suppress GraphQL span generation Oct 6, 2025
@rarguelloF rarguelloF changed the title feat(contrib/gqlgen): Add a configuration option to flexibly suppress GraphQL span generation feat( contrib/99designs/gqlgen): Add a configuration option to flexibly suppress GraphQL span generation Oct 6, 2025
@rarguelloF rarguelloF changed the title feat( contrib/99designs/gqlgen): Add a configuration option to flexibly suppress GraphQL span generation feat(contrib/99designs/gqlgen): Add a configuration option to flexibly suppress GraphQL span generation Oct 6, 2025
@rarguelloF rarguelloF changed the title feat(contrib/99designs/gqlgen): Add a configuration option to flexibly suppress GraphQL span generation feat(contrib/99designs/gqlgen): Add WithShouldStartSpanFunc option Oct 6, 2025
@rarguelloF
Copy link
Copy Markdown
Contributor

/merge

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex bot commented Oct 6, 2025

View all feedbacks in Devflow UI.

2025-10-06 09:02:40 UTC ℹ️ Start processing command /merge


2025-10-06 09:02:48 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-10-06 13:03:06 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

@tomoikey
Copy link
Copy Markdown
Contributor Author

tomoikey commented Oct 6, 2025

@darccio @rarguelloF

Thank you very much for your review!

It appears the pull request is not mergeable due to a failing CI check on the PR title.

As I am unfamiliar with the contribution guidelines for PR titles, would you be so kind as to advise on the necessary changes?

@darccio
Copy link
Copy Markdown
Member

darccio commented Oct 7, 2025

/merge

@dd-devflow-routing-codex
Copy link
Copy Markdown

dd-devflow-routing-codex bot commented Oct 7, 2025

View all feedbacks in Devflow UI.

2025-10-07 10:29:27 UTC ℹ️ Start processing command /merge


2025-10-07 10:29:34 UTC ℹ️ MergeQueue: waiting for PR to be ready

This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2025-10-07 10:32:33 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 18m (p90).


2025-10-07 10:45:19 UTC ℹ️ MergeQueue: This merge request was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apm:ecosystem contrib/* related feature requests or bugs mergequeue-status: done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants