diff --git a/semantic_conventions/trace/instrumentation/graphql.yml b/semantic_conventions/trace/instrumentation/graphql.yml new file mode 100644 index 00000000000..3b779b36527 --- /dev/null +++ b/semantic_conventions/trace/instrumentation/graphql.yml @@ -0,0 +1,20 @@ +groups: + - id: graphql + prefix: graphql + brief: > + This document defines semantic conventions to apply when instrumenting the GraphQL Server. They map GraphQL query + to attributes on a Span. + attributes: + - id: graphql.operation.name + brief: "The name of the query being executed." + type: string + examples: 'findBookById' + - id: graphql.operation.type + brief: "The name of the operation being executed." + type: string + examples: ['QUERY', 'MUTATION', 'SUBSCRIPTION'] + - id: graphql.source + brief: "The GraphQL query being executed." + type: string + note: The value may be sanitized to exclude sensitive information. + examples: 'query findBookById { bookById(id: ?) { name } }' diff --git a/specification/trace/semantic_conventions/README.md b/specification/trace/semantic_conventions/README.md index 5fdb89716d9..34c54b40350 100644 --- a/specification/trace/semantic_conventions/README.md +++ b/specification/trace/semantic_conventions/README.md @@ -28,6 +28,7 @@ The following library-specific semantic conventions are defined: * [AWS Lambda](instrumentation/aws-lambda.md): For AWS Lambda spans. * [AWS SDK](instrumentation/aws-sdk.md): For AWS SDK spans. +* [GraphQL](instrumentation/graphql.md): For GraphQL spans. Apart from semantic conventions for traces and [metrics](../../metrics/semantic_conventions/README.md), OpenTelemetry also defines the concept of overarching [Resources](../../resource/sdk.md) with their own diff --git a/specification/trace/semantic_conventions/instrumentation/graphql.md b/specification/trace/semantic_conventions/instrumentation/graphql.md new file mode 100644 index 00000000000..917104cd50f --- /dev/null +++ b/specification/trace/semantic_conventions/instrumentation/graphql.md @@ -0,0 +1,16 @@ +# Semantic conventions for GraphQL Server + +**Status**: [Experimental](../../../document-status.md) + +This document defines semantic conventions to apply when instrumenting the GraphQL Server. They map GraphQL query to +attributes on a Span. + + +| Attribute | Type | Description | Examples | Required | +|---|---|---|---|---| +| `graphql.graphql.operation.name` | string | The name of the query being executed. | `findBookById` | No | +| `graphql.graphql.operation.type` | string | The name of the operation being executed. | `QUERY`; `MUTATION`; `SUBSCRIPTION` | No | +| `graphql.graphql.source` | string | The GraphQL query being executed. [1] | `query findBookById { bookById(id: ?) { name } }` | No | + +**[1]:** The value may be sanitized to exclude sensitive information. +