// Additional setup is required to first fetch or create a new span
import io.opentelemetry.api.trace.Span;
// We're using the Jackson JSON library
// You may need to add it to your project as a dependency
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashMap;
import java.util.Map;
Map<String, Object> queryParams = new HashMap<>();
queryParams.put("param1", "value1");
queryParams.put("param2", "value2");
Map<String, String> nested = new HashMap<>();
nested.put("param3", "value3");
nested.put("param4", "value4");
queryParams.put("nested", nested);
try {
ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(queryParams);
Span span = Span.current();
span.setAttribute("appsignal.request.query_parameters", jsonString);
} catch (Exception e) {
// Add error handling here
}