@@ -193,17 +193,11 @@ export default class RedisHelper {
193193 ) : Promise < void > {
194194 const timestamp = Date . now ( ) ;
195195
196- try {
197- await this . tsIncrBy ( key , value , timestamp , labels ) ;
198- } catch ( error ) {
199- if ( error instanceof Error && error . message . includes ( 'TSDB: key does not exist' ) ) {
200- this . logger . warn ( `TS key ${ key } does not exist, creating it...` ) ;
201- await this . tsCreateIfNotExists ( key , labels , retentionMs ) ;
202- await this . tsIncrBy ( key , value , timestamp , labels ) ;
203- } else {
204- throw error ;
205- }
206- }
196+ /**
197+ * Create key if not exists — then call increment
198+ */
199+ await this . tsCreateIfNotExists ( key , labels , retentionMs ) ;
200+ await this . tsIncrBy ( key , value , timestamp , labels ) ;
207201 }
208202
209203 /**
@@ -252,17 +246,11 @@ export default class RedisHelper {
252246 ) : Promise < void > {
253247 const timestamp = Date . now ( ) ;
254248
255- try {
256- await this . tsAdd ( key , value , timestamp , labels ) ;
257- } catch ( error ) {
258- if ( error instanceof Error && error . message . includes ( 'TSDB: key does not exist' ) ) {
259- this . logger . warn ( `TS key ${ key } does not exist, creating it...` ) ;
260- await this . tsCreateIfNotExists ( key , labels , retentionMs ) ;
261- await this . tsAdd ( key , value , timestamp , labels ) ;
262- } else {
263- throw error ;
264- }
265- }
249+ /**
250+ * Create key if not exists — then call increment
251+ */
252+ await this . tsCreateIfNotExists ( key , labels , retentionMs ) ;
253+ await this . tsAdd ( key , value , timestamp , labels ) ;
266254 }
267255
268256 /**
0 commit comments