Skip to content

Commit

Permalink
Removed Apollo Tracing documentation (#7595)
Browse files Browse the repository at this point in the history
  • Loading branch information
glen-84 authored Oct 14, 2024
1 parent 2e50852 commit 5bea82c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 100 deletions.
2 changes: 1 addition & 1 deletion website/src/docs/hotchocolate/v14/server/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Though not considered one of the responsibilities of a GraphQL server, for conve

# Instrumentation

Hot Chocolate allows you to gather instrumentation data about your GraphQL server, by hooking into various events in the execution process of a GraphQL request. You will also learn how to setup our OpenTelemetry integration and how to utilize _Apollo Tracing_.
Hot Chocolate allows you to gather instrumentation data about your GraphQL server, by hooking into various events in the execution process of a GraphQL request. You will also learn how to set up our OpenTelemetry integration.

[Learn more about instrumentation](/docs/hotchocolate/v14/server/instrumentation)

Expand Down
99 changes: 0 additions & 99 deletions website/src/docs/hotchocolate/v14/server/instrumentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,102 +374,3 @@ builder.Services.AddSingleton<ActivityEnricher, CustomActivityEnricher>();
```

![Jaeger](../../../shared/jaeger4.png)

# Apollo Tracing

_Apollo Tracing_ is a [performance tracing specification](https://github.com/apollographql/apollo-tracing) for GraphQL servers. It works by returning tracing information about the current request alongside the computed data. While it is not part of the GraphQL specification itself, there is a common agreement in the GraphQL community that all GraphQL servers should support it.

**Example**

```graphql
{
book(id: 1) {
name
author
}
}
```

The above request would result in the below response if _Apollo Tracing_ is enabled.

```json
{
"data": {
"book": {
"name": "C# in Depth",
"author": "Jon Skeet"
}
},
"extensions": {
"tracing": {
"version": 1,
"startTime": "2021-09-25T15:31:41.6515774Z",
"endTime": "2021-09-25T15:31:43.1602255Z",
"duration": 1508648100,
"parsing": { "startOffset": 13335, "duration": 781 },
"validation": { "startOffset": 17012, "duration": 323681 },
"execution": {
"resolvers": [
{
"path": ["book"],
"parentType": "Query",
"fieldName": "book",
"returnType": "Book",
"startOffset": 587048,
"duration": 1004748344
},
{
"path": ["book", "author"],
"parentType": "Book",
"fieldName": "author",
"returnType": "String",
"startOffset": 1005854823,
"duration": 500265020
}
]
}
}
}
}
```

## Enabling Apollo Tracing

_Apollo Tracing_ needs to be explicitly enabled by calling `AddApolloTracing` on the `IRequestExecutorBuilder`.

```csharp
builder.Services
.AddGraphQLServer()
.AddApolloTracing();
```

Further, we can specify a `TracingPreference`. Per default, it is `TracingPreference.OnDemand`.

```csharp
builder.Services
.AddGraphQLServer()
.AddApolloTracing(TracingPreference.Always);
```

There are three possible options for the `TracingPreference`.

| Option | Description |
| ---------- | -------------------------------------------------------------------------------------------- |
| `Never` | _Apollo Tracing_ is disabled. Useful if we want to conditionally disable _Apollo Tracing_. |
| `OnDemand` | _Apollo Tracing_ only traces requests if a specific header is passed with the query request. |
| `Always` | _Apollo Tracing_ is always enabled, and all query requests are traced automatically. |

## On Demand

When _Apollo Tracing_ is added using the `TracingPreference.OnDemand`, we are required to pass one of the following HTTP headers with our query request in order to enable tracing for this specific request.

- `GraphQL-Tracing=1`
- `X-Apollo-Tracing=1`

When using `curl` this could look like the following.

```bash
curl -X POST -H 'GraphQL-Tracing: 1' -H 'Content-Type: application/json' \
-d '{"query":"{\n book(id: 1) {\n name\n author\n }\n}\n"}' \
'http://localhost:5000/graphql'
```

0 comments on commit 5bea82c

Please sign in to comment.