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

Remove extraneous span.setStatus() following span.end() #2697

Merged
merged 4 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/dull-gorillas-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@apollo/gateway": patch
---

Remove extraneous call to `span.setStatus()` on a span which has already ended.

In cases where a subgraph responded with an error, we would sometimes try to set
the status of a span which had already ended. This resulted in a warning log to
the console (but no effect otherwise). This warning should no longer happen.

7 changes: 2 additions & 5 deletions gateway-js/src/executeQueryPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function makeIntrospectionQueryDocument(
const usedVariables = collectUsedVariables(introspectionSelection);
const usedVariableDefinitions = variableDefinitions?.filter((def) => usedVariables.has(def.variable.name.value));
assert(
usedVariables.size === (usedVariableDefinitions?.length ?? 0),
usedVariables.size === (usedVariableDefinitions?.length ?? 0),
() => `Should have found all used variables ${[...usedVariables]} in definitions ${JSON.stringify(variableDefinitions)}`,
);
return {
Expand Down Expand Up @@ -273,9 +273,6 @@ export async function executeQueryPlan(
finally {
span.end()
}
if(errors.length > 0) {
span.setStatus({ code:SpanStatusCode.ERROR });
}
return errors.length === 0 ? { data } : { errors, data };
});

Expand Down Expand Up @@ -381,7 +378,7 @@ async function executeNode(
return new Trace.QueryPlanNode({ fetch: traceNode });
}
case 'Condition': {
const condition = evaluateCondition(node, context.operation.variableDefinitions, context.requestContext.request.variables);
const condition = evaluateCondition(node, context.operation.variableDefinitions, context.requestContext.request.variables);
const pickedBranch = condition ? node.ifClause : node.elseClause;
let branchTraceNode: Trace.QueryPlanNode | undefined = undefined;
if (pickedBranch) {
Expand Down