diff --git a/packages/client-sdk-nodejs/src/config/middleware/impl/experimental-metrics-middleware.ts b/packages/client-sdk-nodejs/src/config/middleware/impl/experimental-metrics-middleware.ts index 2163528ca..2123a88cb 100644 --- a/packages/client-sdk-nodejs/src/config/middleware/impl/experimental-metrics-middleware.ts +++ b/packages/client-sdk-nodejs/src/config/middleware/impl/experimental-metrics-middleware.ts @@ -108,7 +108,7 @@ export abstract class ExperimentalMetricsMiddlewareRequestHandler onRequestBody(request: MiddlewareMessage): Promise { this.requestSize = request.messageLength(); - this.requestType = request.constructor.name; + this.requestType = request._grpcMessage.constructor.name; this.requestBodyTime = new Date().getTime(); return Promise.resolve(request); } diff --git a/packages/client-sdk-nodejs/src/config/middleware/middleware.ts b/packages/client-sdk-nodejs/src/config/middleware/middleware.ts index e8d1291d4..63e80dbb8 100644 --- a/packages/client-sdk-nodejs/src/config/middleware/middleware.ts +++ b/packages/client-sdk-nodejs/src/config/middleware/middleware.ts @@ -29,7 +29,10 @@ export class MiddlewareMessage { } messageLength(): number { - return this._grpcMessage.serializeBinary().length; + if (this._grpcMessage !== null && this._grpcMessage !== undefined) { + return this._grpcMessage.serializeBinary().length; + } + return 0; } } diff --git a/packages/client-sdk-nodejs/src/index.ts b/packages/client-sdk-nodejs/src/index.ts index 2023460d5..6635552ff 100644 --- a/packages/client-sdk-nodejs/src/index.ts +++ b/packages/client-sdk-nodejs/src/index.ts @@ -200,6 +200,7 @@ export { export {ExperimentalRequestLoggingMiddleware} from './config/middleware/experimental-request-logging-middleware'; export {ExperimentalMetricsCsvMiddleware} from './config/middleware/experimental-metrics-csv-middleware'; +export {ExperimentalMetricsLoggingMiddleware} from './config/middleware/experimental-metrics-logging-middleware'; export {ExampleAsyncMiddleware} from './config/middleware/example-async-middleware'; export {