Skip to content

GraphQL dataloaders not compatible with opentelemetry tracing pluginΒ #127

@stevecrozz

Description

@stevecrozz

Ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-darwin20]
GraphQL Gem Version: 2.0.13

Options enable_platform_field and enable_platform_authorized are not compatible with GraphQL gem's own fiber based dataloaders. Turning on these options while using the built-in dataloaders results in missing data and logs like:

ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.
ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.
ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.
ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.
ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.
ERROR -- : OpenTelemetry error: calls to detach should match corresponding calls to attach.

I'm assuming this has to do with the way these data loaders work. Somehow, this appeared to be working fine while using NewRelic tracing and it was able to capture traces with details on field hops and authorizations. Removing the dataloaders fixes this problem, but we need them to prevent N+1 query issues.

# field method
def team
  dataloader.with(Sources::Record, Team).load(object.team_id)
end

# authorized? method
def self.authorized?(object, context)
  can_access_team?(context.dataloader.with(Sources::Record, Team).load(object.team_id))
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingkeepEnsures stale-bot keeps this issue/PR open

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions