1
1
import "dotenv/config" ;
2
- import { CredentialsMethod , FgaApiValidationError , OpenFgaClient , TelemetryAttribute , TelemetryConfiguration } from "@openfga/sdk" ;
2
+ import { CredentialsMethod , FgaApiValidationError , OpenFgaClient , TelemetryAttribute , TelemetryConfiguration , TelemetryMetric } from "@openfga/sdk" ;
3
3
4
4
let credentials ;
5
5
if ( process . env . FGA_CLIENT_ID ) {
@@ -14,27 +14,40 @@ if (process.env.FGA_CLIENT_ID) {
14
14
} ;
15
15
}
16
16
17
- // define desired telemetry options
18
- const counterCredentialsRequestAttributes = new Set ( [
19
- TelemetryAttribute . HttpHost ,
20
- TelemetryAttribute . HttpResponseStatusCode ,
21
- TelemetryAttribute . UserAgentOriginal ,
22
- TelemetryAttribute . FgaClientRequestClientId
23
- ] ) ;
24
-
25
- const histogramRequestDurationAttributes = TelemetryConfiguration . validAttriburtes ;
26
- const histogramQueryDurationAttributes = TelemetryConfiguration . validAttriburtes ;
27
-
28
17
const telemetryConfig = {
29
18
metrics : {
30
- counterCredentialsRequest : {
31
- attributes : counterCredentialsRequestAttributes
19
+ [ TelemetryMetric . CounterCredentialsRequest ] : {
20
+ attributes : new Set ( [
21
+ TelemetryAttribute . UrlScheme ,
22
+ TelemetryAttribute . UserAgentOriginal ,
23
+ TelemetryAttribute . HttpRequestMethod ,
24
+ TelemetryAttribute . FgaClientRequestClientId ,
25
+ TelemetryAttribute . FgaClientRequestStoreId ,
26
+ TelemetryAttribute . FgaClientRequestModelId ,
27
+ TelemetryAttribute . HttpRequestResendCount ,
28
+ ] )
32
29
} ,
33
- histogramRequestDuration : {
34
- attributes : histogramRequestDurationAttributes
30
+ [ TelemetryMetric . HistogramRequestDuration ] : {
31
+ attributes : new Set ( [
32
+ TelemetryAttribute . HttpResponseStatusCode ,
33
+ TelemetryAttribute . UserAgentOriginal ,
34
+ TelemetryAttribute . FgaClientRequestMethod ,
35
+ TelemetryAttribute . FgaClientRequestClientId ,
36
+ TelemetryAttribute . FgaClientRequestStoreId ,
37
+ TelemetryAttribute . FgaClientRequestModelId ,
38
+ TelemetryAttribute . HttpRequestResendCount ,
39
+ ] )
35
40
} ,
36
- histogramQueryDuration : {
37
- attributes : histogramQueryDurationAttributes
41
+ [ TelemetryMetric . HistogramQueryDuration ] : {
42
+ attributes : new Set ( [
43
+ TelemetryAttribute . HttpResponseStatusCode ,
44
+ TelemetryAttribute . UserAgentOriginal ,
45
+ TelemetryAttribute . FgaClientRequestMethod ,
46
+ TelemetryAttribute . FgaClientRequestClientId ,
47
+ TelemetryAttribute . FgaClientRequestStoreId ,
48
+ TelemetryAttribute . FgaClientRequestModelId ,
49
+ TelemetryAttribute . HttpRequestResendCount ,
50
+ ] )
38
51
}
39
52
}
40
53
} ;
0 commit comments