Skip to content

Commit d94a95e

Browse files
author
Adar Ovadia
committed
Node: add open telemetry client config
Signed-off-by: Adar Ovadia <[email protected]>
1 parent 96664d9 commit d94a95e

File tree

3 files changed

+77
-19
lines changed

3 files changed

+77
-19
lines changed

node/src/BaseClient.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -666,17 +666,17 @@ export interface BaseClientConfiguration {
666666
*
667667
* ### OpenTelemetry
668668
*
669-
* - **openTelemetryConfigs**: Use the `openTelemetryConfigs` property to specify the endpoint of the collector to export the measurments.
669+
* - **openTelemetryConfig**: Use the `openTelemetryConfig` property to specify the endpoint of the collector to export the measurments.
670670
* - **Collector EndPoint**: Set `collectorEndPoint` to specify the endpoint of the collector to export the measurments.
671-
* - **Span Flush Interval**: Set `spanFlushInterval` to specify the duration in milliseconds the data will be exported to the collector. If interval is not specified, 500 will be used.
672-
*
671+
* - **Span Flush Interval Ms**: Set `spanFlushIntervalMs` to specify the duration in milliseconds the data will be exported to the collector. If interval is not specified, 500 will be used.
672+
*
673673
* @example
674674
* ```typescript
675675
* const config: AdvancedBaseClientConfiguration = {
676676
* connectionTimeout: 5000, // 5 seconds
677677
* openTelemetryConfig: {
678678
* collectorEndPoint: 'https://127.0.0.1',
679-
* spanFlushInterval: 500,
679+
* spanFlushIntervalMs: 500,
680680
* },
681681
* };
682682
* ```
@@ -693,13 +693,16 @@ export interface AdvancedBaseClientConfiguration {
693693
* Configartion for OpenTelemetry if exits.
694694
*/
695695
openTelemetryConfig?: {
696+
/**
697+
* The client collector address to export the measurments.
698+
*/
696699
collectorEndPoint: string;
697700
/**
698701
* The duration in milliseconds the data will exported to the collector.
699702
* If interval is not specified, 500 will be used.
700703
*/
701-
spanFlushInterval?: number;
702-
}
704+
spanFlushIntervalMs?: number;
705+
};
703706
}
704707

705708
/**

node/tests/GlideClient.test.ts

+36-8
Original file line numberDiff line numberDiff line change
@@ -1069,14 +1069,42 @@ describe("GlideClient", () => {
10691069
);
10701070

10711071
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
1072-
"opentelemetry configs_%p",
1073-
async (protocol) => {
1074-
const client = GlideClient.createClient({
1075-
...getClientConfigurationOption(cluster.getAddresses(), protocol), advancedConfiguration:{openTelemetryConfig: {collectorEndPoint: "https://eifrah-aws.github.io/glide-for-redis", spanFlushInterval: 400}}},
1076-
// htttttps://eifrah-aws.github.io/glide-for-redis
1077-
)
1078-
},
1079-
);
1072+
"opentelemetry config_%p",
1073+
async (protocol) => {
1074+
GlideClient.createClient({
1075+
...getClientConfigurationOption(
1076+
cluster.getAddresses(),
1077+
protocol,
1078+
),
1079+
advancedConfiguration: {
1080+
openTelemetryConfig: {
1081+
collectorEndPoint: "https://valid-endpoint",
1082+
spanFlushIntervalMs: 400,
1083+
},
1084+
},
1085+
});
1086+
},
1087+
);
1088+
1089+
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
1090+
"opentelemetry config wrong parameter_%p",
1091+
async (protocol) => {
1092+
await expect(
1093+
GlideClient.createClient({
1094+
...getClientConfigurationOption(
1095+
cluster.getAddresses(),
1096+
protocol,
1097+
),
1098+
advancedConfiguration: {
1099+
openTelemetryConfig: {
1100+
collectorEndPoint: "wrong.endpoint",
1101+
spanFlushIntervalMs: 400,
1102+
},
1103+
},
1104+
}),
1105+
).rejects.toThrowError(/InvalidInput/i); // Ensure InvalidInput error
1106+
},
1107+
);
10801108

10811109
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
10821110
"function kill RW func %p",

node/tests/GlideClusterClient.test.ts

+32-5
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,39 @@ describe("GlideClusterClient", () => {
689689
);
690690

691691
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
692-
"opentelemetry configs_%p",
692+
"opentelemetry config_%p",
693693
async (protocol) => {
694-
const client = GlideClusterClient.createClient({
695-
...getClientConfigurationOption(cluster.getAddresses(), protocol), advancedConfiguration:{openTelemetryConfig: {collectorEndPoint: "https://eifrah-aws.github.io/glide-for-redis"}}},
696-
// htttttps://eifrah-aws.github.io/glide-for-redis
697-
)
694+
GlideClusterClient.createClient({
695+
...getClientConfigurationOption(
696+
cluster.getAddresses(),
697+
protocol,
698+
),
699+
advancedConfiguration: {
700+
openTelemetryConfig: {
701+
collectorEndPoint: "https://valid-endpoint",
702+
},
703+
},
704+
});
705+
},
706+
);
707+
708+
it.each([ProtocolVersion.RESP2, ProtocolVersion.RESP3])(
709+
"opentelemetry config wrong parameter_%p",
710+
async (protocol) => {
711+
await expect(
712+
GlideClusterClient.createClient({
713+
...getClientConfigurationOption(
714+
cluster.getAddresses(),
715+
protocol,
716+
),
717+
advancedConfiguration: {
718+
openTelemetryConfig: {
719+
collectorEndPoint: "wrong.endpoint",
720+
spanFlushIntervalMs: 400,
721+
},
722+
},
723+
}),
724+
).rejects.toThrowError(/InvalidInput/i); // Ensure InvalidInput error
698725
},
699726
);
700727

0 commit comments

Comments
 (0)