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.
2
28
mod compression;
3
29
mod packages;
4
30
mod proto;
@@ -31,11 +57,13 @@ use std::convert::TryInto;
31
57
use tokio:: sync:: mpsc:: { channel, Sender } ;
32
58
use tokio:: sync:: RwLock ;
33
59
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.
36
62
///
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.
39
67
///
40
68
/// The extension will start a separate function on a separate thread which will aggregate traces
41
69
/// and batch send them.
@@ -51,6 +79,7 @@ const TARGET_LOG: &str = "apollo-studio-extension";
51
79
const VERSION : & str = env ! ( "CARGO_PKG_VERSION" ) ;
52
80
const RUNTIME_VERSION : & str = "Rust - No runtime version provided yet" ;
53
81
82
+ /// An ENUM describing the various HTTP Methods existing.
54
83
#[ derive( Debug , Clone ) ]
55
84
pub enum HTTPMethod {
56
85
UNKNOWN = 0 ,
@@ -82,7 +111,30 @@ impl From<HTTPMethod> for Trace_HTTP_Method {
82
111
}
83
112
}
84
113
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.
86
138
#[ derive( Debug , Clone ) ]
87
139
pub struct ApolloTracingDataExt {
88
140
pub userid : Option < String > ,
@@ -116,11 +168,12 @@ impl ApolloTracing {
116
168
/// We initialize the ApolloTracing Extension by starting our aggregator async function which
117
169
/// will receive every traces and send them to the Apollo Studio Ingress for processing
118
170
///
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.
124
177
pub fn new (
125
178
authorization_token : String ,
126
179
hostname : String ,
0 commit comments