Odyssey

Voyage III: Federation in Production

Airlock in productionVariants in a supergraphPublishing to a graph variantSchema checks in a supergraphLocal schema checksSchema checks in CIPublishing & deploymentBuild check errorsOperation check errorsObservability with GraphOS Studio
10. Observability with GraphOS Studio
3m

Overview

The Airlock team has successfully implemented its newest feature (Project Galactic Coordinates), which has evolved and expanded the capabilities of the Airlock graph. They've also made sure to maintain the graph by adding new arguments and removing unused fields. Let's explore how we can continue to keep track of the graph's health and performance.

In this lesson, we will:

  • Explore supergraph insights through the operation and field metrics provided by GraphOS
  • Learn how to interpret metrics for field executions and referencing operations

Metrics in GraphOS

GraphOS provides us with observability tools to track the health and performance of our graph. These tools help surface patterns in how our graph gets used, which helps us identify ways to continue improving our graph.

We can find these metrics under the Insights page in Studio.

Operation metrics

The Operations tab is selected by default in the Insights page. It gives us an overview of operation request rates, service time, and error percentages, including specific operations for each of these that might be worth drilling deeper into.

https://studio.apollographql.com

Insights page in Studio, showing Operations tab

We recommend that clients clearly name each GraphQL operation they send to the graph, because these are the operation names you'll see in your metrics.

We can also filter to select a particular operation to see more specific details about its usage, as well as its signature, which is the shape of the query. We can see the number of requests that have been made and how long each request takes over time.

It looks like one of Airlock's highest-requested operations is GetListing. We can click on the operation to see more detailed insights.

https://studio.apollographql.com

Operations page filter for a specific operation in Studio

Field usage

GraphOS also gives us insight into the usage metrics of our graph's fields. We can navigate to this page by clicking the Fields tab inside the Insights page.

https://studio.apollographql.com

Fields page in Studio

We can use the dropdowns on the top-right side of the page to filter metrics based on a custom time range.

Let's take a closer look at the Listing.overallRating field as an example. In the Usage section, we can see exactly which operations include the Listing.overallRating field:

https://studio.apollographql.com

Fields page details for a specific field in Studio

https://studio.apollographql.com

Fields page details for a specific field in Studio

With a larger time period filter, we can see two new columns: requests and executions.

https://studio.apollographql.com

Fields page details for a specific field in Studio

Field usage metrics fall under two categories: field requests and field executions.

  • Field requests represent how many operations were sent by clients over a given time period that included the field.
  • Field executions represent how many times your servers have executed the resolver for the field over a given time period.

Note: The values for field executions and referencing operations can differ significantly. You can find out the possible reasons by reading the Apollo docs on field usage metrics.

Using insights

We can use these metrics to monitor the health and usage of our graph's types and fields. This helps us answer questions like:

  • Are there some fields that don't get any use at all? Are there deprecated fields from long ago that aren't being used but are still in the schema? Maybe it's time to remove these from the graph to keep our schema clean and useful.
  • Are we planning on making a significant change to a field? Which clients and operations would be affected? We'll need to make sure they're looped into any changes we make.

As our graph evolves, these are good questions to keep in mind, and GraphOS will always be there to help answer them!

Practice

If you needed to know how many times a field has been resolved, which metric would you use?
If you needed to know how many operations have included a field, which metric would you use?
Which of the following operation metrics does GraphOS provide?

Key takeaways

  • Operation metrics provide an overview of operation request rates, service time, and error percentages within a given time period or for a specific operation.
  • Field metrics include field requests (how many operations were sent that included that field) and field executions (how many times the resolver for the field has been executed).

Congratulations 🎉

Well done, you've reached the end! In this course, we learned all about how to work with an existing supergraph in production. We saw how to incorporate schema checks and graph variants into a CI/CD workflow so we can ship new features with confidence. We also explored different types of errors we might encounter from build checks and operation checks. Finally, we looked at how to use GraphOS to discover metrics on our client operations and field usage.

See you in the next series!

Previous

Share your questions and comments about this lesson

Your feedback helps us improve! If you're stuck or confused, let us know and we'll help you out. All comments are public and must follow the Apollo Code of Conduct. Note that comments that have been resolved or addressed may be removed.

You'll need a GitHub account to post below. Don't have one? Post in our Odyssey forum instead.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              arguments

              A key-value pair associated with a particular schema field that lets operations pass data to that field's resolver.

              Argument values can be hardcoded as literal values (shown below for clarity) or provided via GraphQL variables (recommended).

              query GetHuman {
              human(id: "200") {
              name
              height(unit: "meters")
              }
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              GraphQL

              An open-source query language and specification for APIs that enables clients to request specific data, promoting efficiency and flexibility in data retrieval.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operation names

              The name of a particular query, mutation, or subscription. You should provide a name for every operation to improve logging and debugging. For example:

              mutation AddTodo($type: String!) {
              addTodo(type: $type) {
              id
              type
              }
              }
              query GetHuman {
              human(id: "200") {
              name
              height(unit: "meters")
              }
              }

              The operations above are named AddTodo and GetHuman.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              query

              A request for specific data from a GraphQL server. Clients define the structure of the response, enabling precise and efficient data retrieval.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              Field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              resolver

              A function that populates data for a particular field in a GraphQL schema. For example:

              const resolvers = {
              Query: {
              author(root, args, context, info) {
              return find(authors, { id: args.id });
              },
              },
              };
              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              fields

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              graph

              A schema-based data model representing how different data elements interconnect and can be accessed.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              Operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              Field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }
              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              operations

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              resolver

              A function that populates data for a particular field in a GraphQL schema. For example:

              const resolvers = {
              Query: {
              author(root, args, context, info) {
              return find(authors, { id: args.id });
              },
              },
              };
              supergraph

              A unified, federated graph composed of separate GraphQL APIs using Apollo Federation. Enables a microservices architecture that exposes a unified GraphQL API to clients.

              schema checks

              A GraphOS feature that ensures proposed subgraph schema changes successfully compose into a supergraph schema, don't break active clients, and follow best practices.

              variants

              Independent instances of a graph often used to represent different environments. Each variant has its own schema and own router.

              operation

              A single query, mutation, or subscription that clients send to a GraphQL server to request or manipulate data.

              GraphOS

              A platform for building and managing a supergraph. It provides a management plane to test and ship changes and runtime capabilities to secure and monitor the graph.

              metrics

              Measurements of the router's behavior that can be exported and monitored, for example, the number of in-flight requests.

              field

              A unit of data that belongs to a type in a schema. Every GraphQL query requests one or more fields.

              type Author {
              # id, firstName, and lastName are all fields of the Author type
              id: Int!
              firstName: String
              lastName: String
              }

              NEW COURSE ALERT

              Introducing Apollo Connectors

              Connectors are the new and easy way to get started with GraphQL, using existing REST APIs.

              Say goodbye to GraphQL servers and resolvers—now, everything happens in the schema!

              Take the course