mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
attach http adapter metrics directly to adapter instance
This commit is contained in:
parent
2775715081
commit
fd18bd2694
@ -16,16 +16,16 @@
|
||||
|
||||
package io.nosqlbench.adapter.http;
|
||||
|
||||
import io.nosqlbench.adapter.http.core.HttpFormatParser;
|
||||
import io.nosqlbench.adapter.http.core.HttpOp;
|
||||
import io.nosqlbench.adapter.http.core.HttpOpMapper;
|
||||
import io.nosqlbench.adapter.http.core.HttpSpace;
|
||||
import io.nosqlbench.adapter.http.core.*;
|
||||
import io.nosqlbench.nb.api.components.core.NBComponentProps;
|
||||
import io.nosqlbench.nb.api.config.standard.ConfigModel;
|
||||
import io.nosqlbench.nb.api.config.standard.Param;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseDriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverSpaceCache;
|
||||
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||
import io.nosqlbench.nb.api.engine.metrics.instruments.NBMetricHistogram;
|
||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||
import io.nosqlbench.nb.api.components.core.NBComponent;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
@ -41,8 +41,11 @@ import java.util.function.Function;
|
||||
@Service(value = DriverAdapter.class, selector = "http")
|
||||
public class HttpDriverAdapter extends BaseDriverAdapter<HttpOp, HttpSpace> {
|
||||
|
||||
private final HttpMetrics httpMetrics;
|
||||
|
||||
public HttpDriverAdapter(NBComponent parent, NBLabels labels) {
|
||||
super(parent, labels);
|
||||
this.httpMetrics=new HttpMetrics(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,7 +57,7 @@ public class HttpDriverAdapter extends BaseDriverAdapter<HttpOp, HttpSpace> {
|
||||
|
||||
@Override
|
||||
public Function<String, ? extends HttpSpace> getSpaceInitializer(NBConfiguration cfg) {
|
||||
return spaceName -> new HttpSpace(getParent(), spaceName, cfg);
|
||||
return spaceName -> new HttpSpace(this, spaceName, cfg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,4 +87,8 @@ public class HttpDriverAdapter extends BaseDriverAdapter<HttpOp, HttpSpace> {
|
||||
return super.getConfigModel().add(HttpSpace.getConfigModel()).add(thisCfgModel);
|
||||
}
|
||||
|
||||
|
||||
public HttpMetrics getHttpMetrics() {
|
||||
return this.httpMetrics;
|
||||
}
|
||||
}
|
||||
|
@ -17,33 +17,32 @@
|
||||
package io.nosqlbench.adapter.http.core;
|
||||
|
||||
import com.codahale.metrics.Histogram;
|
||||
import io.nosqlbench.adapter.http.HttpDriverAdapter;
|
||||
import io.nosqlbench.nb.api.components.core.NBComponentProps;
|
||||
import io.nosqlbench.nb.api.engine.metrics.instruments.MetricCategory;
|
||||
import io.nosqlbench.nb.api.labels.NBLabeledElement;
|
||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||
import io.nosqlbench.nb.api.components.core.NBComponent;
|
||||
|
||||
public class HttpMetrics implements NBLabeledElement {
|
||||
private final NBComponent parent;
|
||||
private final HttpSpace space;
|
||||
private final HttpDriverAdapter parentAdapter;
|
||||
final Histogram statusCodeHistogram;
|
||||
|
||||
public HttpMetrics(NBComponent parent, HttpSpace space) {
|
||||
this.parent = parent;
|
||||
this.space = space;
|
||||
statusCodeHistogram = parent.create().histogram(
|
||||
public HttpMetrics(HttpDriverAdapter parentAdapter) {
|
||||
this.parentAdapter = parentAdapter;
|
||||
statusCodeHistogram = parentAdapter.create().histogram(
|
||||
"statuscode",
|
||||
space.getHdrDigits(),
|
||||
Integer.parseInt(parentAdapter.getComponentProp(NBComponentProps.HDRDIGITS).orElse("3")),
|
||||
MetricCategory.Payload,
|
||||
"A histogram of status codes received by the HTTP client"
|
||||
);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "http"+("default".equals(this.space.getSpaceName())?"": '-' + space.getSpaceName());
|
||||
return parentAdapter.getAdapterName() + "-metrics";
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBLabels getLabels() {
|
||||
return space.getLabels();
|
||||
return parentAdapter.getLabels();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package io.nosqlbench.adapter.http.core;
|
||||
|
||||
import io.nosqlbench.adapter.http.HttpDriverAdapter;
|
||||
import io.nosqlbench.nb.api.labels.NBLabeledElement;
|
||||
import io.nosqlbench.nb.api.labels.NBLabels;
|
||||
import io.nosqlbench.nb.api.config.standard.ConfigModel;
|
||||
@ -39,7 +40,7 @@ import java.util.Locale;
|
||||
public class HttpSpace implements NBLabeledElement {
|
||||
private final static Logger logger = LogManager.getLogger(HttpSpace.class);
|
||||
|
||||
private final NBComponent parent;
|
||||
private final HttpDriverAdapter parentAdapter;
|
||||
private final String name;
|
||||
private final NBConfiguration cfg;
|
||||
private HttpConsoleFormats console;
|
||||
@ -52,8 +53,8 @@ public class HttpSpace implements NBLabeledElement {
|
||||
private boolean diagnosticsEnabled;
|
||||
|
||||
|
||||
public HttpSpace(NBComponent parent, String spaceName, NBConfiguration cfg) {
|
||||
this.parent = parent;
|
||||
public HttpSpace(HttpDriverAdapter parentAdapter, String spaceName, NBConfiguration cfg) {
|
||||
this.parentAdapter = parentAdapter;
|
||||
this.name = spaceName;
|
||||
this.cfg = cfg;
|
||||
applyConfig(cfg);
|
||||
@ -79,7 +80,7 @@ public class HttpSpace implements NBLabeledElement {
|
||||
);
|
||||
this.timeout = Duration.ofMillis(cfg.get("timeout", long.class));
|
||||
this.timeoutMillis = cfg.get("timeout", long.class);
|
||||
this.httpMetrics = new HttpMetrics(parent, this);
|
||||
this.httpMetrics = parentAdapter.getHttpMetrics();
|
||||
|
||||
this.console = cfg.getOptional("diag").map(s -> HttpConsoleFormats.apply(s, this.console))
|
||||
.orElseGet(() -> HttpConsoleFormats.apply(null,null));
|
||||
|
Loading…
Reference in New Issue
Block a user