Skip to content

Commit

Permalink
Add semantic conventions for GraphQL
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Mar 29, 2022
1 parent 709cb7a commit f9873a8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
20 changes: 20 additions & 0 deletions semantic_conventions/trace/instrumentation/graphql.yml
Original file line number Diff line number Diff line change
@@ -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 } }'
1 change: 1 addition & 0 deletions specification/trace/semantic_conventions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

<!-- semconv graphql -->
| 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.
<!-- endsemconv -->

0 comments on commit f9873a8

Please sign in to comment.