Skip to content

Commit c2e7b97

Browse files
authored
Revert "Introduce Api Telemetry (#1487)"
This reverts commit 92e7341.
1 parent 92e7341 commit c2e7b97

File tree

69 files changed

+118
-2273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+118
-2273
lines changed

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,6 @@ public final class Config implements Serializable {
148148
*/
149149
private final MetricsAdapter metricsAdapter;
150150

151-
/**
152-
* Specify if telemetry collection is disabled.
153-
* <p>
154-
* By default, the driver will send anonymous usage statistics to the server it connects to if the server requests those.
155-
*/
156-
private final boolean telemetryDisabled;
157-
158151
private Config(ConfigBuilder builder) {
159152
this.logging = builder.logging;
160153
this.logLeakedSessions = builder.logLeakedSessions;
@@ -176,7 +169,6 @@ private Config(ConfigBuilder builder) {
176169

177170
this.eventLoopThreads = builder.eventLoopThreads;
178171
this.metricsAdapter = builder.metricsAdapter;
179-
this.telemetryDisabled = builder.telemetryDisabled;
180172
}
181173

182174
/**
@@ -343,18 +335,6 @@ public String userAgent() {
343335
return userAgent;
344336
}
345337

346-
/**
347-
* Returns if the telemetry is disabled on the driver side.
348-
* <p>
349-
* The telemetry is collected only when it is enabled both the server and the driver.
350-
*
351-
* @return {@code true} if telemetry is disabled or {@code false} otherwise
352-
* @since 5.13
353-
*/
354-
public boolean isTelemetryDisabled() {
355-
return telemetryDisabled;
356-
}
357-
358338
/**
359339
* Used to build new config instances
360340
*/
@@ -377,8 +357,6 @@ public static final class ConfigBuilder {
377357
private int eventLoopThreads = 0;
378358
private NotificationConfig notificationConfig = NotificationConfig.defaultConfig();
379359

380-
private boolean telemetryDisabled = false;
381-
382360
private ConfigBuilder() {}
383361

384362
/**
@@ -770,31 +748,6 @@ public ConfigBuilder withNotificationConfig(NotificationConfig notificationConfi
770748
return this;
771749
}
772750

773-
/**
774-
* Sets if telemetry is disabled on the driver side.
775-
* <p>
776-
* By default, the driver sends anonymous telemetry data to the server it connects to if the server has
777-
* telemetry enabled. This can be explicitly disabled on the driver side by setting this setting to
778-
* {@code true}.
779-
* <p>
780-
* At present, the driver sends which API type is used, like:
781-
* <ul>
782-
* <li>Managed transaction ({@link Session#executeWrite(TransactionCallback)},
783-
* {@link Session#executeRead(TransactionCallback)} and similar options)</li>
784-
* <li>Unmanaged transaction ({@link Session#beginTransaction()} and similar options)</li>
785-
* <li>Autocommit transaction ({@link Session#run(Query)} and similar options)</li>
786-
* <li>Executable query ({@link Driver#executableQuery(String)} and similar options)</li>
787-
* </ul>
788-
*
789-
* @param telemetryDisabled {@code true} if telemetry is disabled or {@code false} otherwise
790-
* @return this builder
791-
* @since 5.13
792-
*/
793-
public ConfigBuilder withTelemetryDisabled(boolean telemetryDisabled) {
794-
this.telemetryDisabled = telemetryDisabled;
795-
return this;
796-
}
797-
798751
/**
799752
* Create a config instance from this builder.
800753
*

driver/src/main/java/org/neo4j/driver/internal/DriverFactory.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ protected InternalDriver createRoutingDriver(
269269
*/
270270
protected InternalDriver createDriver(
271271
SecurityPlan securityPlan, SessionFactory sessionFactory, MetricsProvider metricsProvider, Config config) {
272-
return new InternalDriver(
273-
securityPlan, sessionFactory, metricsProvider, config.isTelemetryDisabled(), config.logging());
272+
return new InternalDriver(securityPlan, sessionFactory, metricsProvider, config.logging());
274273
}
275274

276275
/**

driver/src/main/java/org/neo4j/driver/internal/InternalDriver.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,18 @@ public class InternalDriver implements Driver {
6565
private final SessionFactory sessionFactory;
6666
private final Logger log;
6767

68-
private final boolean telemetryDisabled;
69-
7068
private final AtomicBoolean closed = new AtomicBoolean(false);
7169
private final MetricsProvider metricsProvider;
7270

7371
InternalDriver(
7472
SecurityPlan securityPlan,
7573
SessionFactory sessionFactory,
7674
MetricsProvider metricsProvider,
77-
boolean telemetryDisabled,
7875
Logging logging) {
7976
this.securityPlan = securityPlan;
8077
this.sessionFactory = sessionFactory;
8178
this.metricsProvider = metricsProvider;
8279
this.log = logging.getLog(getClass());
83-
this.telemetryDisabled = telemetryDisabled;
8480
}
8581

8682
@Override
@@ -219,7 +215,7 @@ private static RuntimeException driverCloseException() {
219215

220216
public NetworkSession newSession(SessionConfig config, AuthToken overrideAuthToken) {
221217
assertOpen();
222-
var session = sessionFactory.newInstance(config, overrideAuthToken, telemetryDisabled);
218+
var session = sessionFactory.newInstance(config, overrideAuthToken);
223219
if (closed.get()) {
224220
// session does not immediately acquire connection, it is fine to just throw
225221
throw driverCloseException();

driver/src/main/java/org/neo4j/driver/internal/InternalExecutableQuery.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.neo4j.driver.SessionConfig;
3333
import org.neo4j.driver.TransactionCallback;
3434
import org.neo4j.driver.TransactionConfig;
35-
import org.neo4j.driver.internal.telemetry.TelemetryApi;
3635

3736
public class InternalExecutableQuery implements ExecutableQuery {
3837
private final Driver driver;
@@ -82,8 +81,7 @@ public <A, R, T> T execute(Collector<Record, A, R> recordCollector, ResultFinish
8281
return resultFinisher.finish(result.keys(), finishedValue, summary);
8382
};
8483
var accessMode = config.routing().equals(RoutingControl.WRITE) ? AccessMode.WRITE : AccessMode.READ;
85-
return session.execute(
86-
accessMode, txCallback, TransactionConfig.empty(), TelemetryApi.EXECUTABLE_QUERY, false);
84+
return session.execute(accessMode, txCallback, TransactionConfig.empty(), false);
8785
}
8886
}
8987

driver/src/main/java/org/neo4j/driver/internal/InternalSession.java

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import org.neo4j.driver.exceptions.ClientException;
3535
import org.neo4j.driver.internal.async.NetworkSession;
3636
import org.neo4j.driver.internal.spi.Connection;
37-
import org.neo4j.driver.internal.telemetry.ApiTelemetryWork;
38-
import org.neo4j.driver.internal.telemetry.TelemetryApi;
3937
import org.neo4j.driver.internal.util.Futures;
4038

4139
public class InternalSession extends AbstractQueryRunner implements Session {
@@ -95,7 +93,7 @@ public Transaction beginTransaction(TransactionConfig config) {
9593

9694
public Transaction beginTransaction(TransactionConfig config, String txType) {
9795
var tx = Futures.blockingGet(
98-
session.beginTransactionAsync(config, txType, new ApiTelemetryWork(TelemetryApi.UNMANAGED_TRANSACTION)),
96+
session.beginTransactionAsync(config, txType),
9997
() -> terminateConnectionOnThreadInterrupt("Thread interrupted while starting a transaction"));
10098
return new InternalTransaction(tx);
10199
}
@@ -109,12 +107,12 @@ public <T> T readTransaction(TransactionWork<T> work) {
109107
@Override
110108
@Deprecated
111109
public <T> T readTransaction(TransactionWork<T> work, TransactionConfig config) {
112-
return transaction(AccessMode.READ, work, config, TelemetryApi.MANAGED_TRANSACTION, true);
110+
return transaction(AccessMode.READ, work, config, true);
113111
}
114112

115113
@Override
116114
public <T> T executeRead(TransactionCallback<T> callback, TransactionConfig config) {
117-
return execute(AccessMode.READ, callback, config, TelemetryApi.MANAGED_TRANSACTION, true);
115+
return execute(AccessMode.READ, callback, config, true);
118116
}
119117

120118
@Override
@@ -126,12 +124,12 @@ public <T> T writeTransaction(TransactionWork<T> work) {
126124
@Override
127125
@Deprecated
128126
public <T> T writeTransaction(TransactionWork<T> work, TransactionConfig config) {
129-
return transaction(AccessMode.WRITE, work, config, TelemetryApi.MANAGED_TRANSACTION, true);
127+
return transaction(AccessMode.WRITE, work, config, true);
130128
}
131129

132130
@Override
133131
public <T> T executeWrite(TransactionCallback<T> callback, TransactionConfig config) {
134-
return execute(AccessMode.WRITE, callback, config, TelemetryApi.MANAGED_TRANSACTION, true);
132+
return execute(AccessMode.WRITE, callback, config, true);
135133
}
136134

137135
@Override
@@ -153,29 +151,21 @@ public void reset() {
153151
() -> terminateConnectionOnThreadInterrupt("Thread interrupted while resetting the session"));
154152
}
155153

156-
<T> T execute(
157-
AccessMode accessMode,
158-
TransactionCallback<T> callback,
159-
TransactionConfig config,
160-
TelemetryApi telemetryApi,
161-
boolean flush) {
162-
return transaction(
163-
accessMode, tx -> callback.execute(new DelegatingTransactionContext(tx)), config, telemetryApi, flush);
154+
<T> T execute(AccessMode accessMode, TransactionCallback<T> callback, TransactionConfig config, boolean flush) {
155+
return transaction(accessMode, tx -> callback.execute(new DelegatingTransactionContext(tx)), config, flush);
164156
}
165157

166158
private <T> T transaction(
167159
AccessMode mode,
168160
@SuppressWarnings("deprecation") TransactionWork<T> work,
169161
TransactionConfig config,
170-
TelemetryApi telemetryApi,
171162
boolean flush) {
172163
// use different code path compared to async so that work is executed in the caller thread
173164
// caller thread will also be the one who sleeps between retries;
174165
// it is unsafe to execute retries in the event loop threads because this can cause a deadlock
175166
// event loop thread will bock and wait for itself to read some data
176-
var apiTelemetryWork = new ApiTelemetryWork(telemetryApi);
177167
return session.retryLogic().retry(() -> {
178-
try (var tx = beginTransaction(mode, config, apiTelemetryWork, flush)) {
168+
try (var tx = beginTransaction(mode, config, flush)) {
179169

180170
var result = work.execute(tx);
181171
if (result instanceof Result) {
@@ -192,10 +182,9 @@ private <T> T transaction(
192182
});
193183
}
194184

195-
private Transaction beginTransaction(
196-
AccessMode mode, TransactionConfig config, ApiTelemetryWork apiTelemetryWork, boolean flush) {
185+
private Transaction beginTransaction(AccessMode mode, TransactionConfig config, boolean flush) {
197186
var tx = Futures.blockingGet(
198-
session.beginTransactionAsync(mode, config, null, apiTelemetryWork, flush),
187+
session.beginTransactionAsync(mode, config, null, flush),
199188
() -> terminateConnectionOnThreadInterrupt("Thread interrupted while starting a transaction"));
200189
return new InternalTransaction(tx);
201190
}

driver/src/main/java/org/neo4j/driver/internal/SessionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.neo4j.driver.internal.async.NetworkSession;
2525

2626
public interface SessionFactory {
27-
NetworkSession newInstance(SessionConfig sessionConfig, AuthToken overrideAuthToken, boolean telemetryDisabled);
27+
NetworkSession newInstance(SessionConfig sessionConfig, AuthToken overrideAuthToken);
2828

2929
CompletionStage<Void> verifyConnectivity();
3030

driver/src/main/java/org/neo4j/driver/internal/SessionFactoryImpl.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ public class SessionFactoryImpl implements SessionFactory {
5353
}
5454

5555
@Override
56-
public NetworkSession newInstance(
57-
SessionConfig sessionConfig, AuthToken overrideAuthToken, boolean telemetryDisabled) {
56+
public NetworkSession newInstance(SessionConfig sessionConfig, AuthToken overrideAuthToken) {
5857
return createSession(
5958
connectionProvider,
6059
retryLogic,
@@ -66,8 +65,7 @@ public NetworkSession newInstance(
6665
logging,
6766
sessionConfig.bookmarkManager().orElse(NoOpBookmarkManager.INSTANCE),
6867
sessionConfig.notificationConfig(),
69-
overrideAuthToken,
70-
telemetryDisabled);
68+
overrideAuthToken);
7169
}
7270

7371
private Set<Bookmark> toDistinctSet(Iterable<Bookmark> bookmarks) {
@@ -144,8 +142,7 @@ private NetworkSession createSession(
144142
Logging logging,
145143
BookmarkManager bookmarkManager,
146144
NotificationConfig notificationConfig,
147-
AuthToken authToken,
148-
boolean telemetryDisabled) {
145+
AuthToken authToken) {
149146
Objects.requireNonNull(bookmarks, "bookmarks may not be null");
150147
Objects.requireNonNull(bookmarkManager, "bookmarkManager may not be null");
151148
return leakedSessionsLoggingEnabled
@@ -160,8 +157,7 @@ private NetworkSession createSession(
160157
logging,
161158
bookmarkManager,
162159
notificationConfig,
163-
authToken,
164-
telemetryDisabled)
160+
authToken)
165161
: new NetworkSession(
166162
connectionProvider,
167163
retryLogic,
@@ -173,7 +169,6 @@ private NetworkSession createSession(
173169
logging,
174170
bookmarkManager,
175171
notificationConfig,
176-
authToken,
177-
telemetryDisabled);
172+
authToken);
178173
}
179174
}

driver/src/main/java/org/neo4j/driver/internal/async/InternalAsyncSession.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
import org.neo4j.driver.async.ResultCursor;
3939
import org.neo4j.driver.exceptions.ClientException;
4040
import org.neo4j.driver.internal.InternalBookmark;
41-
import org.neo4j.driver.internal.telemetry.ApiTelemetryWork;
42-
import org.neo4j.driver.internal.telemetry.TelemetryApi;
4341
import org.neo4j.driver.internal.util.Futures;
4442

4543
public class InternalAsyncSession extends AsyncAbstractQueryRunner implements AsyncSession {
@@ -82,8 +80,7 @@ public CompletionStage<AsyncTransaction> beginTransactionAsync() {
8280

8381
@Override
8482
public CompletionStage<AsyncTransaction> beginTransactionAsync(TransactionConfig config) {
85-
return session.beginTransactionAsync(config, new ApiTelemetryWork(TelemetryApi.UNMANAGED_TRANSACTION))
86-
.thenApply(InternalAsyncTransaction::new);
83+
return session.beginTransactionAsync(config).thenApply(InternalAsyncTransaction::new);
8784
}
8885

8986
@Override
@@ -139,10 +136,9 @@ private <T> CompletionStage<T> transactionAsync(
139136
AccessMode mode,
140137
@SuppressWarnings("deprecation") AsyncTransactionWork<CompletionStage<T>> work,
141138
TransactionConfig config) {
142-
var apiTelemetryWork = new ApiTelemetryWork(TelemetryApi.MANAGED_TRANSACTION);
143139
return session.retryLogic().retryAsync(() -> {
144140
var resultFuture = new CompletableFuture<T>();
145-
var txFuture = session.beginTransactionAsync(mode, config, apiTelemetryWork);
141+
var txFuture = session.beginTransactionAsync(mode, config);
146142

147143
txFuture.whenComplete((tx, completionError) -> {
148144
var error = Futures.completionExceptionCause(completionError);

driver/src/main/java/org/neo4j/driver/internal/async/LeakLoggingNetworkSession.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public LeakLoggingNetworkSession(
4848
Logging logging,
4949
BookmarkManager bookmarkManager,
5050
NotificationConfig notificationConfig,
51-
AuthToken overrideAuthToken,
52-
boolean telemetryDisabled) {
51+
AuthToken overrideAuthToken) {
5352
super(
5453
connectionProvider,
5554
retryLogic,
@@ -61,8 +60,7 @@ public LeakLoggingNetworkSession(
6160
logging,
6261
bookmarkManager,
6362
notificationConfig,
64-
overrideAuthToken,
65-
telemetryDisabled);
63+
overrideAuthToken);
6664
this.stackTrace = captureStackTrace();
6765
}
6866

driver/src/main/java/org/neo4j/driver/internal/async/NetworkConnection.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public class NetworkConnection implements Connection {
6767
private final InboundMessageDispatcher messageDispatcher;
6868
private final String serverAgent;
6969
private final BoltServerAddress serverAddress;
70-
private final boolean telemetryEnabled;
7170
private final BoltProtocol protocol;
7271
private final ExtendedChannelPool channelPool;
7372
private final CompletableFuture<Void> releaseFuture;
@@ -93,7 +92,6 @@ public NetworkConnection(
9392
this.messageDispatcher = ChannelAttributes.messageDispatcher(channel);
9493
this.serverAgent = ChannelAttributes.serverAgent(channel);
9594
this.serverAddress = ChannelAttributes.serverAddress(channel);
96-
this.telemetryEnabled = ChannelAttributes.telemetryEnabled(channel);
9795
this.protocol = BoltProtocol.forChannel(channel);
9896
this.channelPool = channelPool;
9997
this.releaseFuture = new CompletableFuture<>();
@@ -138,11 +136,6 @@ public void writeAndFlush(Message message, ResponseHandler handler) {
138136
}
139137
}
140138

141-
@Override
142-
public boolean isTelemetryEnabled() {
143-
return telemetryEnabled;
144-
}
145-
146139
@Override
147140
public CompletionStage<Void> reset(Throwable throwable) {
148141
var result = new CompletableFuture<Void>();

0 commit comments

Comments
 (0)