Skip to content
Closed
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
3 changes: 3 additions & 0 deletions packages/plugins/opentelemetry/src/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export {
export const SEMATTRS_GRAPHQL_DOCUMENT = 'graphql.document';
export const SEMATTRS_GRAPHQL_OPERATION_TYPE = 'graphql.operation.type';
export const SEMATTRS_GRAPHQL_OPERATION_NAME = 'graphql.operation.name';

// Identifies a graphql request
export const SEMATTRS_HIVE_GRAPHQL = 'hive.graphql';
export const SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH =
'hive.graphql.operation.hash';
export const SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = 'hive.graphql.error.count';
Expand Down
3 changes: 3 additions & 0 deletions packages/plugins/opentelemetry/src/hive-span-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { SpanImpl } from '@opentelemetry/sdk-trace-base/build/src/Span';
import { SEMATTRS_HTTP_METHOD } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES,
SEMATTRS_HIVE_GRAPHQL,
SEMATTRS_HIVE_GRAPHQL_ERROR_CODES,
SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT,
} from './attributes';
Expand Down Expand Up @@ -131,6 +132,8 @@ export class HiveTracingSpanProcessor implements SpanProcessor {
operationSpan.attributes[attr] ??= span.attributes[attr];
}

operationSpan.attributes[SEMATTRS_HIVE_GRAPHQL] = true;

// Now that operation spans have been updated, we can report it
this.processor.onEnd(operationSpan);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/plugins/opentelemetry/tests/useOpenTelemetry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
SEMATTRS_GRAPHQL_OPERATION_TYPE,
SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES,
SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME,
SEMATTRS_HIVE_GRAPHQL,
SEMATTRS_HIVE_GRAPHQL_ERROR_CODES,
SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT,
SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH,
Expand Down Expand Up @@ -1189,6 +1190,7 @@ describe('useOpenTelemetry', () => {
[SEMATTRS_HTTP_STATUS_CODE]: 500,

// Hive specific
[SEMATTRS_HIVE_GRAPHQL]: true,
['hive.client.name']: 'test-client-name',
['hive.client.version']: 'test-client-version',

Expand Down
Loading