-
Notifications
You must be signed in to change notification settings - Fork 122
docs(js-sdk): document agent configuration options #7269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
n1ru4l
wants to merge
2
commits into
main
Choose a base branch
from
docs-js-sdk-agent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ export interface AgentOptions { | |
| maxRetries?: number; | ||
| /** | ||
| * 200 by default | ||
| * @deprecated This is no longer used. | ||
|
||
| */ | ||
| minTimeout?: number; | ||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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. | ||
|
|
@@ -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 | ||
|
|
@@ -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. | ||
|
|
@@ -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 | ||
|
|
@@ -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` | ||
n1ru4l marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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. | ||
n1ru4l marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ###### `sendInterval` | ||
|
|
||
| - Type: `boolean` | ||
n1ru4l marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - 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 | ||
|
||
| */ | ||
| 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 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.