2525import org .apache .iotdb .db .pipe .agent .task .subtask .sink .PipeSinkSubtask ;
2626import org .apache .iotdb .metrics .AbstractMetricService ;
2727import org .apache .iotdb .metrics .metricsets .IMetricSet ;
28+ import org .apache .iotdb .metrics .type .Histogram ;
2829import org .apache .iotdb .metrics .type .Rate ;
2930import org .apache .iotdb .metrics .utils .MetricLevel ;
3031import 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 );
@@ -83,6 +117,7 @@ public void unbindFrom(final AbstractMetricService metricService) {
83117
84118 private void removeMetrics (final String taskID ) {
85119 removeRate (taskID );
120+ removeHistogram (taskID );
86121 }
87122
88123 private void removeRate (final String taskID ) {
@@ -98,6 +133,29 @@ private void removeRate(final String taskID) {
98133 schemaRateMap .remove (taskID );
99134 }
100135
136+ private void removeHistogram (final String taskID ) {
137+ final PipeSinkSubtask connector = connectorMap .get (taskID );
138+ metricService .remove (
139+ MetricType .HISTOGRAM ,
140+ Metric .PIPE_SCHEMA_BATCH_SIZE .toString (),
141+ Tag .NAME .toString (),
142+ connector .getAttributeSortedString (),
143+ Tag .CREATION_TIME .toString (),
144+ String .valueOf (connector .getCreationTime ()));
145+ metricService .remove (
146+ MetricType .HISTOGRAM ,
147+ Metric .PIPE_SCHEMA_BATCH_TIME_COST .toString (),
148+ Tag .NAME .toString (),
149+ connector .getAttributeSortedString (),
150+ Tag .CREATION_TIME .toString (),
151+ String .valueOf (connector .getCreationTime ()));
152+ metricService .remove (
153+ MetricType .HISTOGRAM ,
154+ Metric .PIPE_CONNECTOR_BATCH_SIZE .toString (),
155+ Tag .NAME .toString (),
156+ connector .getAttributeSortedString ());
157+ }
158+
101159 //////////////////////////// Register & deregister (pipe integration) ////////////////////////////
102160
103161 public void register (final PipeSinkSubtask pipeSinkSubtask ) {
0 commit comments