diff --git a/pom.xml b/pom.xml
index 5ea787b3..ba105036 100644
--- a/pom.xml
+++ b/pom.xml
@@ -243,6 +243,11 @@
commons-lang3
3.11
+
+ io.micrometer
+ micrometer-observation
+ 1.17.0
+
commons-io
commons-io
@@ -252,19 +257,19 @@
org.junit.jupiter
junit-jupiter-api
- 5.7.0
+ 5.9.0
test
org.junit.jupiter
junit-jupiter-params
- 5.7.0
+ 5.9.0
test
org.junit.jupiter
junit-jupiter-engine
- 5.7.0
+ 5.9.0
test
@@ -279,6 +284,12 @@
2.2
test
+
+ io.micrometer
+ micrometer-tracing-integration-test
+ 1.7.0
+ test
+
org.projectlombok
lombok
diff --git a/src/main/java/ru/rt/restream/reindexer/ReindexerConfiguration.java b/src/main/java/ru/rt/restream/reindexer/ReindexerConfiguration.java
index f5d90685..4e544670 100644
--- a/src/main/java/ru/rt/restream/reindexer/ReindexerConfiguration.java
+++ b/src/main/java/ru/rt/restream/reindexer/ReindexerConfiguration.java
@@ -15,6 +15,7 @@
*/
package ru.rt.restream.reindexer;
+import io.micrometer.observation.ObservationRegistry;
import ru.rt.restream.reindexer.binding.Binding;
import ru.rt.restream.reindexer.binding.builtin.Builtin;
import ru.rt.restream.reindexer.binding.builtin.server.BuiltinServer;
@@ -58,6 +59,8 @@ public final class ReindexerConfiguration {
private SSLSocketFactory sslSocketFactory;
+ private ObservationRegistry observationRegistry = ObservationRegistry.NOOP;
+
private ReindexerConfiguration() {
}
@@ -176,6 +179,18 @@ public ReindexerConfiguration sslSocketFactory(SSLSocketFactory sslSocketFactory
return this;
}
+ /**
+ * Configure an {@link ObservationRegistry} to record connector's metrics and traces.
+ * Defaults to {@link ObservationRegistry#NOOP}.
+ *
+ * @param observationRegistry the {@link ObservationRegistry} to use
+ * @return the {@link ReindexerConfiguration} for further customizations
+ */
+ public ReindexerConfiguration observationRegistry(ObservationRegistry observationRegistry) {
+ this.observationRegistry = Objects.requireNonNull(observationRegistry, "observationRegistry cannot be null");
+ return this;
+ }
+
/**
* Build and return reindexer connector instance.
*
@@ -210,6 +225,7 @@ private Binding getBinding(String protocol, List uris) {
.urls(urls)
.allowUnlistedDataSource(allowUnlistedDataSource)
.sslSocketFactory(sslSocketFactory)
+ .observationRegistry(observationRegistry)
.build();
return new Cproto(dataSourceFactory, dataSourceConfig, connectionPoolSize, requestTimeout);
case "builtin":
diff --git a/src/main/java/ru/rt/restream/reindexer/binding/Binding.java b/src/main/java/ru/rt/restream/reindexer/binding/Binding.java
index 97848473..430609cb 100644
--- a/src/main/java/ru/rt/restream/reindexer/binding/Binding.java
+++ b/src/main/java/ru/rt/restream/reindexer/binding/Binding.java
@@ -83,6 +83,16 @@ public interface Binding {
int RESULTS_NEED_OUTPUT_RANK = 0x400;
+ int ADD_TX_ITEM = 26;
+
+ int UPDATE_QUERY_TX = 31;
+
+ int DELETE_QUERY_TX = 30;
+
+ int COMMIT_TX = 27;
+
+ int ROLLBACK_TX = 28;
+
/**
* Open or create a new namespace and indexes based on passed definition.
*
diff --git a/src/main/java/ru/rt/restream/reindexer/binding/cproto/CommandObservationContext.java b/src/main/java/ru/rt/restream/reindexer/binding/cproto/CommandObservationContext.java
new file mode 100644
index 00000000..b7fea5ef
--- /dev/null
+++ b/src/main/java/ru/rt/restream/reindexer/binding/cproto/CommandObservationContext.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020-present Restream
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ru.rt.restream.reindexer.binding.cproto;
+
+import io.micrometer.observation.transport.Kind;
+import io.micrometer.observation.transport.RequestReplySenderContext;
+import lombok.Getter;
+import ru.rt.restream.reindexer.ReindexerResponse;
+
+/**
+ * A context for command observation.
+ */
+@Getter
+final class CommandObservationContext extends RequestReplySenderContext