use of io.opentelemetry.api.trace.Span in project hbase by apache.
the class AsyncRegionLocator method getRegionLocation.
CompletableFuture<HRegionLocation> getRegionLocation(TableName tableName, byte[] row, int replicaId, RegionLocateType type, boolean reload, long timeoutNs) {
final Supplier<Span> supplier = new TableSpanBuilder(conn).setName("AsyncRegionLocator.getRegionLocation").setTableName(tableName);
return tracedLocationFuture(() -> {
// meta region can not be split right now so we always call the same method.
// Change it later if the meta table can have more than one regions.
CompletableFuture<HRegionLocation> future = new CompletableFuture<>();
CompletableFuture<RegionLocations> locsFuture = isMeta(tableName) ? metaRegionLocator.getRegionLocations(replicaId, reload) : nonMetaRegionLocator.getRegionLocations(tableName, row, replicaId, type, reload);
addListener(locsFuture, (locs, error) -> {
if (error != null) {
future.completeExceptionally(error);
return;
}
HRegionLocation loc = locs.getRegionLocation(replicaId);
if (loc == null) {
future.completeExceptionally(new RegionOfflineException("No location for " + tableName + ", row='" + Bytes.toStringBinary(row) + "', locateType=" + type + ", replicaId=" + replicaId));
} else if (loc.getServerName() == null) {
future.completeExceptionally(new RegionOfflineException("No server address listed for region '" + loc.getRegion().getRegionNameAsString() + ", row='" + Bytes.toStringBinary(row) + "', locateType=" + type + ", replicaId=" + replicaId));
} else {
future.complete(loc);
}
});
return withTimeout(future, timeoutNs, () -> "Timeout(" + TimeUnit.NANOSECONDS.toMillis(timeoutNs) + "ms) waiting for region location for " + tableName + ", row='" + Bytes.toStringBinary(row) + "', replicaId=" + replicaId);
}, AsyncRegionLocator::getRegionNames, supplier);
}
use of io.opentelemetry.api.trace.Span in project hbase by apache.
the class IntegrationTestSendTraceRequests method insertData.
private LinkedBlockingQueue<Long> insertData() throws IOException, InterruptedException {
LinkedBlockingQueue<Long> rowKeys = new LinkedBlockingQueue<>(25000);
BufferedMutator ht = util.getConnection().getBufferedMutator(this.tableName);
byte[] value = new byte[300];
for (int x = 0; x < 5000; x++) {
Span span = TraceUtil.getGlobalTracer().spanBuilder("insertData").startSpan();
try (Scope scope = span.makeCurrent()) {
for (int i = 0; i < 5; i++) {
long rk = random.nextLong();
rowKeys.add(rk);
Put p = new Put(Bytes.toBytes(rk));
for (int y = 0; y < 10; y++) {
random.nextBytes(value);
p.addColumn(familyName, Bytes.toBytes(random.nextLong()), value);
}
ht.mutate(p);
}
if ((x % 1000) == 0) {
admin.flush(tableName);
}
} finally {
span.end();
}
}
admin.flush(tableName);
return rowKeys;
}
use of io.opentelemetry.api.trace.Span in project wildfly by wildfly.
the class OpenTelemetryContainerFilter method filter.
@Override
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext) {
Object serverSpan = containerRequestContext.getProperty(SERVER_SPAN);
if (serverSpan != null && serverSpan instanceof Span) {
final Span span = (Span) serverSpan;
final int status = containerResponseContext.getStatus();
if (status >= 400) {
span.setAttribute(SemanticAttributes.HTTP_STATUS_CODE, status);
}
span.end();
}
}
use of io.opentelemetry.api.trace.Span in project wildfly by wildfly.
the class Service1 method endpoint1.
@GET
public String endpoint1() throws JsonProcessingException {
final Span span = tracer.spanBuilder("Doing some work").startSpan();
span.makeCurrent();
String traceParent = sendRequest();
span.end();
Map<String, String> values = new HashMap<>();
values.put("traceId", span.getSpanContext().getTraceId());
values.put("traceParent", traceParent);
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.writeValueAsString(values);
}
use of io.opentelemetry.api.trace.Span in project wildfly by wildfly.
the class Service2 method endpoint1.
@GET
public String endpoint1() {
final Span span = tracer.spanBuilder("Doing some work in service2").startSpan();
String traceParent = headers.getHeaderString(TRACE_PARENT);
if (traceParent == null || traceParent.isEmpty()) {
throw new WebApplicationException("Missing traceparent header");
}
span.end();
return traceParent;
}
Aggregations