Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Changelog


## [Unreleased](https://github.com/openfga/js-sdk/compare/v0.9.2...HEAD)
## [Unreleased](https://github.com/openfga/js-sdk/compare/v0.9.3...HEAD)

## v0.9.3

### [v0.9.3](https://github.com/openfga/js-sdk/compare/v0.9.2...v0.9.3) (2026-02-25)

- feat: Add APIExecutor for calling arbitrary API endpoints (#298), thanks @Abishek-Newar
Comment thread
SoulPancake marked this conversation as resolved.
Outdated
- fix: use current SDK version in telemetry meter (#335)
- fix: disable httprequestduration metric by default to avoid high cardinality (#344)

## v0.9.2

Expand Down
4 changes: 2 additions & 2 deletions constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
/**
* Version of the OpenFGA JavaScript SDK.
*/
const SdkVersion = "0.9.2";
const SdkVersion = "0.9.3";

/**
* User agent used in HTTP requests.
*/
const UserAgent = "openfga-sdk js/0.9.2";
const UserAgent = "openfga-sdk js/0.9.3";

/**
* Example API domain for documentation/tests.
Expand Down
24 changes: 18 additions & 6 deletions docs/opentelemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ In cases when metrics events are sent, they will not be viewable outside of infr

### Supported Metrics

| Metric Name | Type | Enabled by default | Description |
|---------------------------------|-----------|--------------------|---------------------------------------------------------------------------------|
| `fga-client.request.duration` | Histogram | Yes | The total request time for FGA requests |
| `fga-client.query.duration` | Histogram | Yes | The amount of time the FGA server took to process the request |
|` fga-client.credentials.request`| Counter | Yes | The total number of times a new token was requested when using ClientCredentials|
| Metric Name | Type | Enabled by default | Description |
|------------------------------------|-----------|--------------------|---------------------------------------------------------------------------------|
| `fga-client.request.duration` | Histogram | Yes | The total request time for FGA requests |
| `fga-client.query.duration` | Histogram | Yes | The amount of time the FGA server took to process the request |
| `fga-client.http_request.duration` | Histogram | No | The time for a single HTTP request to complete (including retries) |
|` fga-client.credentials.request` | Counter | Yes | The total number of times a new token was requested when using ClientCredentials|

### Supported attributes

Expand Down Expand Up @@ -42,6 +43,8 @@ Not all attributes are enabled by default.

Some attributes, like `fga-client.user` have been disabled by default due to their high cardinality, which may result in very high costs when using some SaaS metric collectors. If you expect high cardinality for a specific attribute, you can disable it by updating the telemetry configuration accordingly.

Similarly, the `fga-client.http_request.duration` metric is disabled by default because it tracks every individual HTTP request (including each retry attempt), which can generate a high volume of telemetry data and result in increased costs. You can enable it explicitly in your configuration if you need granular per-request metrics.

If your configuration does not specify a given metric, the default attributes for that metric will be used.


Expand Down Expand Up @@ -81,7 +84,16 @@ const telemetryConfig = {
TelemetryAttribute.FgaClientRequestModelId,
TelemetryAttribute.HttpRequestResendCount,
])
}
},
// Optional: Enable per-HTTP-request metrics (disabled by default due to high cardinality)
// histogramHttpRequestDuration: {
// attributes: new Set([
// TelemetryAttribute.HttpHost,
// TelemetryAttribute.HttpResponseStatusCode,
// TelemetryAttribute.HttpRequestMethod,
// TelemetryAttribute.UserAgentOriginal,
// ])
// }
}
};

Expand Down
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Steps
2. In the Example `package.json` change the `@openfga/sdk` dependency from a semver range like below
```json
"dependencies": {
"@openfga/sdk": "^0.9.2"
"@openfga/sdk": "^0.9.3"
}
```
to a `file:` reference like below
Expand Down
2 changes: 1 addition & 1 deletion example/example1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "node example1.mjs"
},
"dependencies": {
"@openfga/sdk": "^0.9.2"
"@openfga/sdk": "^0.9.3"
},
"engines": {
"node": ">=16.13.0"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openfga/sdk",
"version": "0.9.2",
"version": "0.9.3",
Comment thread
SoulPancake marked this conversation as resolved.
"description": "JavaScript and Node.js SDK for OpenFGA",
"author": "OpenFGA",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion telemetry/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export class TelemetryConfiguration implements TelemetryConfig {
[TelemetryMetric.CounterCredentialsRequest]: {attributes: TelemetryConfiguration.defaultAttributes},
[TelemetryMetric.HistogramRequestDuration]: {attributes: TelemetryConfiguration.defaultAttributes},
[TelemetryMetric.HistogramQueryDuration]: {attributes: TelemetryConfiguration.defaultAttributes},
[TelemetryMetric.HistogramHttpRequestDuration]: {attributes: TelemetryConfiguration.defaultAttributes},
// HistogramHttpRequestDuration is disabled by default
[TelemetryMetric.HistogramHttpRequestDuration]: undefined,
};
} else {
this.metrics = {
Expand Down
7 changes: 5 additions & 2 deletions tests/telemetry/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ describe("TelemetryConfiguration", () => {
expect(config.metrics?.counterCredentialsRequest?.attributes).toEqual(TelemetryConfiguration.defaultAttributes);
expect(config.metrics?.histogramQueryDuration?.attributes).toEqual(TelemetryConfiguration.defaultAttributes);
expect(config.metrics?.histogramRequestDuration?.attributes).toEqual(TelemetryConfiguration.defaultAttributes);
});
// histogramHttpRequestDuration is disabled by default due to high cardinality
expect(config.metrics?.histogramHttpRequestDuration?.attributes).toEqual(undefined);
});

test("should be undefined if empty object passed", () => {
const config = new TelemetryConfiguration({});

expect(config.metrics?.counterCredentialsRequest?.attributes).toEqual(undefined);
expect(config.metrics?.histogramQueryDuration?.attributes).toEqual(undefined);
expect(config.metrics?.histogramRequestDuration?.attributes).toEqual(undefined);
});
expect(config.metrics?.histogramHttpRequestDuration?.attributes).toEqual(undefined);
});
});
Loading