Skip to content

NR-370635: Fix instrumentation failure for solr 9.8.0 version #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
@@ -1,11 +1,5 @@
/*
*
* * Copyright 2020 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package org.apache.solr.client.solrj.impl;

import com.newrelic.api.agent.security.NewRelicSecurity;
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper;
import com.newrelic.api.agent.security.schema.AbstractOperation;
@@ -27,6 +21,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@@ -78,22 +73,28 @@ private AbstractOperation preprocessSolrRequest(@SuppressWarnings({"rawtypes"})S
String method = request.getMethod().toString();
String path = request.getPath();
SolrParams solrParams = request.getParams();
Map<String, String> params = Collections.emptyMap();
if(solrParams != null){
params = SolrParams.toMap(solrParams.toNamedList());
}
List<SolrInputDocument> documents = Collections.emptyList();
if(request instanceof UpdateRequest) {
documents = ((UpdateRequest) request).getDocuments();
}
SolrDbOperation solrDbOperation = new SolrDbOperation(this.getClass().getName(), methodName);
solrDbOperation.setCollection(collection);
solrDbOperation.setParams(params);
solrDbOperation.setParams(Collections.emptyMap());

if(solrParams != null){
HashMap<String, String> map = new HashMap<>();
NamedList<Object> params = solrParams.toNamedList();
for (int i = 0; i < params.size(); i++) {
map.put(params.getName(i), params.getVal(i).toString());
}
solrDbOperation.setParams(map);
}

solrDbOperation.setDocuments(documents);
solrDbOperation.setConnectionURL(getBaseURL());
solrDbOperation.setMethod(method);
solrDbOperation.setPath(path);
NewRelicSecurity.getAgent().log(LogLevel.FINEST, String.format("Solr request %s, %s, %s, %s, %s", collection, method, path, params, documents), this.getClass().getName());
NewRelicSecurity.getAgent().log(LogLevel.FINEST, String.format("Solr request %s, %s, %s, %s, %s", collection, method, path, solrDbOperation.getParams(), documents), this.getClass().getName());
NewRelicSecurity.getAgent().registerOperation(solrDbOperation);
return solrDbOperation;
} catch (MalformedURLException e){
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/*
*
* * Copyright 2020 New Relic Corporation. All rights reserved.
* * SPDX-License-Identifier: Apache-2.0
*
*/

package org.apache.solr.client.solrj.impl;

import com.newrelic.api.agent.security.NewRelicSecurity;
import com.newrelic.api.agent.security.instrumentation.helpers.GenericHelper;
import com.newrelic.api.agent.security.schema.AbstractOperation;
@@ -28,6 +22,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -81,22 +76,29 @@ private AbstractOperation preprocessSolrRequest(@SuppressWarnings({"rawtypes"})S
String method = request.getMethod().toString();
String path = request.getPath();
SolrParams solrParams = request.getParams();
Map<String, String> params = Collections.emptyMap();
if(solrParams != null){
params = SolrParams.toMap(solrParams.toNamedList());
}

List<SolrInputDocument> documents = Collections.emptyList();
if(request instanceof UpdateRequest) {
documents = ((UpdateRequest) request).getDocuments();
}
SolrDbOperation solrDbOperation = new SolrDbOperation(this.getClass().getName(), methodName);
solrDbOperation.setCollection(collection);
solrDbOperation.setParams(params);

solrDbOperation.setParams(Collections.emptyMap());

if(solrParams != null){
HashMap<String, String> map = new HashMap<>();
NamedList<Object> params = solrParams.toNamedList();
for (int i = 0; i < params.size(); i++) {
map.put(params.getName(i), params.getVal(i).toString());
}
solrDbOperation.setParams(map);
}
solrDbOperation.setDocuments(documents);
solrDbOperation.setConnectionURL(getBaseURL());
solrDbOperation.setMethod(method);
solrDbOperation.setPath(path);
NewRelicSecurity.getAgent().log(LogLevel.FINEST, String.format("Solr request %s, %s, %s, %s, %s", collection, method, path, params, documents), this.getClass().getName());
NewRelicSecurity.getAgent().log(LogLevel.FINEST, String.format("Solr request %s, %s, %s, %s, %s", collection, method, path, solrDbOperation.getParams(), documents), this.getClass().getName());
NewRelicSecurity.getAgent().registerOperation(solrDbOperation);
return solrDbOperation;
} catch (MalformedURLException e){