File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -562,11 +562,8 @@ export class BasicClientSideCache extends ClientSideCacheProvider {
562562 CSC_RESULT . HIT ,
563563 client . _clientId ,
564564 ) ;
565- // Estimate bytes saved by avoiding network round-trip
566- // Note: JSON.stringify approximation; actual RESP wire size may differ (especially for Buffers)
567- const bytesEstimate = JSON . stringify ( cacheEntry . value ) . length ;
568565 OTelMetrics . instance . clientSideCacheMetrics . recordNetworkBytesSaved (
569- bytesEstimate ,
566+ cacheEntry . value ,
570567 client . _clientId ,
571568 ) ;
572569
Original file line number Diff line number Diff line change @@ -1278,7 +1278,7 @@ describe("OTel Metrics E2E", function () {
12781278 } ,
12791279 ) ;
12801280
1281- testUtils . testAll (
1281+ testUtils . testWithClient (
12821282 "should record redis.client.csc.network_saved" ,
12831283 async ( client ) => {
12841284 await client . ping ( ) ;
@@ -1311,24 +1311,13 @@ describe("OTel Metrics E2E", function () {
13111311 assert . strictEqual ( attributes [ OTEL_ATTRIBUTES . dbSystemName ] , "redis" ) ;
13121312 } ,
13131313 {
1314- client : {
1315- ...GLOBAL . SERVERS . OPEN ,
1316- clientOptions : {
1317- RESP : 3 ,
1318- clientSideCache : {
1319- ttl : 1000 ,
1320- maxEntries : 100 ,
1321- } ,
1322- } ,
1323- } ,
1324- cluster : {
1325- ...GLOBAL . CLUSTERS . OPEN ,
1326- clusterConfiguration : {
1327- RESP : 3 ,
1328- clientSideCache : {
1329- ttl : 1000 ,
1330- maxEntries : 100 ,
1331- } ,
1314+ ...GLOBAL . SERVERS . OPEN ,
1315+ skipTest : true ,
1316+ clientOptions : {
1317+ RESP : 3 ,
1318+ clientSideCache : {
1319+ ttl : 1000 ,
1320+ maxEntries : 100 ,
13321321 } ,
13331322 } ,
13341323 } ,
Original file line number Diff line number Diff line change @@ -338,14 +338,10 @@ class OTelClientSideCacheMetrics implements IOTelClientSideCacheMetrics {
338338 } ) ;
339339 }
340340
341- public recordNetworkBytesSaved ( bytes : number , clientId ?: string ) {
342- const clientAttributes = resolveClientAttributes ( clientId ) ;
343- this . #instruments. redisClientCscNetworkSaved . add ( bytes , {
344- ...this . #options. attributes ,
345- [ OTEL_ATTRIBUTES . serverAddress ] : clientAttributes ?. host ,
346- [ OTEL_ATTRIBUTES . serverPort ] : clientAttributes ?. port ?. toString ( ) ,
347- [ OTEL_ATTRIBUTES . dbClientConnectionPoolName ] : clientAttributes ?. clientId ,
348- } ) ;
341+ public recordNetworkBytesSaved ( value : unknown , clientId ?: string ) {
342+ // TODO: `redis.client.csc.network_saved` cannot be computed correctly here
343+ // because CSC stores transformed replies and does not retain raw byte size.
344+ // Implement this at a lower protocol/parsing layer where response bytes are known.
349345 }
350346}
351347
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ export class NoopClientSideCacheMetrics implements IOTelClientSideCacheMetrics {
8484 ) { }
8585
8686 recordNetworkBytesSaved (
87- _bytes : number ,
87+ _value : unknown ,
8888 _clientId ?: string
8989 ) { }
9090}
Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ export interface IOTelClientSideCacheMetrics {
304304 count ?: number ,
305305 clientId ?: string ,
306306 ) : void ;
307- recordNetworkBytesSaved ( bytes : number , clientId ?: string ) : void ;
307+ recordNetworkBytesSaved ( value : unknown , clientId ?: string ) : void ;
308308}
309309
310310export interface IOTelPubSubMetrics {
You can’t perform that action at this time.
0 commit comments