Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ import {
startInactiveSpan,
withActiveSpan,
} from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '@sentry/opentelemetry';

import type { GraphQLInstrumentationConfig, GraphQLInstrumentationParsedConfig } from './types';
import { SENTRY_GRAPHQL_OPERATION } from '@sentry/conventions/attributes';

const PACKAGE_NAME = '@sentry/instrumentation-graphql';

Expand Down Expand Up @@ -267,19 +268,19 @@ export class GraphQLInstrumentation extends InstrumentationBase<GraphQLInstrumen
const rootSpan = getRootSpan(span);
const rootSpanAttributes = spanToJSON(rootSpan).data;

const existingOperations = rootSpanAttributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION] || [];
const existingOperations = rootSpanAttributes[SENTRY_GRAPHQL_OPERATION] || [];

const newOperation = operationName ? `${operationType} ${operationName}` : `${operationType}`;

// We keep track of each operation on the root span
// This can either be a string, or an array of strings (if there are multiple operations)
if (Array.isArray(existingOperations)) {
(existingOperations as string[]).push(newOperation);
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, existingOperations);
rootSpan.setAttribute(SENTRY_GRAPHQL_OPERATION, existingOperations);
} else if (typeof existingOperations === 'string') {
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);
rootSpan.setAttribute(SENTRY_GRAPHQL_OPERATION, [existingOperations, newOperation]);
} else {
rootSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION, newOperation);
rootSpan.setAttribute(SENTRY_GRAPHQL_OPERATION, newOperation);
}

if (!spanToJSON(rootSpan).data['original-description']) {
Expand Down
2 changes: 0 additions & 2 deletions packages/opentelemetry/src/exports.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from './semanticAttributes';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Public export removed without deprecation

Medium Severity

SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION was publicly exported from @sentry/opentelemetry and is removed here with no deprecated alias or notice. Elsewhere, attribute migrations to @sentry/conventions keep the old export marked @deprecated. Flagged because the PR Review Guidelines call out public API removals and breaking changes without deprecation notices.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit 1b136db. Configure here.


export { getRequestSpanData } from './utils/getRequestSpanData';

export { getScopesFromContext } from './utils/contextData';
Expand Down
3 changes: 0 additions & 3 deletions packages/opentelemetry/src/semanticAttributes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
/** If this attribute is true, it means that the parent is a remote span. */
export const SEMANTIC_ATTRIBUTE_SENTRY_PARENT_IS_REMOTE = 'sentry.parentIsRemote';

// These are not standardized yet, but used by the graphql instrumentation
export const SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION = 'sentry.graphql.operation';
4 changes: 2 additions & 2 deletions packages/opentelemetry/src/utils/parseSpanDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
HTTP_URL,
MESSAGING_SYSTEM,
RPC_SERVICE,
SENTRY_GRAPHQL_OPERATION,
SENTRY_KIND,
URL_FULL,
} from '@sentry/conventions/attributes';
Expand All @@ -25,7 +26,6 @@ import {
spanToJSON,
stripUrlQueryAndFragment,
} from '@sentry/core';
import { SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION } from '../semanticAttributes';
import type { AbstractSpan } from '../types';
import { spanHasAttributes, spanHasName } from './spanTypes';

Expand Down Expand Up @@ -175,7 +175,7 @@ export function descriptionForHttpMethod(
return { ...getUserUpdatedNameAndSource(name, attributes), op: opParts.join('.') };
}

const graphqlOperationsAttribute = attributes[SEMANTIC_ATTRIBUTE_SENTRY_GRAPHQL_OPERATION];
const graphqlOperationsAttribute = attributes[SENTRY_GRAPHQL_OPERATION];

// Ex. GET /api/users
const baseDescription = `${httpMethod} ${urlPath}`;
Expand Down
Loading