2424import org .apache .iotdb .db .pipe .agent .task .subtask .sink .PipeSinkSubtask ;
2525import org .apache .iotdb .metrics .AbstractMetricService ;
2626import org .apache .iotdb .metrics .metricsets .IMetricSet ;
27+ import org .apache .iotdb .metrics .type .Histogram ;
2728import org .apache .iotdb .metrics .type .Rate ;
2829import org .apache .iotdb .metrics .utils .MetricLevel ;
2930import org .apache .iotdb .metrics .utils .MetricType ;
@@ -57,6 +58,7 @@ public void bindTo(final AbstractMetricService metricService) {
5758
5859 private void createMetrics (final String taskID ) {
5960 createRate (taskID );
61+ createHistogram (taskID );
6062 }
6163
6264 private void createRate (final String taskID ) {
@@ -73,6 +75,38 @@ private void createRate(final String taskID) {
7375 String .valueOf (connector .getCreationTime ())));
7476 }
7577
78+ private void createHistogram (final String taskID ) {
79+ final PipeSinkSubtask connector = connectorMap .get (taskID );
80+
81+ final Histogram schemaBatchSizeHistogram =
82+ metricService .getOrCreateHistogram (
83+ Metric .PIPE_SCHEMA_BATCH_SIZE .toString (),
84+ MetricLevel .IMPORTANT ,
85+ Tag .NAME .toString (),
86+ connector .getAttributeSortedString (),
87+ Tag .CREATION_TIME .toString (),
88+ String .valueOf (connector .getCreationTime ()));
89+ connector .setSchemaBatchSizeHistogram (schemaBatchSizeHistogram );
90+
91+ final Histogram schemaBatchTimeIntervalHistogram =
92+ metricService .getOrCreateHistogram (
93+ Metric .PIPE_SCHEMA_BATCH_TIME_COST .toString (),
94+ MetricLevel .IMPORTANT ,
95+ Tag .NAME .toString (),
96+ connector .getAttributeSortedString (),
97+ Tag .CREATION_TIME .toString (),
98+ String .valueOf (connector .getCreationTime ()));
99+ connector .setSchemaBatchTimeIntervalHistogram (schemaBatchTimeIntervalHistogram );
100+
101+ final Histogram schemaBatchEventSizeHistogram =
102+ metricService .getOrCreateHistogram (
103+ Metric .PIPE_CONNECTOR_BATCH_SIZE .toString (),
104+ MetricLevel .IMPORTANT ,
105+ Tag .NAME .toString (),
106+ connector .getAttributeSortedString ());
107+ connector .setEventSizeHistogram (schemaBatchEventSizeHistogram );
108+ }
109+
76110 @ Override
77111 public void unbindFrom (final AbstractMetricService metricService ) {
78112 ImmutableSet .copyOf (connectorMap .keySet ()).forEach (this ::deregister );
@@ -84,6 +118,7 @@ public void unbindFrom(final AbstractMetricService metricService) {
84118
85119 private void removeMetrics (final String taskID ) {
86120 removeRate (taskID );
121+ removeHistogram (taskID );
87122 }
88123
89124 private void removeRate (final String taskID ) {
@@ -99,6 +134,29 @@ private void removeRate(final String taskID) {
99134 schemaRateMap .remove (taskID );
100135 }
101136
137+ private void removeHistogram (final String taskID ) {
138+ final PipeSinkSubtask connector = connectorMap .get (taskID );
139+ metricService .remove (
140+ MetricType .HISTOGRAM ,
141+ Metric .PIPE_SCHEMA_BATCH_SIZE .toString (),
142+ Tag .NAME .toString (),
143+ connector .getAttributeSortedString (),
144+ Tag .CREATION_TIME .toString (),
145+ String .valueOf (connector .getCreationTime ()));
146+ metricService .remove (
147+ MetricType .HISTOGRAM ,
148+ Metric .PIPE_SCHEMA_BATCH_TIME_COST .toString (),
149+ Tag .NAME .toString (),
150+ connector .getAttributeSortedString (),
151+ Tag .CREATION_TIME .toString (),
152+ String .valueOf (connector .getCreationTime ()));
153+ metricService .remove (
154+ MetricType .HISTOGRAM ,
155+ Metric .PIPE_CONNECTOR_BATCH_SIZE .toString (),
156+ Tag .NAME .toString (),
157+ connector .getAttributeSortedString ());
158+ }
159+
102160 //////////////////////////// Register & deregister (pipe integration) ////////////////////////////
103161
104162 public void register (@ NonNull final PipeSinkSubtask pipeSinkSubtask ) {
0 commit comments