Skip to content

Commit 7abbab6

Browse files
committed
Update docs
1 parent 5571370 commit 7abbab6

File tree

5 files changed

+50
-7
lines changed

5 files changed

+50
-7
lines changed

bin/router/src/pipeline/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub async fn execute_pipeline(
150150
let operation_name = normalize_payload.operation_for_plan.name.as_ref();
151151

152152
shared_state.usage_agent.as_ref().and_then(|usage_agent| {
153-
shared_state.router_config.usage.as_ref().map(|usage_config| {
153+
shared_state.router_config.usage_reporting.as_ref().map(|usage_config| {
154154
usage::send_usage_report(
155155
supergraph.schema.clone(),
156156
start,

bin/router/src/pipeline/usage.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{sync::Arc, time::{Duration, Instant, SystemTime, UNIX_EPOCH}};
33
use async_trait::async_trait;
44
use graphql_parser::schema::Document;
55
use hive_console_sdk::agent::{ExecutionReport, UsageAgent};
6-
use hive_router_config::{HiveRouterConfig, usage::UsageConfig};
6+
use hive_router_config::{HiveRouterConfig, usage_reporting::UsageReportingConfig};
77
use hive_router_plan_executor::execution::plan::PlanExecutionOutput;
88
use ntex::web::HttpRequest;
99
use rand::Rng;
@@ -14,7 +14,7 @@ use crate::background_tasks::BackgroundTask;
1414
pub fn from_config(
1515
router_config: &HiveRouterConfig,
1616
) -> Option<UsageAgent> {
17-
router_config.usage.as_ref().map(|usage_config| {
17+
router_config.usage_reporting.as_ref().map(|usage_config| {
1818
let flush_interval = Duration::from_secs(usage_config.flush_interval);
1919
hive_console_sdk::agent::UsageAgent::new(
2020
usage_config.token.clone(),
@@ -36,7 +36,7 @@ pub fn send_usage_report(
3636
operation_name: Option<&String>,
3737
operation_body: &str,
3838
usage_agent: &UsageAgent,
39-
usage_config: &UsageConfig,
39+
usage_config: &UsageReportingConfig,
4040
execution_result: &PlanExecutionOutput,
4141
) {
4242
let mut rng = rand::rng();

docs/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
|[**query\_planner**](#query_planner)|`object`|Query planning configuration.<br/>Default: `{"allow_expose":false,"timeout":"10s"}`<br/>||
1515
|[**supergraph**](#supergraph)|`object`|Configuration for the Federation supergraph source. By default, the router will use a local file-based supergraph source (`./supergraph.graphql`).<br/>||
1616
|[**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/>||
17+
|[**usage\_reporting**](#usage_reporting)|`object`, `null`|Configuration for usage reporting to GraphQL Hive.<br/>|yes|
1718

1819
**Additional Properties:** not allowed
1920
**Example**
@@ -83,6 +84,7 @@ traffic_shaping:
8384
dedupe_enabled: true
8485
max_connections_per_host: 100
8586
pool_idle_timeout_seconds: 50
87+
usage_reporting: null
8688

8789
```
8890
@@ -1740,4 +1742,45 @@ pool_idle_timeout_seconds: 50
17401742
17411743
```
17421744

1745+
<a name="usage_reporting"></a>
1746+
## usage\_reporting: object,null
1747+
1748+
Configuration for usage reporting to GraphQL Hive.
1749+
1750+
1751+
**Properties**
1752+
1753+
|Name|Type|Description|Required|
1754+
|----|----|-----------|--------|
1755+
|**accept\_invalid\_certs**|`boolean`|Accepts invalid SSL certificates<br/>Default: false<br/>Default: `false`<br/>|no|
1756+
|**buffer\_size**|`integer`|A maximum number of operations to hold in a buffer before sending to Hive Console<br/>Default: 1000<br/>Default: `1000`<br/>Format: `"uint"`<br/>Minimum: `0`<br/>|no|
1757+
|**client\_name\_header**|`string`|Default: `"graphql-client-name"`<br/>|no|
1758+
|**client\_version\_header**|`string`|Default: `"graphql-client-version"`<br/>|no|
1759+
|**connect\_timeout**|`integer`|A timeout for only the connect phase of a request to Hive Console<br/>Unit: seconds<br/>Default: 5 (s)<br/>Default: `5`<br/>Format: `"uint64"`<br/>Minimum: `0`<br/>|no|
1760+
|**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|
1761+
|[**exclude**](#usage_reportingexclude)|`string[]`|A list of operations (by name) to be ignored by Hive.<br/>Default: <br/>|no|
1762+
|**flush\_interval**|`integer`|Frequency of flushing the buffer to the server<br/>Default: 5 seconds<br/>Default: `5`<br/>Format: `"uint64"`<br/>Minimum: `0`<br/>|no|
1763+
|**request\_timeout**|`integer`|A timeout for the entire request to Hive Console<br/>Unit: seconds<br/>Default: 15 (s)<br/>Default: `15`<br/>Format: `"uint64"`<br/>Minimum: `0`<br/>|no|
1764+
|**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|
1765+
|**target\_id**|`string`|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/>|yes|
1766+
|**token**|`string`|Your [Registry Access Token](https://the-guild.dev/graphql/hive/docs/management/targets#registry-access-tokens) with write permission.<br/>|yes|
1767+
1768+
**Additional Properties:** not allowed
1769+
**Example**
1770+
1771+
```yaml
1772+
{}
1773+
1774+
```
1775+
1776+
<a name="usage_reportingexclude"></a>
1777+
### usage\_reporting\.exclude\[\]: array
1778+
1779+
A list of operations (by name) to be ignored by Hive.
1780+
Example: ["IntrospectionQuery", "MeQuery"]
1781+
1782+
1783+
**Items**
1784+
1785+
**Item Type:** `string`
17431786

lib/router-config/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub mod primitives;
99
pub mod query_planner;
1010
pub mod supergraph;
1111
pub mod traffic_shaping;
12-
pub mod usage;
12+
pub mod usage_reporting;
1313

1414
use config::{Config, Environment, File, FileFormat, FileSourceFile};
1515
use schemars::JsonSchema;
@@ -72,7 +72,7 @@ pub struct HiveRouterConfig {
7272
pub override_subgraph_urls: override_subgraph_urls::OverrideSubgraphUrlsConfig,
7373
/// Configuration for usage reporting to GraphQL Hive.
7474
#[serde(default)]
75-
pub usage: Option<usage::UsageConfig>,
75+
pub usage_reporting: Option<usage_reporting::UsageReportingConfig>,
7676
}
7777

7878
#[derive(Debug, thiserror::Error)]

lib/router-config/src/usage.rs renamed to lib/router-config/src/usage_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
33

44
#[derive(Debug, Deserialize, Serialize, JsonSchema, Clone)]
55
#[serde(deny_unknown_fields)]
6-
pub struct UsageConfig {
6+
pub struct UsageReportingConfig {
77
/// Your [Registry Access Token](https://the-guild.dev/graphql/hive/docs/management/targets#registry-access-tokens) with write permission.
88
pub token: String,
99
/// 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.

0 commit comments

Comments
 (0)