Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,19 @@ public enum DefaultDriverOption implements DriverOption {
*
* <p>Value-Type: boolean
*/
ADDRESS_TRANSLATOR_RESOLVE_ADDRESSES("advanced.address-translator.resolve-addresses");
ADDRESS_TRANSLATOR_RESOLVE_ADDRESSES("advanced.address-translator.resolve-addresses"),
/**
* Whether the driver reports its effective client configuration to ScyllaDB at connection time.
*
* <p>When {@code true}, the driver sends a compact JSON description of its configuration in the
* CQL {@code STARTUP} options under the {@code DRIVER_CONFIG} key (control connection only);
* ScyllaDB stores it in {@code system.clients.client_options} so operators can inspect driver
* settings while investigating incidents. Independently of this flag, a {@code SESSION_ID}
* startup option is sent on every connection so the server can group a session's connections.
*
* <p>Value type: boolean
*/
CLIENT_CONFIG_REPORTING_ENABLED("advanced.client-config-reporting.enabled");

private final String path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ protected static void fillWithDriverDefaults(OptionsMap map) {
// values) with no sensible scalar default, analogous to how CONFIG_RELOAD_INTERVAL is omitted.
map.put(TypedDriverOption.CLIENT_ROUTES_NATIVE_TRANSPORT_PORT, 9042);
map.put(TypedDriverOption.CLIENT_ROUTES_SHARD_AWARENESS_ENABLED, false);
map.put(TypedDriverOption.CLIENT_CONFIG_REPORTING_ENABLED, false);
}

@Immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,11 @@ public String toString() {
new TypedDriverOption<>(
DefaultDriverOption.CLIENT_ROUTES_SHARD_AWARENESS_ENABLED, GenericType.BOOLEAN);

/** Whether the driver reports its client configuration to ScyllaDB at connection time. */
public static final TypedDriverOption<Boolean> CLIENT_CONFIG_REPORTING_ENABLED =
new TypedDriverOption<>(
DefaultDriverOption.CLIENT_CONFIG_REPORTING_ENABLED, GenericType.BOOLEAN);

private static Iterable<TypedDriverOption<?>> introspectBuiltInValues() {
try {
ImmutableList.Builder<TypedDriverOption<?>> result = ImmutableList.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,32 @@ public static Builder builder() {

public final String ownerLogPrefix;

/**
* Whether the channel should report the driver configuration ({@code DRIVER_CONFIG}) in its
* {@code STARTUP} options. Set only for the control connection, so the (potentially large) config
* blob is sent once per session rather than on every pooled connection.
*/
public final boolean reportConfig;

private DriverChannelOptions(
CqlIdentifier keyspace,
List<String> eventTypes,
EventCallback eventCallback,
String ownerLogPrefix) {
String ownerLogPrefix,
boolean reportConfig) {
this.keyspace = keyspace;
this.eventTypes = eventTypes;
this.eventCallback = eventCallback;
this.ownerLogPrefix = ownerLogPrefix;
this.reportConfig = reportConfig;
}

public static class Builder {
private CqlIdentifier keyspace = null;
private List<String> eventTypes = Collections.emptyList();
private EventCallback eventCallback = null;
private String ownerLogPrefix = null;
private boolean reportConfig = false;

public Builder withKeyspace(CqlIdentifier keyspace) {
this.keyspace = keyspace;
Expand All @@ -82,8 +92,17 @@ public Builder withOwnerLogPrefix(String ownerLogPrefix) {
return this;
}

/**
* Marks this channel as the one that reports {@code DRIVER_CONFIG} (the control connection).
*/
public Builder reportConfig(boolean reportConfig) {
this.reportConfig = reportConfig;
return this;
}

public DriverChannelOptions build() {
return new DriverChannelOptions(keyspace, eventTypes, eventCallback, ownerLogPrefix);
return new DriverChannelOptions(
keyspace, eventTypes, eventCallback, ownerLogPrefix, reportConfig);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ Message getRequest() {
if (featureStore != null) {
featureStore.populateStartupOptions(startupOptions);
}
// Adds SESSION_ID on every connection and DRIVER_CONFIG on the control connection
// (options.reportConfig); no-op when client config reporting is disabled.
context
.getDriverConfigReporter()
.populateStartupOptions(startupOptions, options.reportConfig);
return request = new Startup(startupOptions);
case GET_CLUSTER_NAME:
return request = CLUSTER_NAME_QUERY;
Expand Down
Loading
Loading