Skip to content

Commit cd3c5f1

Browse files
authored
feat: report SDK version in user-agent (#402)
Set user-agent with SDK version Signed-off-by: ItalyPaleAle <[email protected]> Signed-off-by: ItalyPaleAle <[email protected]>
1 parent 6ed6116 commit cd3c5f1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/implementation/Client/GRPCClient/GRPCClient.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { Settings } from "../../../utils/Settings.util";
2020
import { Logger } from "../../../logger/Logger";
2121
import GRPCClientSidecar from "./sidecar";
2222
import DaprClient from "../DaprClient";
23+
import { SDK_VERSION } from "../../../version";
2324

2425
export default class GRPCClient implements IClient {
2526
private isInitialized: boolean;
@@ -69,7 +70,9 @@ export default class GRPCClient implements IClient {
6970
}
7071

7172
private generateClient(host: string, port: string, credentials: grpc.ChannelCredentials): GrpcDaprClient {
72-
const client = new GrpcDaprClient(`${host}:${port}`, credentials);
73+
const client = new GrpcDaprClient(`${host}:${port}`, credentials, {
74+
"grpc.primary_user_agent": "dapr-sdk-js/v" + SDK_VERSION,
75+
});
7376
return client;
7477
}
7578

src/implementation/Client/HTTPClient/HTTPClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { Settings } from "../../../utils/Settings.util";
2121
import { THTTPExecuteParams } from "../../../types/http/THTTPExecuteParams.type";
2222
import { Logger } from "../../../logger/Logger";
2323
import HTTPClientSidecar from "./sidecar";
24+
import { SDK_VERSION } from "../../../version";
2425

2526
export default class HTTPClient implements IClient {
2627
private isInitialized: boolean;
@@ -157,6 +158,8 @@ export default class HTTPClient implements IClient {
157158
params.headers["dapr-api-token"] = this.options.daprApiToken;
158159
}
159160

161+
params.headers["user-agent"] = `dapr-sdk-js/v${SDK_VERSION} http/1`;
162+
160163
if (!params?.method) {
161164
params.method = "GET";
162165
}

0 commit comments

Comments
 (0)