Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/libraries/core/src/client/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface AgentOptions {
maxRetries?: number;
/**
* 200 by default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would even remove the description if it has no effect at all today.

* @deprecated This is no longer used.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Do we have an alternative field or something related? (if so, worth documenting it)

*/
minTimeout?: number;
/**
Expand Down
82 changes: 75 additions & 7 deletions packages/web/docs/src/content/api-reference/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ Refer to the
for complete list of options and configurations you can pass to the Hive JavaScript Client of
choice.

#### Client Information
#### Usage reporting

##### Client Information

By default, the client information is retrieved by looking up the `x-graphql-client-name` and
`x-graphql-client-version` headers in the HTTP request. For operations executed via the
Expand Down Expand Up @@ -82,9 +84,9 @@ useHive({
The context object is the context object as used within the GraphQL execution. Depending on your
server framework and GraphQL protocol, the context object may contain different properties.

We recommend to always try to safely decode the context.
We recommend to safely decode the context in order to avoid runtime errors.

#### Excluding Operations
##### Excluding Operations

You can pass a custom `exclude` array to the `HivePluginOptions` to ignore specific operations from
being reported to Hive.
Expand All @@ -97,9 +99,9 @@ useHive({
})
```

#### Sampling
##### Sampling

##### Basic sampling
###### Basic sampling

With `sampleRate` option, you're able to control the sampling rate of the usage reporting. Setting
it to `0.5` will result in 50% of the operations being sent to Hive. There is no guarantee that
Expand All @@ -116,7 +118,7 @@ useHive({
})
```

##### Dynamic sampling
###### Dynamic sampling

GraphQL Hive client accepts a function that returns a number between 0 and 1. This allows you to
implement dynamic sampling based on the operation's context.
Expand Down Expand Up @@ -151,7 +153,7 @@ useHive({
})
```

##### At-least-once sampling
###### At-least-once sampling

If you want to make sure that every operation is reported at least once, you can use the
`atLeastOnceSampler`. Every operation is reported at least once, but every next occurrence is
Expand Down Expand Up @@ -321,6 +323,72 @@ useHive({

</Tabs>

##### Agent

The agent collects and schedules usage reporting call to the Hive Console usage reporting service.
The configuration can be customized.

###### `maxRetries`

- Type: `boolean`
- Default: `5`

Configure the maximum amount of retries per usage reporting batch before dropping the reporting
attempts.

###### `maxSize`

The maximum batch size of usage reports before sending the batch.

###### `sendInterval`

- Type: `boolean`
- Default: `10_000`

The amount of time after which a pending usage reporting batch should be sent in case before the
`maxSize` amount is reached.

###### `fetch`

- Type: [`Fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch)
- Default: `fetch`

Provide a custom WHATWG `fetch` implementation

###### `logger`

- Type: [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console)
- Default: `globalThis.console`

Console object to use for logging info, errors and debug information.

###### `circuitBreaker`

- Type: `AgentCircuitBreakerConfiguration`
- Default:
```js
{
/**
* Percentage after what the circuit breaker should kick in.
* Default: 50
*/
errorThresholdPercentage: 50,
/**
* Count of requests before starting evaluating.
* Default: 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment for volumeThreshold's default value is incorrect. It should be 10 to match the code and the value provided.

     * Default: 10

*/
volumeThreshold: 10,
/**
* After what time the circuit breaker is attempting to retry sending requests in milliseconds
* Default: 30_000
*/
resetTimeout: 30_000,
}
```

Configure the curcuit breaker for temporarily suspending sending usage reports in case of network
issues or outages to avoid exhausting the service from being overwhelmed with failing HTTP requests.

#### Persisted Documents

Hive client supports resolving persisted documents. For getting started please refer to our
Expand Down
Loading