Skip to content
Open
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
@@ -0,0 +1,9 @@
title: >
HttpSolrClient impls now sends certain interesting request parameters in the URL query string when a POST of parameters is submitted. In other words, withTheseParamNamesInTheUrl now has a default set.
This improves observability, particularly for distributed search & admin commands.
type: changed
authors:
- name: David Smiley
links:
- name: PR#4871
url: https://github.com/apache/solr/pull/4871
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,32 @@
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/collection1_shard1_replica_nN/select"},
"http.url":"http://NORMALIZED/solr/collection1_shard1_replica_nN/select",
"http.params":"distrib=false&isShard=true&shards.purpose=16388"},
{
"name":"post:/{core}/select",
"kind":"SERVER",
"db.instance":"collection1_shard1_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/collection1_shard1_replica_nN/select"},
"http.url":"http://NORMALIZED/solr/collection1_shard1_replica_nN/select",
"http.params":"distrib=false&isShard=true&shards.purpose=64"},
{
"name":"post:/{core}/select",
"kind":"SERVER",
"db.instance":"collection1_shard2_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select"},
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select",
"http.params":"distrib=false&isShard=true&shards.purpose=16388"},
{
"name":"post:/{core}/select",
"kind":"SERVER",
"db.instance":"collection1_shard2_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select"}]}]}]}
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select",
"http.params":"distrib=false&isShard=true&shards.purpose=64"}]}]}]}
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,41 @@
"db.instance":"collection1",
"children":[
{
"name":"post:/admin/cores",
"name":"reload:/admin/cores",
"kind":"SERVER",
"db.instance":"collection1_shard1_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/admin/cores"},
"http.url":"http://NORMALIZED/solr/admin/cores",
"http.params":"action=RELOAD"},
{
"name":"post:/admin/cores",
"name":"reload:/admin/cores",
"kind":"SERVER",
"db.instance":"collection1_shard1_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/admin/cores"},
"http.url":"http://NORMALIZED/solr/admin/cores",
"http.params":"action=RELOAD"},
{
"name":"post:/admin/cores",
"name":"reload:/admin/cores",
"kind":"SERVER",
"db.instance":"collection1_shard2_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/admin/cores"},
"http.url":"http://NORMALIZED/solr/admin/cores",
"http.params":"action=RELOAD"},
{
"name":"post:/admin/cores",
"name":"reload:/admin/cores",
"kind":"SERVER",
"db.instance":"collection1_shard2_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/admin/cores"}]},
"http.url":"http://NORMALIZED/solr/admin/cores",
"http.params":"action=RELOAD"}]},
{
"name":"post:/collections/{collection}/reload",
"kind":"SERVER",
Expand Down Expand Up @@ -124,20 +128,23 @@
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/collection1_shard1_replica_nN/select"},
"http.url":"http://NORMALIZED/solr/collection1_shard1_replica_nN/select",
"http.params":"distrib=false&isShard=true&shards.purpose=16388"},
{
"name":"post:/{core}/select",
"kind":"SERVER",
"db.instance":"collection1_shard2_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select"},
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select",
"http.params":"distrib=false&isShard=true&shards.purpose=16388"},
{
"name":"post:/{core}/select",
"kind":"SERVER",
"db.instance":"collection1_shard2_replica_nN",
"db.type":"solr",
"http.request.method":"POST",
"http.response.status_code":200,
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select"}]}]}]}
"http.url":"http://NORMALIZED/solr/collection1_shard2_replica_nN/select",
"http.params":"distrib=false&isShard=true&shards.purpose=64"}]}]}]}
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private void verifyCollectionCreation(String collection) throws Exception {
// db.instance=testInternalCollectionApiCommands
// - this will be the parent span, all following spans will have the same traceId
//
// 3..6 (4 times) name=post:/admin/cores
// 3..6 (4 times) name=create:/admin/cores
// db.instance=testInternalCollectionApiCommands_shard1_replica_n2
// db.instance=testInternalCollectionApiCommands_shard2_replica_n4
// db.instance=testInternalCollectionApiCommands_shard2_replica_n1
Expand Down Expand Up @@ -238,7 +238,7 @@ private void verifyCollectionCreation(String collection) throws Exception {
ops.put(span.getName(), ops.getOrDefault(span.getName(), 0) + 1);
}
var expectedOps =
Map.of("CreateCollectionCmd", 1, "post:/admin/cores", 4, "post:/{core}/get", 6);
Map.of("CreateCollectionCmd", 1, "create:/admin/cores", 4, "post:/{core}/get", 6);
assertEquals(expectedOps, ops);
}

Expand All @@ -254,7 +254,7 @@ private void verifyCollectionDeletion(String collection) throws Exception {
// db.instance=testInternalCollectionApiCommands
// - this will be the parent span, all following spans will have the same traceId
//
// 3..6 (4 times) name=post:/admin/cores
// 3..6 (4 times) name=unload:/admin/cores
// db.instance=testInternalCollectionApiCommands_shard2_replica_n1
// db.instance=testInternalCollectionApiCommands_shard1_replica_n2
// db.instance=testInternalCollectionApiCommands_shard2_replica_n4
Expand All @@ -278,7 +278,7 @@ private void verifyCollectionDeletion(String collection) throws Exception {
assertEquals(span.getTraceId(), parentTraceId);
ops.put(span.getName(), ops.getOrDefault(span.getName(), 0) + 1);
}
var expectedOps = Map.of("DeleteCollectionCmd", 1, "post:/admin/cores", 4);
var expectedOps = Map.of("DeleteCollectionCmd", 1, "unload:/admin/cores", 4);
assertEquals(expectedOps, ops);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@
import org.apache.solr.client.solrj.response.ResponseParser;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CollectionAdminParams;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
import org.apache.solr.common.util.NamedList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -65,6 +69,20 @@ public abstract class HttpSolrClient extends SolrClient {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
protected static final Charset FALLBACK_CHARSET = StandardCharsets.UTF_8;

/** Default set are interesting for routing or fundamental request purpose */
private static final Set<String> DEFAULT_URL_PARAM_NAMES =
Set.of(
CoreAdminParams.ACTION,
CommonAdminParams.ASYNC,
CollectionAdminParams.COLLECTION,
"name", // core/collection name
"command", // e.g. for replication
ShardParams.IS_SHARD,
CommonParams.DISTRIB,
ShardParams._ROUTE_,
ShardParams.SHARDS_PREFERENCE,
ShardParams.SHARDS_PURPOSE);

protected final String baseUrl;
protected final long requestTimeoutMillis;

Expand All @@ -87,11 +105,7 @@ protected HttpSolrClient(String serverBaseUrl, BuilderBase<?, ?> builder) {
this.parser = builder.responseParser;
}
this.defaultCollection = builder.defaultCollection;
if (builder.urlParamNames != null) {
this.urlParamNames = builder.urlParamNames;
} else {
this.urlParamNames = Set.of();
}
this.urlParamNames = Objects.requireNonNullElse(builder.urlParamNames, DEFAULT_URL_PARAM_NAMES);
}

private static String extractBaseUrl(String serverBaseUrl) {
Expand Down
Loading