Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Create debugging-client-requests.mdx #6504

Closed
wants to merge 7 commits into from
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
5 changes: 5 additions & 0 deletions .changesets/docs_debug_client_requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### [docs] Create debugging-client-requests.mdx ([PR #6504](https://github.com/apollographql/router/pull/6504))

Add a docs page about how to debug client requests. This infomation is spread across many different features so this serves as a landing page for all of that.

By [@smyrick](https://github.com/smyrick) in https://github.com/apollographql/router/pull/6504
52 changes: 52 additions & 0 deletions docs/source/routing/observability/debugging-client-requests.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Debugging Client Requests to GraphOS Router
subtitle: Log incoming requests to help debug problematic queries or errors
description: Enable telemetry features to help gain more visibility into incoming HTTP requests and help debug issues your clients may be having.
---

By default, the GraphOS Router does not generate access logs for incoming client HTTP requests, nor are features like OpenTelemetry enabled to capture every request.

The best way to see GraphQL operation data is to use [GraphOS Insights](https://www.apollographql.com/docs/graphos/platform/insights). Here you will be able to see failed requests, what the client id was, and what was the exact [GraphQL error if enabled](https://www.apollographql.com/docs/graphos/routing/graphos-reporting#errors).

If however, you are having issues with some requests coming from clients and would like to enable debugging features in your own evnironment, we reccomend first doing this in a non-production environment or using logic to do this on a per-request basis.

## OpenTelemetry Spans and Traces
Using [Router Telemetry](https://www.apollographql.com/docs/graphos/routing/observability/telemetry), the trace for a give request will have a span labeled as `router`. This span will contain the HTTP information for a given client request with our [standard attributes](https://www.apollographql.com/docs/graphos/reference/router/telemetry/instrumentation/standard-attributes#router).

This will include helpful information about the request and response, but you will notice that an attribute for the HTTP body text is not included. If you would like to see the GraphQL operation first check your [GraphOS Insights](https://www.apollographql.com/docs/graphos/platform/insights) or follow the other options listed below.

## Request/Response Logging
Using the [logging-when-header](https://www.apollographql.com/docs/graphos/reference/router/telemetry/log-exporters/overview#requestresponse-logging) feature you can include the request body in your logs conditionally.

```yaml title="router.yaml"
telemetry:
exporters:
logging:
# If one of these headers matches we will log supergraph and subgraphs requests/responses
experimental_when_header:
- name: apollo-router-log-request
value: my_client
headers: true # default: false
body: true # default: false
```

## Rhai Scripts & Coprocessors
Hooking into the `RouterService` layer for either [Rhai scripts](https://www.apollographql.com/docs/graphos/routing/customization/rhai) or [Coprocessors](https://www.apollographql.com/docs/graphos/routing/customization/coprocessor) will give you access to the full HTTP request/response before any processing takes place. Here you can add custom logic on what to log and when.

## Debug Router Logs
GraphOS Router by default uses the `info` level for its logging. [Enabling other logging levels](https://www.apollographql.com/docs/graphos/reference/router/telemetry/log-exporters/overview) can help debug specific scenarios. It is only reccomended for local or non-production environments.

## Alternative Cloud Services
If you are deploying GraphOS Router to a cloud service, it is likely that you already have access to the raw HTTP logs through other services such as a load balancer. Using the trace id or operation hash, you should be able to find a specific client request logs for that operation. Check out the docs for popular cloud providers here:

AWS
* [AWS CloudWatch Logs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html)
* [AWS Elastic Load Balancer](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-access-logs.html)

GCP
* [Google Cloud Observability](https://cloud.google.com/logging/docs/log-analytics)
* [Google Cloud Load Balancing](https://cloud.google.com/load-balancing/docs/l7-internal/monitoring)

Azure
* [Azure App Service Logging](https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs)
* [Azure Load Balancer](https://learn.microsoft.com/en-us/azure/load-balancer/monitor-load-balancer]
Loading