Skip to content

Commit 9d7a7d3

Browse files
committed
Go
1 parent fa1cebd commit 9d7a7d3

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

docs/README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
|[**query\_planner**](#query_planner)|`object`|Query planning configuration.<br/>Default: `{"allow_expose":false,"timeout":"10s"}`<br/>||
1717
|[**supergraph**](#supergraph)|`object`|Configuration for the Federation supergraph source. By default, the router will use a local file-based supergraph source (`./supergraph.graphql`).<br/>||
1818
|[**traffic\_shaping**](#traffic_shaping)|`object`|Configuration for the traffic-shaper executor. Use these configurations to control how requests are being executed to subgraphs.<br/>Default: `{"dedupe_enabled":true,"max_connections_per_host":100,"pool_idle_timeout_seconds":50}`<br/>||
19-
|[**usage\_reporting**](#usage_reporting)|`object`, `null`|Configuration for usage reporting to GraphQL Hive.<br/>|yes|
19+
|[**usage\_reporting**](#usage_reporting)|`object`|Configuration for usage reporting to GraphQL Hive.<br/>Default: `{"accept_invalid_certs":false,"access_token":"","buffer_size":1000,"client_name_header":"graphql-client-name","client_version_header":"graphql-client-version","connect_timeout":"5s","enabled":false,"endpoint":"https://app.graphql-hive.com/usage","exclude":[],"flush_interval":"5s","request_timeout":"15s","sample_rate":"100%","target_id":null}`<br/>|yes|
2020

2121
**Additional Properties:** not allowed
2222
**Example**
@@ -111,7 +111,20 @@ traffic_shaping:
111111
dedupe_enabled: true
112112
max_connections_per_host: 100
113113
pool_idle_timeout_seconds: 50
114-
usage_reporting: null
114+
usage_reporting:
115+
accept_invalid_certs: false
116+
access_token: ''
117+
buffer_size: 1000
118+
client_name_header: graphql-client-name
119+
client_version_header: graphql-client-version
120+
connect_timeout: 5s
121+
enabled: false
122+
endpoint: https://app.graphql-hive.com/usage
123+
exclude: []
124+
flush_interval: 5s
125+
request_timeout: 15s
126+
sample_rate: 100%
127+
target_id: null
115128

116129
```
117130

@@ -1832,7 +1845,7 @@ pool_idle_timeout_seconds: 50
18321845
```
18331846

18341847
<a name="usage_reporting"></a>
1835-
## usage\_reporting: object,null
1848+
## usage\_reporting: object
18361849

18371850
Configuration for usage reporting to GraphQL Hive.
18381851

@@ -1847,18 +1860,31 @@ Configuration for usage reporting to GraphQL Hive.
18471860
|**client\_name\_header**|`string`|Default: `"graphql-client-name"`<br/>|no|
18481861
|**client\_version\_header**|`string`|Default: `"graphql-client-version"`<br/>|no|
18491862
|**connect\_timeout**|`string`|A timeout for only the connect phase of a request to Hive Console<br/>Default: 5 seconds<br/>Default: `"5s"`<br/>|no|
1863+
|**enabled**|`boolean`|Default: `false`<br/>|no|
18501864
|**endpoint**|`string`|For self-hosting, you can override `/usage` endpoint (defaults to `https://app.graphql-hive.com/usage`).<br/>Default: `"https://app.graphql-hive.com/usage"`<br/>|no|
18511865
|[**exclude**](#usage_reportingexclude)|`string[]`|A list of operations (by name) to be ignored by Hive.<br/>Default: <br/>|no|
18521866
|**flush\_interval**|`string`|Frequency of flushing the buffer to the server<br/>Default: 5 seconds<br/>Default: `"5s"`<br/>|no|
18531867
|**request\_timeout**|`string`|A timeout for the entire request to Hive Console<br/>Default: 15 seconds<br/>Default: `"15s"`<br/>|no|
1854-
|**sample\_rate**|`number`|Sample rate to determine sampling.<br/>0.0 = 0% chance of being sent<br/>1.0 = 100% chance of being sent<br/>Default: 1.0<br/>Default: `1`<br/>Format: `"double"`<br/>|no|
1868+
|**sample\_rate**|`string`|Sample rate to determine sampling.<br/>0% = never being sent<br/>50% = half of the requests being sent<br/>100% = always being sent<br/>Default: 100%<br/>Default: `"100%"`<br/>|no|
18551869
|**target\_id**|`string`, `null`|A target ID, this can either be a slug following the format “$organizationSlug/$projectSlug/$targetSlug” (e.g “the-guild/graphql-hive/staging”) or an UUID (e.g. “a0f4c605-6541-4350-8cfe-b31f21a4bf80”). To be used when the token is configured with an organization access token.<br/>|no|
18561870

18571871
**Additional Properties:** not allowed
18581872
**Example**
18591873

18601874
```yaml
1861-
{}
1875+
accept_invalid_certs: false
1876+
access_token: ''
1877+
buffer_size: 1000
1878+
client_name_header: graphql-client-name
1879+
client_version_header: graphql-client-version
1880+
connect_timeout: 5s
1881+
enabled: false
1882+
endpoint: https://app.graphql-hive.com/usage
1883+
exclude: []
1884+
flush_interval: 5s
1885+
request_timeout: 15s
1886+
sample_rate: 100%
1887+
target_id: null
18621888
18631889
```
18641890

lib/router-config/src/usage_reporting.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ use serde::{Deserialize, Serialize};
88
pub struct UsageReportingConfig {
99
#[serde(default = "default_enabled")]
1010
pub enabled: bool,
11+
1112
/// Your [Registry Access Token](https://the-guild.dev/graphql/hive/docs/management/targets#registry-access-tokens) with write permission.
1213
pub access_token: String,
14+
1315
/// A target ID, this can either be a slug following the format “$organizationSlug/$projectSlug/$targetSlug” (e.g “the-guild/graphql-hive/staging”) or an UUID (e.g. “a0f4c605-6541-4350-8cfe-b31f21a4bf80”). To be used when the token is configured with an organization access token.
1416
#[serde(deserialize_with = "deserialize_target_id")]
1517
pub target_id: Option<String>,
1618
/// For self-hosting, you can override `/usage` endpoint (defaults to `https://app.graphql-hive.com/usage`).
1719
#[serde(default = "default_endpoint")]
1820
pub endpoint: String,
21+
1922
/// Sample rate to determine sampling.
2023
/// 0% = never being sent
2124
/// 50% = half of the requests being sent
@@ -24,22 +27,27 @@ pub struct UsageReportingConfig {
2427
#[serde(default = "default_sample_rate")]
2528
#[schemars(with = "String")]
2629
pub sample_rate: Percentage,
30+
2731
/// A list of operations (by name) to be ignored by Hive.
2832
/// Example: ["IntrospectionQuery", "MeQuery"]
2933
#[serde(default)]
3034
pub exclude: Vec<String>,
35+
3136
#[serde(default = "default_client_name_header")]
3237
pub client_name_header: String,
3338
#[serde(default = "default_client_version_header")]
3439
pub client_version_header: String,
40+
3541
/// A maximum number of operations to hold in a buffer before sending to Hive Console
3642
/// Default: 1000
3743
#[serde(default = "default_buffer_size")]
3844
pub buffer_size: usize,
45+
3946
/// Accepts invalid SSL certificates
4047
/// Default: false
4148
#[serde(default = "default_accept_invalid_certs")]
4249
pub accept_invalid_certs: bool,
50+
4351
/// A timeout for only the connect phase of a request to Hive Console
4452
/// Default: 5 seconds
4553
#[serde(
@@ -49,6 +57,7 @@ pub struct UsageReportingConfig {
4957
)]
5058
#[schemars(with = "String")]
5159
pub connect_timeout: Duration,
60+
5261
/// A timeout for the entire request to Hive Console
5362
/// Default: 15 seconds
5463
#[serde(
@@ -58,6 +67,7 @@ pub struct UsageReportingConfig {
5867
)]
5968
#[schemars(with = "String")]
6069
pub request_timeout: Duration,
70+
6171
/// Frequency of flushing the buffer to the server
6272
/// Default: 5 seconds
6373
#[serde(

0 commit comments

Comments
 (0)