diff --git a/apps/collector-proxy/src/workers/foreign-traces.ts b/apps/collector-proxy/src/workers/foreign-traces.ts index 4ad0972b..bd462ef5 100644 --- a/apps/collector-proxy/src/workers/foreign-traces.ts +++ b/apps/collector-proxy/src/workers/foreign-traces.ts @@ -65,9 +65,6 @@ export function foreignTracesWorker({ client }: { client: DebuggerClient }) { errorMessage: span.errorMessage, errorStack: span.errorStack, graphqlDocument: span.graphqlDocument, - graphqlVariables: span.graphqlVariables, - graphqlResult: span.graphqlResult, - graphqlContext: span.graphqlContext, isForeign: span.isForeign, attributes: JSON.stringify(span.attributes), }, diff --git a/apps/collector-proxy/src/workers/post-traces.ts b/apps/collector-proxy/src/workers/post-traces.ts index 26189dc4..19243a31 100644 --- a/apps/collector-proxy/src/workers/post-traces.ts +++ b/apps/collector-proxy/src/workers/post-traces.ts @@ -126,9 +126,6 @@ export function postTracesWorker({ errorMessage: span.errorMessage, errorStack: span.errorStack, graphqlDocument: span.graphqlDocument, - graphqlVariables: span.graphqlVariables, - graphqlResult: span.graphqlResult, - graphqlContext: span.graphqlContext, graphqlSchemaHash: span.graphqlSchemaHash, graphqlOperationName: span.graphqlOperationName, graphqlOperationType: span.graphqlOperationType, diff --git a/apps/ui/src/demo/create-post-traces.ts b/apps/ui/src/demo/create-post-traces.ts index 854b03dd..417b7255 100644 --- a/apps/ui/src/demo/create-post-traces.ts +++ b/apps/ui/src/demo/create-post-traces.ts @@ -55,21 +55,6 @@ createPost.spans.push({ [AttributeNames.DOCUMENT]: postsdQueryStr, }), graphqlDocument: postsdQueryStr, - graphqlContext: JSON.stringify({ - "X-Forwarded-For": "http://localhost:3000", - "secret-token-123": "Bearer token", - }), - graphqlVariables: JSON.stringify({ - title: "First post", - content: "This is the first post", - }), - graphqlResult: JSON.stringify({ - data: { - id: "1", - title: "First post", - content: "This is the first post", - }, - }), }); // Child spans simulating ORM and SQL queries, and post attributes processing diff --git a/apps/ui/src/demo/fail-create-post-traces.ts b/apps/ui/src/demo/fail-create-post-traces.ts index 55ebf46f..9b8d8239 100644 --- a/apps/ui/src/demo/fail-create-post-traces.ts +++ b/apps/ui/src/demo/fail-create-post-traces.ts @@ -53,13 +53,6 @@ failCreatePost.spans.push({ [AttributeNames.DOCUMENT]: postsdQueryStr, }), graphqlDocument: postsdQueryStr, - graphqlContext: JSON.stringify({ - "X-Forwarded-For": "http://localhost:3000", - }), - graphqlVariables: JSON.stringify({ - title: "First post", - content: "This is the first post", - }), errorMessage: "Token Missing", errorStack: "Error: Token Missing\n at login (index.js:1:1)", }); diff --git a/apps/ui/src/demo/login-traces.ts b/apps/ui/src/demo/login-traces.ts index de44ea3e..000da65d 100644 --- a/apps/ui/src/demo/login-traces.ts +++ b/apps/ui/src/demo/login-traces.ts @@ -49,19 +49,6 @@ successfullLogin.spans.push({ [AttributeNames.DOCUMENT]: loginMutation, }), graphqlDocument: loginMutation, - graphqlVariables: JSON.stringify({ - username: "test", - password: "test", - }), - graphqlContext: JSON.stringify({ - "X-Forwarded-For": "http://localhost:3000", - "secret-token-123": "Bearer token", - }), - graphqlResult: JSON.stringify({ - data: { - login: "Bearer token", - }, - }), }); // ORM CALL and SQL Query for successful login @@ -168,14 +155,6 @@ failedLogin.spans.push({ graphqlDocument: loginMutation, errorMessage: "Invalid credentials", errorStack: "Error: Invalid credentials\n at login (index.js:1:1)", - graphqlVariables: JSON.stringify({ - username: "test", - password: "test", - }), - graphqlContext: JSON.stringify({ - "X-Forwarded-For": "http://localhost:3000", - "secret-token-123": "Bearer token", - }), }); // ORM CALL and SQL Query for failed login diff --git a/apps/ui/src/demo/me-traces.ts b/apps/ui/src/demo/me-traces.ts index c8e146ab..1aba1351 100644 --- a/apps/ui/src/demo/me-traces.ts +++ b/apps/ui/src/demo/me-traces.ts @@ -57,30 +57,6 @@ meQueryTrace.spans.push({ [AttributeNames.DOCUMENT]: meQuery, }), graphqlDocument: meQuery, - graphqlContext: JSON.stringify({ - "X-Forwarded-For": "http://localhost:3000", - "secret-token-123": "Bearer token", - }), - graphqlResult: JSON.stringify({ - data: { - me: { - id: "user_id", - username: "test", - posts: [ - { - id: "1", - title: "First post", - content: "This is the first post", - }, - { - id: "2", - title: "Second post", - content: "This is the second post", - }, - ], - }, - }, - }), }); meQueryTrace.spans.push({ diff --git a/apps/ui/src/demo/posts-traces.ts b/apps/ui/src/demo/posts-traces.ts index 61d05c28..3775fb04 100644 --- a/apps/ui/src/demo/posts-traces.ts +++ b/apps/ui/src/demo/posts-traces.ts @@ -55,26 +55,6 @@ postQuery.spans.push({ [AttributeNames.DOCUMENT]: postsdQueryStr, }), graphqlDocument: postsdQueryStr, - graphqlContext: JSON.stringify({ - "X-Forwarded-For": "http://localhost:3000", - "secret-token-123": "Bearer token", - }), - graphqlResult: JSON.stringify({ - data: { - posts: [ - { - id: "1", - title: "First post", - content: "This is the first post", - }, - { - id: "2", - title: "Second post", - content: "This is the second post", - }, - ], - }, - }), }); // Child spans simulating ORM and SQL queries, and post attributes processing diff --git a/apps/ui/src/utils/__tests__/trace-name-includes.spec.ts b/apps/ui/src/utils/__tests__/trace-name-includes.spec.ts index d594a962..c85a5f95 100644 --- a/apps/ui/src/utils/__tests__/trace-name-includes.spec.ts +++ b/apps/ui/src/utils/__tests__/trace-name-includes.spec.ts @@ -25,11 +25,6 @@ const trace: Trace = { durationNano: "19395200", graphqlDocument: "query ($where: ListTraceGroupsWhere, $includeSpans: Boolean = false, $includeRootSpan: Boolean = false) {\n listTraceGroups(where: $where) {\n traces {\n id\n traceId\n firstSpanErrorMessage\n firstSpanErrorStack\n spans @include(if: $includeSpans) {\n ...SpanObject\n }\n rootSpan @include(if: $includeRootSpan) {\n ...SpanObject\n }\n }\n }\n}", - graphqlVariables: - '{"args":{"where":{"rootSpanName":null,"schemaId":"9c47e081-44ec-4256-8a40-79c162df3a57"}}}', - graphqlResult: null, - graphqlContext: - '{"context":{"waitUntil":"Function","loaders":{"rootSpanLoader":{"_batchLoadFn":"Function","_maxBatchSize":null,"_batchScheduleFn":"Function","_cacheKeyFn":"Function","_cacheMap":{},"_batch":null,"name":null},"spanLoader":{"_batchLoadFn":"Function","_maxBatchSize":null,"_batchScheduleFn":"Function","_cacheKeyFn":"Function","_cacheMap":{},"_batch":null,"name":null}}}}', graphqlOperationName: null, graphqlOperationType: "query", }, diff --git a/apps/ui/src/utils/mappers.ts b/apps/ui/src/utils/mappers.ts index d26706aa..8810237c 100644 --- a/apps/ui/src/utils/mappers.ts +++ b/apps/ui/src/utils/mappers.ts @@ -1,17 +1,10 @@ export const metaMapper: Record = { - variables: "JSON variables attached to the Query.", - result: "The result of the Query.", - context: "Safe JSON of the GraphQL context obj.", errors: "Errors of each resolver", }; -export const jsonMapper: Record = { - variables: "graphqlVariables", - result: "graphqlResult", - context: "graphqlContext", -}; +export const jsonMapper: Record = {}; -export const variablesHeader = ["Variables", "Result", "Context", "Errors"]; +export const variablesHeader = ["Errors"]; export const kindKeywordMapper: Record = { ObjectTypeDefinition: "type", diff --git a/e2e/tests/trace.test.ts b/e2e/tests/trace.test.ts index 82044f17..ede4b41a 100644 --- a/e2e/tests/trace.test.ts +++ b/e2e/tests/trace.test.ts @@ -130,9 +130,6 @@ describe("trace", () => { expect(print(parse(editorValues.query))).toEqual( rootSpan?.graphqlDocument, ); - expect(JSON.parse(editorValues.variables as string)).toMatchObject( - JSON.parse(rootSpan?.graphqlVariables as string), - ); if (variant.shouldError) { const sanitizedUIError = JSON.parse( @@ -147,10 +144,6 @@ describe("trace", () => { }), ), ); - } else { - expect(JSON.parse(editorValues.result as string)).toMatchObject( - JSON.parse(rootSpan?.graphqlResult as string), - ); } }); } diff --git a/packages/adapters/proxy/tests/entities/Span/create-one.test.ts b/packages/adapters/proxy/tests/entities/Span/create-one.test.ts index 90fb0f27..5ccb1ca4 100644 --- a/packages/adapters/proxy/tests/entities/Span/create-one.test.ts +++ b/packages/adapters/proxy/tests/entities/Span/create-one.test.ts @@ -21,9 +21,6 @@ describe("Span", () => { }); const graphqlDocument = faker.lorem.words(); - const graphqlVariables = faker.lorem.words(); - const graphqlResult = faker.lorem.words(); - const graphqlContext = faker.lorem.words(); const graphqlOperationName = faker.lorem.words(); const graphqlOperationType = faker.lorem.words(); @@ -42,9 +39,6 @@ describe("Span", () => { traceGroupId: createdTrace?.trace?.id, isGraphQLRootSpan: true, graphqlDocument, - graphqlVariables, - graphqlResult, - graphqlContext, graphqlOperationName, graphqlOperationType, isForeign: false, diff --git a/packages/adapters/proxy/tests/utils.ts b/packages/adapters/proxy/tests/utils.ts index afeaad1b..dc2efbca 100644 --- a/packages/adapters/proxy/tests/utils.ts +++ b/packages/adapters/proxy/tests/utils.ts @@ -49,9 +49,6 @@ export async function createFakeSpan({ const errorMessage = shouldError ? faker.lorem.words() : undefined; const errorStack = shouldError ? faker.lorem.words() : undefined; const graphqlDocument = faker.lorem.words(); - const graphqlVariables = faker.lorem.words(); - const graphqlResult = faker.lorem.words(); - const graphqlContext = faker.lorem.words(); const graphqlSchemaHash = faker.lorem.words(); const graphqlOperationName = faker.lorem.words(); const graphqlOperationType = faker.lorem.words(); @@ -70,9 +67,6 @@ export async function createFakeSpan({ errorMessage: errorMessage, errorStack: errorStack, graphqlDocument: graphqlDocument, - graphqlVariables: graphqlVariables, - graphqlResult: graphqlResult, - graphqlContext: graphqlContext, graphqlSchemaHash: graphqlSchemaHash, graphqlOperationName: graphqlOperationName, graphqlOperationType: graphqlOperationType, diff --git a/packages/adapters/sqlite/src/entities/Span.ts b/packages/adapters/sqlite/src/entities/Span.ts index 5c305d56..b8fd2965 100644 --- a/packages/adapters/sqlite/src/entities/Span.ts +++ b/packages/adapters/sqlite/src/entities/Span.ts @@ -137,9 +137,6 @@ export class SQLiteSpan extends BaseSpan { errorMessage: input.errorMessage, errorStack: input.errorStack, graphqlDocument: input.graphqlDocument, - graphqlVariables: input.graphqlVariables, - graphqlResult: input.graphqlResult, - graphqlContext: input.graphqlContext, graphqlSchemaHash: input.graphqlSchemaHash, graphqlOperationName: input.graphqlOperationName, graphqlOperationType: input.graphqlOperationType, diff --git a/packages/adapters/sqlite/tests/utils.ts b/packages/adapters/sqlite/tests/utils.ts index d731374b..b22ed29b 100644 --- a/packages/adapters/sqlite/tests/utils.ts +++ b/packages/adapters/sqlite/tests/utils.ts @@ -43,9 +43,6 @@ export async function createFakeSpan({ const errorMessage = shouldError ? faker.random.words() : undefined; const errorStack = shouldError ? faker.random.words() : undefined; const graphqlDocument = faker.random.words(); - const graphqlVariables = faker.random.words(); - const graphqlResult = faker.random.words(); - const graphqlContext = faker.random.words(); const graphqlSchemaHash = faker.random.words(); const graphqlOperationName = faker.random.words(); const graphqlOperationType = faker.random.words(); @@ -64,9 +61,6 @@ export async function createFakeSpan({ errorMessage: errorMessage, errorStack: errorStack, graphqlDocument: graphqlDocument, - graphqlVariables: graphqlVariables, - graphqlResult: graphqlResult, - graphqlContext: graphqlContext, graphqlSchemaHash: graphqlSchemaHash, graphqlOperationName: graphqlOperationName, durationNano: endTimeUnixNano - startTimeUnixNano, diff --git a/packages/data-access/prisma/schema.prisma b/packages/data-access/prisma/schema.prisma index 5cd13361..56a4a51f 100644 --- a/packages/data-access/prisma/schema.prisma +++ b/packages/data-access/prisma/schema.prisma @@ -34,9 +34,6 @@ model Span { graphqlOperationName String? graphqlOperationType String? graphqlDocument String? - graphqlVariables String? - graphqlResult String? - graphqlContext String? graphqlSchemaHash String? attributes String? errorMessage String? diff --git a/packages/graphql-fragments/src/SpanFragment.ts b/packages/graphql-fragments/src/SpanFragment.ts index ccad76f4..0e3c67d4 100644 --- a/packages/graphql-fragments/src/SpanFragment.ts +++ b/packages/graphql-fragments/src/SpanFragment.ts @@ -14,9 +14,6 @@ export const SpanFragment = gql` startTimeUnixNano durationNano graphqlDocument - graphqlVariables - graphqlResult - graphqlContext graphqlOperationName graphqlOperationType createdAt diff --git a/packages/graphql-schema/src/mutations/create-span.ts b/packages/graphql-schema/src/mutations/create-span.ts index 2bf17125..49ce7ffe 100644 --- a/packages/graphql-schema/src/mutations/create-span.ts +++ b/packages/graphql-schema/src/mutations/create-span.ts @@ -45,15 +45,6 @@ const CreateSpanInputObject: InputRef = builder.inputType( graphqlDocument: t.string({ required: false, }), - graphqlVariables: t.string({ - required: false, - }), - graphqlResult: t.string({ - required: false, - }), - graphqlContext: t.string({ - required: false, - }), graphqlSchemaHash: t.string({ required: false, }), diff --git a/packages/graphql-schema/src/objects/span.ts b/packages/graphql-schema/src/objects/span.ts index 60892047..a4b638ed 100644 --- a/packages/graphql-schema/src/objects/span.ts +++ b/packages/graphql-schema/src/objects/span.ts @@ -18,9 +18,6 @@ export const SpanObject: ObjectRef = builder.objectType("Span", { startTimeUnixNano: t.exposeString("startTimeUnixNano"), endTimeUnixNano: t.exposeString("endTimeUnixNano"), graphqlDocument: t.exposeString("graphqlDocument", { nullable: true }), - graphqlVariables: t.exposeString("graphqlVariables", { nullable: true }), - graphqlResult: t.exposeString("graphqlResult", { nullable: true }), - graphqlContext: t.exposeString("graphqlContext", { nullable: true }), graphqlOperationName: t.exposeString("graphqlOperationName", { nullable: true, }), diff --git a/packages/opentelemetry/src/extract-spans.ts b/packages/opentelemetry/src/extract-spans.ts index ec415ad7..bfe31bd8 100644 --- a/packages/opentelemetry/src/extract-spans.ts +++ b/packages/opentelemetry/src/extract-spans.ts @@ -39,9 +39,6 @@ export function extractSpans({ ] as string | undefined; let graphqlDocument: string | undefined; - let graphqlVariables: string | undefined; - let graphqlResult: string | undefined; - let graphqlContext: string | undefined; let errorMessage: string | undefined; let errorStack: string | undefined; @@ -56,33 +53,6 @@ export function extractSpans({ debug("Error parsing document", error); } } - - const variables = attributes[AttributeNames.OPERATION_ARGS]; - if (variables) { - try { - graphqlVariables = JSON.stringify(JSON.parse(variables)); - } catch (error) { - debug("Error parsing variables", error); - } - } - - const result = attributes[AttributeNames.OPERATION_RESULT]; - if (result) { - try { - graphqlResult = JSON.stringify(JSON.parse(result)); - } catch (error) { - debug("Error parsing result", error); - } - } - - const context = attributes[AttributeNames.OPERATION_CONTEXT]; - if (context) { - try { - graphqlContext = JSON.stringify(JSON.parse(context)); - } catch (error) { - debug("Error parsing context", error); - } - } } const remainingAttributes = Object.entries(attributes).reduce( @@ -90,9 +60,6 @@ export function extractSpans({ if ( key !== AttributeNames.SCHEMA_HASH && key !== AttributeNames.DOCUMENT && - key !== AttributeNames.OPERATION_ARGS && - key !== AttributeNames.OPERATION_RESULT && - key !== AttributeNames.OPERATION_CONTEXT && key !== AttributeNames.OPERATION_ROOT_NAME ) { acc[key] = value; @@ -132,9 +99,6 @@ export function extractSpans({ graphqlDocument, graphqlOperationName, graphqlOperationType, - graphqlVariables, - graphqlResult, - graphqlContext, errorMessage, errorStack, }; diff --git a/packages/opentelemetry/src/info-to-attributes.ts b/packages/opentelemetry/src/info-to-attributes.ts index 28d38f44..f02244ba 100644 --- a/packages/opentelemetry/src/info-to-attributes.ts +++ b/packages/opentelemetry/src/info-to-attributes.ts @@ -1,20 +1,17 @@ import { AttributeNames } from "@graphql-debugger/types"; -import { isGraphQLInfoRoot, safeJson } from "@graphql-debugger/utils"; +import { isGraphQLInfoRoot } from "@graphql-debugger/utils"; import { GraphQLResolveInfo, print } from "graphql"; export function infoToAttributes({ info, schemaHash, - args, - context, }: { info: GraphQLResolveInfo; schemaHash?: string; args?: any; context?: any; }): Record { - const _args = args || info.variableValues; const isRoot = isGraphQLInfoRoot({ info }); const attributes = { @@ -27,27 +24,12 @@ export function infoToAttributes({ [AttributeNames.DOCUMENT]: print(info.operation), [AttributeNames.OPERATION_TYPE]: info.operation.operation.toLowerCase(), - ...(info.operation.name?.value ? { [AttributeNames.OPERATION_ROOT_NAME]: info.operation.name?.value, } : {}), - - ...(_args - ? { - [AttributeNames.OPERATION_ARGS]: safeJson({ - args: _args, - }), - } - : {}), - - ...(context - ? { - [AttributeNames.OPERATION_CONTEXT]: safeJson({ context }), - } - : {}), } : {}), }; diff --git a/packages/opentelemetry/tests/extract-spans.test.ts b/packages/opentelemetry/tests/extract-spans.test.ts index d4283bff..9df16718 100644 --- a/packages/opentelemetry/tests/extract-spans.test.ts +++ b/packages/opentelemetry/tests/extract-spans.test.ts @@ -22,26 +22,6 @@ describe("extractSpans", () => { `), ); - const variables = JSON.stringify({ - where: { - name: "bob", - }, - }); - - const context = JSON.stringify({ - user: { - id: "1", - }, - }); - - const result = JSON.stringify({ - users: [ - { - name: "bob", - }, - ], - }); - const error = new Error("something went wrong"); const knownScope: ResourceSpans["scopeSpans"][0]["scope"] = { @@ -92,24 +72,6 @@ describe("extractSpans", () => { stringValue: "[User]", }, }, - { - key: AttributeNames.OPERATION_ARGS, - value: { - stringValue: variables, - }, - }, - { - key: AttributeNames.OPERATION_CONTEXT, - value: { - stringValue: context, - }, - }, - { - key: AttributeNames.OPERATION_RESULT, - value: { - stringValue: result, - }, - }, { key: AttributeNames.OPERATION_ROOT, value: { @@ -236,9 +198,6 @@ describe("extractSpans", () => { ).toString(), graphqlSchemaHash: schemaHash, graphqlDocument: document, - graphqlVariables: variables, - graphqlResult: result, - graphqlContext: context, errorMessage: undefined, errorStack: undefined, isForeign: false, @@ -265,11 +224,8 @@ describe("extractSpans", () => { ).toString(), graphqlSchemaHash: schemaHash, graphqlDocument: undefined, - graphqlVariables: undefined, - graphqlResult: undefined, graphqlOperationName: undefined, graphqlOperationType: undefined, - graphqlContext: undefined, errorMessage: undefined, errorStack: undefined, isForeign: false, @@ -289,9 +245,6 @@ describe("extractSpans", () => { ).toString(), graphqlSchemaHash: schemaHash, graphqlDocument: undefined, - graphqlVariables: undefined, - graphqlResult: undefined, - graphqlContext: undefined, graphqlOperationName: undefined, graphqlOperationType: undefined, errorMessage: error.message, @@ -507,9 +460,6 @@ describe("extractSpans", () => { parentSpanId: undefined, errorMessage: undefined, errorStack: undefined, - graphqlContext: undefined, - graphqlResult: undefined, - graphqlVariables: undefined, graphqlOperationName: undefined, graphqlOperationType: "query", attributes: { @@ -535,10 +485,7 @@ describe("extractSpans", () => { graphqlSchemaHash: schemaHash, errorMessage: undefined, errorStack: undefined, - graphqlContext: undefined, graphqlDocument: undefined, - graphqlResult: undefined, - graphqlVariables: undefined, graphqlOperationName: undefined, graphqlOperationType: undefined, attributes: {}, @@ -563,11 +510,8 @@ describe("extractSpans", () => { }, errorMessage: undefined, errorStack: undefined, - graphqlContext: undefined, graphqlDocument: undefined, - graphqlResult: undefined, graphqlSchemaHash: undefined, - graphqlVariables: undefined, graphqlOperationName: undefined, graphqlOperationType: undefined, }, @@ -587,11 +531,8 @@ describe("extractSpans", () => { attributes: { "db.statement": "SELECT * FROM User" }, errorMessage: undefined, errorStack: undefined, - graphqlContext: undefined, graphqlDocument: undefined, - graphqlResult: undefined, graphqlSchemaHash: undefined, - graphqlVariables: undefined, graphqlOperationName: undefined, graphqlOperationType: undefined, }, diff --git a/packages/opentelemetry/tests/info-to-attributes.test.ts b/packages/opentelemetry/tests/info-to-attributes.test.ts index 3da8ab1f..f37acd52 100644 --- a/packages/opentelemetry/tests/info-to-attributes.test.ts +++ b/packages/opentelemetry/tests/info-to-attributes.test.ts @@ -60,12 +60,6 @@ describe("infoToAttributes", () => { [AttributeNames.DOCUMENT]: expect.any(String), [AttributeNames.OPERATION_RETURN_TYPE]: "String", [AttributeNames.SCHEMA_HASH]: schemaHash, - [AttributeNames.OPERATION_ARGS]: JSON.stringify({ - args: { value: randomArgValue }, - }), - [AttributeNames.OPERATION_CONTEXT]: JSON.stringify({ - context: { value: randomContextValue }, - }), [AttributeNames.OPERATION_ROOT_NAME]: "QueryName", }); }); diff --git a/packages/schemas/src/entities/span.ts b/packages/schemas/src/entities/span.ts index d58949de..65294271 100644 --- a/packages/schemas/src/entities/span.ts +++ b/packages/schemas/src/entities/span.ts @@ -16,9 +16,6 @@ export const SpanSchema = z.object({ errorMessage: z.string().optional().nullable(), errorStack: z.string().optional().nullable(), graphqlDocument: z.string().optional().nullable(), - graphqlVariables: z.string().optional().nullable(), - graphqlResult: z.string().optional().nullable(), - graphqlContext: z.string().optional().nullable(), graphqlOperationName: z.string().optional().nullable(), graphqlOperationType: z.string().optional().nullable(), isGraphQLRootSpan: z.boolean().optional().nullable(), diff --git a/packages/schemas/src/graphql/mutations/create-span.ts b/packages/schemas/src/graphql/mutations/create-span.ts index e889150f..ad3f2771 100644 --- a/packages/schemas/src/graphql/mutations/create-span.ts +++ b/packages/schemas/src/graphql/mutations/create-span.ts @@ -14,9 +14,6 @@ export const CreateSpanInput = z.object({ errorMessage: z.string().optional().nullable(), errorStack: z.string().optional().nullable(), graphqlDocument: z.string().optional().nullable(), - graphqlVariables: z.string().optional().nullable(), - graphqlResult: z.string().optional().nullable(), - graphqlContext: z.string().optional().nullable(), graphqlSchemaHash: z.string().optional().nullable(), graphqlOperationName: z.string().optional().nullable(), graphqlOperationType: z.string().optional().nullable(), diff --git a/packages/schemas/src/opentelemetry/extracted-span.ts b/packages/schemas/src/opentelemetry/extracted-span.ts index d3679652..2d96aad8 100644 --- a/packages/schemas/src/opentelemetry/extracted-span.ts +++ b/packages/schemas/src/opentelemetry/extracted-span.ts @@ -14,9 +14,6 @@ export const ExtractedSpanSchema = z.object({ graphqlOperationName: z.string().optional(), graphqlOperationType: z.string().optional(), graphqlDocument: z.string().optional(), - graphqlVariables: z.string().optional(), - graphqlResult: z.string().optional(), - graphqlContext: z.string().optional(), errorMessage: z.string().optional(), errorStack: z.string().optional(), }); diff --git a/packages/trace-directive/src/trace-directive.ts b/packages/trace-directive/src/trace-directive.ts index e5bc9c4d..93e074b6 100644 --- a/packages/trace-directive/src/trace-directive.ts +++ b/packages/trace-directive/src/trace-directive.ts @@ -6,8 +6,6 @@ import { context as otelContext, runInSpan, } from "@graphql-debugger/opentelemetry"; -import { AttributeNames } from "@graphql-debugger/types"; -import { isGraphQLInfoRoot, safeJson } from "@graphql-debugger/utils"; import { MapperKind, getDirective, mapSchema } from "@graphql-tools/utils"; import { GraphQLSchema, defaultFieldResolver } from "graphql"; @@ -55,23 +53,8 @@ export function traceDirective(directiveName = "trace") { const parentSpan = context.parentSpan as Span | undefined; - const _context = { - ...context, - GraphQLDebuggerContext: undefined, - }; - - if (internalCtx?.excludeKeysFromContext?.length) { - Object.keys(_context).forEach((key) => { - if (internalCtx?.excludeKeysFromContext?.includes(key)) { - delete _context[key]; - } - }); - } - const attributes = infoToAttributes({ info, - args, - context: _context, schemaHash: internalCtx.schemaHash, }); @@ -96,15 +79,6 @@ export function traceDirective(directiveName = "trace") { const result = await resolve(source, args, context, info); - if (isGraphQLInfoRoot({ info })) { - if (internalCtx.includeResult && result) { - span.setAttribute( - AttributeNames.OPERATION_RESULT, - safeJson({ result }), - ); - } - } - context.parentSpan = span; return result; diff --git a/packages/trace-directive/tests/trace.test.ts b/packages/trace-directive/tests/trace.test.ts index dee765c2..f7be4064 100644 --- a/packages/trace-directive/tests/trace.test.ts +++ b/packages/trace-directive/tests/trace.test.ts @@ -308,16 +308,6 @@ describe("@trace directive", () => { expect(spanTree.span.attributes[AttributeNames.DOCUMENT]).toMatch( print(parse(query)), ); - expect( - JSON.parse( - spanTree.span.attributes[AttributeNames.OPERATION_ARGS] as string, - ), - ).toMatchObject({ - args: { - name: "Dan", - age: 23, - }, - }); const postsSpan = spanTree.children.find( (child) => child.span.name === "User posts", @@ -494,23 +484,6 @@ describe("@trace directive", () => { expect( spanTree.span.attributes[AttributeNames.OPERATION_RETURN_TYPE], ).toMatch("[User]"); - - const variables = JSON.parse( - spanTree.span.attributes[AttributeNames.OPERATION_ARGS] as string, - ); - expect(variables).toMatchObject({ - args: { name: randomName }, - }); - - const context = JSON.parse( - spanTree.span.attributes[AttributeNames.OPERATION_CONTEXT] as string, - ); - - expect(context).toEqual({ - context: { name: randomName, someFunction: "Function" }, - }); - - expect(context[excludeContext]).toBeUndefined(); }); test("should append graphql result to trace attribute", async () => { @@ -572,19 +545,10 @@ describe("@trace directive", () => { print(parse(query)), ); - const result = spanTree.span.attributes[AttributeNames.OPERATION_RESULT]; - expect(result).toEqual( - JSON.stringify({ result: { name: randomString, age: "23" } }), - ); - const nameSpan = spanTree.children.find( (child) => child.span.name === "User name", ); expect(nameSpan).toBeDefined(); - - const nameResult = - nameSpan!.span.attributes[AttributeNames.OPERATION_RESULT]; - expect(nameResult).toEqual(undefined); }); test("should append graphql schema hash to trace attribute", async () => { @@ -706,12 +670,5 @@ describe("@trace directive", () => { expect(spanTree.span.attributes[AttributeNames.DOCUMENT]).toMatch( print(parse(query)), ); - - const result = spanTree.span.attributes[AttributeNames.OPERATION_RESULT]; - expect(result).toEqual( - JSON.stringify({ - result: "world", - }), - ); }); }); diff --git a/packages/utils/package.json b/packages/utils/package.json index 108b8500..32da2173 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -23,8 +23,7 @@ "dependencies": { "@graphql-debugger/data-access": "workspace:^", "@graphql-debugger/time": "workspace:^", - "debug": "4.3.4", - "safe-json-stringify": "1.2.0" + "debug": "4.3.4" }, "devDependencies": { "@graphql-debugger/types": "workspace:^", diff --git a/packages/utils/src/db-span-to-network.ts b/packages/utils/src/db-span-to-network.ts index 6a40f6cd..e3a22ee2 100644 --- a/packages/utils/src/db-span-to-network.ts +++ b/packages/utils/src/db-span-to-network.ts @@ -16,9 +16,6 @@ export function dbSpanToNetwork(dbSpan: DBSpan): NetworkSpan { endTimeUnixNano: new UnixNanoTimeStamp(dbSpan.endTimeUnixNano).toString(), durationNano: new UnixNanoTimeStamp(dbSpan.durationNano).toString(), graphqlDocument: dbSpan.graphqlDocument, - graphqlVariables: dbSpan.graphqlVariables, - graphqlResult: dbSpan.graphqlResult, - graphqlContext: dbSpan.graphqlContext, graphqlOperationName: dbSpan.graphqlOperationName, graphqlOperationType: dbSpan.graphqlOperationType, createdAt: new TimeStamp(dbSpan.createdAt).toString(), diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 1fd7b8fc..65969b19 100755 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,6 +1,5 @@ export * from "./debug"; export * from "./hash-schema"; -export * from "./safe-json"; export * from "./sum-trace-time"; export * from "./db-span-to-network"; export * from "./get-trace-start"; diff --git a/packages/utils/src/safe-json.ts b/packages/utils/src/safe-json.ts index 034d59e3..e69de29b 100644 --- a/packages/utils/src/safe-json.ts +++ b/packages/utils/src/safe-json.ts @@ -1,30 +0,0 @@ -import safeJsonStringify from "safe-json-stringify"; - -export const excludedKeys = [ - "req", - "_req", - "request", - "_request", - "res", - "_res", - "params", - "_params", -]; - -export function safeJson(object: any = {}) { - return safeJsonStringify(object, (key, value) => { - if (typeof value === "bigint") { - return value.toString(); - } - - if (typeof value === "function") { - return "Function"; - } - - if (excludedKeys.includes(key)) { - return undefined; - } - - return value; - }); -} diff --git a/plugins/apollo/src/index.ts b/plugins/apollo/src/index.ts index c67e1b85..8a63a44a 100644 --- a/plugins/apollo/src/index.ts +++ b/plugins/apollo/src/index.ts @@ -14,8 +14,6 @@ import { GraphQLDebuggerContext, SchemaExporer, } from "@graphql-debugger/trace-schema"; -import { AttributeNames } from "@graphql-debugger/types"; -import { isGraphQLInfoRoot, safeJson } from "@graphql-debugger/utils"; import { ApolloServerPlugin } from "@apollo/server"; import { Path } from "graphql/jsutils/Path"; @@ -118,7 +116,7 @@ export const graphqlDebuggerPlugin = ({ spanMap.set(currentPath, span); - const callback = (error: Error | null, result: any) => { + const callback = (error: Error | null) => { if (!span) { return; } @@ -130,15 +128,6 @@ export const graphqlDebuggerPlugin = ({ message: e.message, }); span.recordException(e); - } else { - if (isGraphQLInfoRoot({ info: fieldCtx.info })) { - if (internalCtx.includeResult && result) { - span.setAttribute( - AttributeNames.OPERATION_RESULT, - safeJson({ result }), - ); - } - } } span.end(); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6ef7ef0d..bd0eccd7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -745,9 +745,6 @@ importers: graphql: specifier: ^16.0.0 || ^17.0.0 version: 16.0.0 - safe-json-stringify: - specifier: 1.2.0 - version: 1.2.0 devDependencies: "@graphql-debugger/types": specifier: workspace:^ @@ -16369,13 +16366,6 @@ packages: integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==, } - /safe-json-stringify@1.2.0: - resolution: - { - integrity: sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg==, - } - dev: false - /safe-regex-test@1.0.3: resolution: {