Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

- feat: Add APIExecutor for calling arbitrary API endpoints (#298), thanks @Abishek-Newar
- 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
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
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