@@ -296,7 +296,6 @@ func (e *clickhouseLogsExporter) pushToClickhouse(ctx context.Context, ld plog.L
296
296
var insertLogsStmtV2 driver.Batch
297
297
var insertResourcesStmtV2 driver.Batch
298
298
var statement driver.Batch
299
- var tagStatement driver.Batch
300
299
var tagStatementV2 driver.Batch
301
300
var attributeKeysStmt driver.Batch
302
301
var resourceKeysStmt driver.Batch
@@ -311,9 +310,6 @@ func (e *clickhouseLogsExporter) pushToClickhouse(ctx context.Context, ld plog.L
311
310
if statement != nil {
312
311
_ = statement .Abort ()
313
312
}
314
- if tagStatement != nil {
315
- _ = tagStatement .Abort ()
316
- }
317
313
if insertLogsStmtV2 != nil {
318
314
_ = insertLogsStmtV2 .Abort ()
319
315
}
@@ -342,11 +338,6 @@ func (e *clickhouseLogsExporter) pushToClickhouse(ctx context.Context, ld plog.L
342
338
}
343
339
}
344
340
345
- tagStatement , err = e .db .PrepareBatch (ctx , fmt .Sprintf ("INSERT INTO %s.%s" , databaseName , DISTRIBUTED_TAG_ATTRIBUTES ), driver .WithReleaseConnection ())
346
- if err != nil {
347
- return fmt .Errorf ("PrepareTagBatch:%w" , err )
348
- }
349
-
350
341
tagStatementV2 , err = e .db .PrepareBatch (ctx , fmt .Sprintf ("INSERT INTO %s.%s" , databaseName , DISTRIBUTED_TAG_ATTRIBUTES_V2 ), driver .WithReleaseConnection ())
351
342
if err != nil {
352
343
return fmt .Errorf ("PrepareTagBatchV2:%w" , err )
@@ -385,7 +376,7 @@ func (e *clickhouseLogsExporter) pushToClickhouse(ctx context.Context, ld plog.L
385
376
}
386
377
resourceJson := string (serializedRes )
387
378
388
- err = e .addAttrsToTagStatement (tagStatement , tagStatementV2 , attributeKeysStmt , resourceKeysStmt , utils .TagTypeResource , resources , e .useNewSchema , shouldSkipKeys )
379
+ err = e .addAttrsToTagStatement (tagStatementV2 , attributeKeysStmt , resourceKeysStmt , utils .TagTypeResource , resources , e .useNewSchema , shouldSkipKeys )
389
380
if err != nil {
390
381
return err
391
382
}
@@ -401,7 +392,7 @@ func (e *clickhouseLogsExporter) pushToClickhouse(ctx context.Context, ld plog.L
401
392
scopeAttributes := attributesToSlice (scope .Attributes (), true )
402
393
scopeMap := attributesToMap (scope .Attributes (), true )
403
394
404
- err := e .addAttrsToTagStatement (tagStatement , tagStatementV2 , attributeKeysStmt , resourceKeysStmt , utils .TagTypeScope , scopeAttributes , e .useNewSchema , shouldSkipKeys )
395
+ err := e .addAttrsToTagStatement (tagStatementV2 , attributeKeysStmt , resourceKeysStmt , utils .TagTypeScope , scopeAttributes , e .useNewSchema , shouldSkipKeys )
405
396
if err != nil {
406
397
return err
407
398
}
@@ -445,7 +436,7 @@ func (e *clickhouseLogsExporter) pushToClickhouse(ctx context.Context, ld plog.L
445
436
attributes := attributesToSlice (r .Attributes (), false )
446
437
attrsMap := attributesToMap (r .Attributes (), false )
447
438
448
- err = e .addAttrsToTagStatement (tagStatement , tagStatementV2 , attributeKeysStmt , resourceKeysStmt , utils .TagTypeAttribute , attributes , e .useNewSchema , shouldSkipKeys )
439
+ err = e .addAttrsToTagStatement (tagStatementV2 , attributeKeysStmt , resourceKeysStmt , utils .TagTypeAttribute , attributes , e .useNewSchema , shouldSkipKeys )
449
440
if err != nil {
450
441
return err
451
442
}
@@ -581,20 +572,6 @@ func (e *clickhouseLogsExporter) pushToClickhouse(ctx context.Context, ld plog.L
581
572
stats .RecordWithTags (ctx , []tag.Mutator {tag .Upsert (usage .TagTenantKey , k ), tag .Upsert (usage .TagExporterIdKey , e .id .String ())}, ExporterSigNozSentLogRecords .M (int64 (v .Count )), ExporterSigNozSentLogRecordsBytes .M (int64 (v .Size )))
582
573
}
583
574
584
- // push tag attributes
585
- tagWriteStart := time .Now ()
586
- err = tagStatement .Send ()
587
- stats .RecordWithTags (ctx ,
588
- []tag.Mutator {
589
- tag .Upsert (exporterKey , pipeline .SignalLogs .String ()),
590
- tag .Upsert (tableKey , DISTRIBUTED_TAG_ATTRIBUTES ),
591
- },
592
- writeLatencyMillis .M (int64 (time .Since (tagWriteStart ).Milliseconds ())),
593
- )
594
- if err != nil {
595
- return err
596
- }
597
-
598
575
return err
599
576
}
600
577
}
@@ -667,7 +644,6 @@ func (e *clickhouseLogsExporter) addAttrsToAttributeKeysStatement(
667
644
}
668
645
669
646
func (e * clickhouseLogsExporter ) addAttrsToTagStatement (
670
- statement driver.Batch ,
671
647
tagStatementV2 driver.Batch ,
672
648
attributeKeysStmt driver.Batch ,
673
649
resourceKeysStmt driver.Batch ,
@@ -683,20 +659,8 @@ func (e *clickhouseLogsExporter) addAttrsToTagStatement(
683
659
e .logger .Debug ("key has been skipped" , zap .String ("key" , key ))
684
660
continue
685
661
}
686
- err := statement .Append (
687
- time .Now (),
688
- v ,
689
- tagType ,
690
- "string" ,
691
- attrs .StringValues [i ],
692
- nil ,
693
- nil ,
694
- )
695
- if err != nil {
696
- return fmt .Errorf ("could not append string attribute to batch, err: %w" , err )
697
- }
698
662
e .addAttrsToAttributeKeysStatement (attributeKeysStmt , resourceKeysStmt , v , tagType , utils .TagDataTypeString )
699
- err = tagStatementV2 .Append (
663
+ err : = tagStatementV2 .Append (
700
664
unixMilli ,
701
665
v ,
702
666
tagType ,
@@ -709,31 +673,14 @@ func (e *clickhouseLogsExporter) addAttrsToTagStatement(
709
673
}
710
674
}
711
675
712
- intTypeName := "int64"
713
- if useNewSchema {
714
- intTypeName = "float64"
715
- }
716
676
for i , v := range attrs .IntKeys {
717
677
key := utils .MakeKeyForAttributeKeys (v , tagType , utils .TagDataTypeNumber )
718
678
if _ , ok := shouldSkipKeys [key ]; ok {
719
679
e .logger .Debug ("key has been skipped" , zap .String ("key" , key ))
720
680
continue
721
681
}
722
-
723
- err := statement .Append (
724
- time .Now (),
725
- v ,
726
- tagType ,
727
- intTypeName ,
728
- nil ,
729
- nil ,
730
- attrs .IntValues [i ],
731
- )
732
- if err != nil {
733
- return fmt .Errorf ("could not append number attribute to batch, err: %w" , err )
734
- }
735
682
e .addAttrsToAttributeKeysStatement (attributeKeysStmt , resourceKeysStmt , v , tagType , utils .TagDataTypeNumber )
736
- err = tagStatementV2 .Append (
683
+ err : = tagStatementV2 .Append (
737
684
unixMilli ,
738
685
v ,
739
686
tagType ,
@@ -751,20 +698,8 @@ func (e *clickhouseLogsExporter) addAttrsToTagStatement(
751
698
e .logger .Debug ("key has been skipped" , zap .String ("key" , key ))
752
699
continue
753
700
}
754
- err := statement .Append (
755
- time .Now (),
756
- v ,
757
- tagType ,
758
- "float64" ,
759
- nil ,
760
- nil ,
761
- attrs .FloatValues [i ],
762
- )
763
- if err != nil {
764
- return fmt .Errorf ("could not append number attribute to batch, err: %w" , err )
765
- }
766
701
e .addAttrsToAttributeKeysStatement (attributeKeysStmt , resourceKeysStmt , v , tagType , utils .TagDataTypeNumber )
767
- err = tagStatementV2 .Append (
702
+ err : = tagStatementV2 .Append (
768
703
unixMilli ,
769
704
v ,
770
705
tagType ,
@@ -782,20 +717,9 @@ func (e *clickhouseLogsExporter) addAttrsToTagStatement(
782
717
e .logger .Debug ("key has been skipped" , zap .String ("key" , key ))
783
718
continue
784
719
}
785
- err := statement .Append (
786
- time .Now (),
787
- v ,
788
- tagType ,
789
- "bool" ,
790
- nil ,
791
- nil ,
792
- nil ,
793
- )
794
- if err != nil {
795
- return fmt .Errorf ("could not append bool attribute to batch, err: %w" , err )
796
- }
720
+
797
721
e .addAttrsToAttributeKeysStatement (attributeKeysStmt , resourceKeysStmt , v , tagType , utils .TagDataTypeBool )
798
- err = tagStatementV2 .Append (
722
+ err : = tagStatementV2 .Append (
799
723
unixMilli ,
800
724
v ,
801
725
tagType ,
0 commit comments