Skip to content

Commit 9647faa

Browse files
Anthony GriffonMiaxos
authored andcommitted
misc: update documentation
1 parent d721e4e commit 9647faa

File tree

2 files changed

+68
-12
lines changed

2 files changed

+68
-12
lines changed

src/lib.rs

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1-
//! # Apollo Studio Extension for Performance Tracing for async_graphql crates
1+
//! # Apollo Extensions for async_graphql
2+
//! <div align="center">
3+
//! <!-- CI -->
4+
//! <img src="https://github.com/Miaxos/async_graphql_apollo_studio_extension/actions/workflows/ci.yml/badge.svg" />
5+
//! <!-- Crates version -->
6+
//! <a href="https://crates.io/crates/async-graphql-extension-apollo-tracing">
7+
//! <img src="https://img.shields.io/crates/v/async-graphql-extension-apollo-tracing.svg?style=flat-square"
8+
//! alt="Crates.io version" />
9+
//! </a>
10+
//! <!-- Downloads -->
11+
//! <a href="https://crates.io/crates/async-graphql-extension-apollo-tracing">
12+
//! <img src="https://img.shields.io/crates/d/async-graphql-extension-apollo-tracing.svg?style=flat-square"
13+
//! alt="Download" />
14+
//! </a>
15+
//! </div>
16+
//!
17+
//! ## Features
18+
//!
19+
//! * Fully support traces & errors
20+
//! * Batched traces transfer
21+
//! * Client segmentation
22+
//! * Tracing
23+
//! * Schema register protocol implemented
24+
//!
25+
//! ## Crate Features
26+
//!
27+
//! * `compression` - To enable GZIP Compression when sending traces to Apollo Studio.
228
mod compression;
329
mod packages;
430
mod proto;
@@ -31,11 +57,13 @@ use std::convert::TryInto;
3157
use tokio::sync::mpsc::{channel, Sender};
3258
use tokio::sync::RwLock;
3359

34-
/// Apollo tracing extension for performance tracing
35-
/// https://www.apollographql.com/docs/studio/setup-analytics/#adding-support-to-a-third-party-server-advanced
60+
/// Apollo Tracing Extension to send traces to Apollo Studio
61+
/// The extension to include to your `async_graphql` instance to connect with Apollo Studio.
3662
///
37-
/// Apollo Tracing works by creating Trace from GraphQL calls, which contains extra data about the
38-
/// request being processed. These traces are then batched sent to the Apollo Studio server.
63+
/// <https://www.apollographql.com/docs/studio/setup-analytics/#adding-support-to-a-third-party-server-advanced>
64+
///
65+
/// Apollo Tracing works by creating traces from GraphQL calls, which contains extra data about the
66+
/// request being processed. These traces are then batched sent to Apollo Studio.
3967
///
4068
/// The extension will start a separate function on a separate thread which will aggregate traces
4169
/// and batch send them.
@@ -51,6 +79,7 @@ const TARGET_LOG: &str = "apollo-studio-extension";
5179
const VERSION: &str = env!("CARGO_PKG_VERSION");
5280
const RUNTIME_VERSION: &str = "Rust - No runtime version provided yet";
5381

82+
/// An ENUM describing the various HTTP Methods existing.
5483
#[derive(Debug, Clone)]
5584
pub enum HTTPMethod {
5685
UNKNOWN = 0,
@@ -82,7 +111,30 @@ impl From<HTTPMethod> for Trace_HTTP_Method {
82111
}
83112
}
84113

85-
/// This structure must be registered to the Query Data to add context to the apollo metrics.
114+
/// The structure where you can add additional context for Apollo Studio.
115+
/// This structure must be added to your query data.
116+
///
117+
/// It'll allow you to [segment your
118+
/// users](https://www.apollographql.com/docs/studio/client-awareness/)
119+
///
120+
/// * `userid` - To segment your users, you should fill this field with an internal id describing
121+
/// your client or event a name. Apollo Studio will be able to aggregate metrics by users.
122+
/// * `client_name` - You can segment your users by the client they are using to access your
123+
/// GraphQL API, it's really usefull when you have mobile and web users for instance. Usually we
124+
/// add a header `apollographql-client-name` to store this data. Apollo Studio will allow you to
125+
/// aggregate your metrics by Client Name.
126+
/// * `client_version` - You can segment your users by the client but it's usefull to also have the
127+
/// version your clients are using, especially when you are serving your API for mobile users,
128+
/// it'll allow you to follow metrics depending on which version your users are. Usually we add a
129+
/// header `apollographql-client-version` to store this data.
130+
/// * `path` - It's the HTTP path to your GraphQL API, it may be usefull for you but generally it's
131+
/// just `/graphql`.
132+
/// * `host` - It's the HTTP host to your GraphQL API.
133+
/// * `method` - The HTTP Method.
134+
/// * `secure` - If you have SSL.
135+
/// * `protocol` - The http protocol, example: HTTP/1, HTTP/1.1, HTTP/2.
136+
/// * `status_code` - The status code return by your GraphQL API. It's a little weird to have to put it
137+
/// before executing the graphql function, it'll be changed later but usually it's just a 200.
86138
#[derive(Debug, Clone)]
87139
pub struct ApolloTracingDataExt {
88140
pub userid: Option<String>,
@@ -116,11 +168,12 @@ impl ApolloTracing {
116168
/// We initialize the ApolloTracing Extension by starting our aggregator async function which
117169
/// will receive every traces and send them to the Apollo Studio Ingress for processing
118170
///
119-
/// autorization_token - Token to send metrics to apollo studio.
120-
/// hostname - Hostname like yourdomain-graphql-1.io
121-
/// graph_ref - <ref>@<variant> Graph reference with variant
122-
/// release_name - Your release version or release name from Git for example
123-
/// batch_target - The number of traces to batch, it depends on your traffic
171+
/// * autorization_token - Token to send metrics to apollo studio.
172+
/// * hostname - Hostname like yourdomain-graphql-1.io
173+
/// * graph_ref - <ref>@<variant> Graph reference with variant
174+
/// * release_name - Your release version or release name from Git for example
175+
/// * batch_target - The number of traces to batch, it depends on your traffic, if you have
176+
/// 60 request per minutes, set it to 20.
124177
pub fn new(
125178
authorization_token: String,
126179
hostname: String,

src/register.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
//! # Apollo Studio Extension for Registering Schema
1+
//! # Apollo Schema reporting
2+
//!
3+
//! Implementation of the apollo Schema Reporting Protocol
4+
//! <https://www.apollographql.com/docs/studio/schema/schema-reporting/>
25
use async_graphql::{ObjectType, Schema, SubscriptionType};
36
use reqwest::Client;
47
use sha2::{Digest, Sha256};

0 commit comments

Comments
 (0)