@Override public void onFailure(final Throwable throwable, final HttpServerResponse response, final Span span) { LOG.trace("logging failed processing of request"); TracingHelper.logError(span, throwable); } }
@Override public final void authenticate(final JsonObject authInfo, final Handler<AsyncResult<User>> resultHandler) { final T credentials = getCredentials(Objects.requireNonNull(authInfo)); if (credentials == null) { resultHandler.handle(Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_UNAUTHORIZED, "malformed credentials"))); } else { authenticate(credentials, TracingHelper.extractSpanContext(tracer, authInfo), s -> { if (s.succeeded()) { resultHandler.handle(Future.succeededFuture(s.result())); } else { resultHandler.handle(Future.failedFuture(s.cause())); } }); } }
/** * Marks an <em>OpenTracing</em> span as erroneous and logs an exception. * <p> * This method does <em>not</em> finish the span. * * @param span The span to mark. * @param error The exception that has occurred. * @throws NullPointerException if error is {@code null}. */ public static void logError(final Span span, final Throwable error) { if (span != null) { logError(span, getErrorLogItems(error)); } }
@Override public void parseCredentials(final RoutingContext context, final Handler<AsyncResult<JsonObject>> handler) { super.parseCredentials(context, ar -> { if (ar.succeeded()) { final SpanContext spanContext = TracingHandler.serverSpanContext(context); if (spanContext != null && !(spanContext instanceof NoopSpanContext)) { TracingHelper.injectSpanContext(tracer, spanContext, ar.result()); } } handler.handle(ar); }); } }
@Override public void onFailure(final Throwable throwable, final HttpServerResponse response, final Span span) { LOG.trace("logging failed processing of request"); TracingHelper.logError(span, throwable); } }
/** * Marks an <em>OpenTracing</em> span as erroneous and logs an exception. * <p> * This method does <em>not</em> finish the span. * * @param span The span to mark. * @param error The exception that has occurred. * @throws NullPointerException if error is {@code null}. */ public static void logError(final Span span, final Throwable error) { if (span != null) { logError(span, getErrorLogItems(error)); } }
/** * Marks an <em>OpenTracing</em> span as erroneous and logs a message. * <p> * This method does <em>not</em> finish the span. * * @param span The span to mark. * @param message The message to log on the span. * @throws NullPointerException if message is {@code null}. */ public static void logError(final Span span, final String message) { if (span != null) { Objects.requireNonNull(message); logError(span, Collections.singletonMap(Fields.MESSAGE, message)); } }
/** * Marks an <em>OpenTracing</em> span as erroneous and logs a message. * <p> * This method does <em>not</em> finish the span. * * @param span The span to mark. * @param message The message to log on the span. * @throws NullPointerException if message is {@code null}. */ public static void logError(final Span span, final String message) { if (span != null) { Objects.requireNonNull(message); logError(span, Collections.singletonMap(Fields.MESSAGE, message)); } }
/** * Cancels an outstanding request with a given result. * * @param correlationId The correlation id of the request to cancel. * @param result The result to pass to the request's result handler. * @throws NullPointerException if any of the parameters is {@code null}. * @throws IllegalArgumentException if the result has not failed. */ protected final void cancelRequest(final Object correlationId, final AsyncResult<R> result) { Objects.requireNonNull(correlationId); Objects.requireNonNull(result); if (result.succeeded()) { throw new IllegalArgumentException("result must be failed"); } else { final TriTuple<Handler<AsyncResult<R>>, Object, Span> handler = replyMap.remove(correlationId); if (handler == null) { // response has already been processed } else { LOG.debug("canceling request [target: {}, correlation ID: {}]: {}", targetAddress, correlationId, result.cause().getMessage()); TracingHelper.logError(handler.three(), result.cause()); handler.one().handle(result); } } }
TracingHelper.logError(span, "no credentials found with matching type and client context"); } else { TracingHelper.logError(span, "no credentials found with matching type"); TracingHelper.logError(span, "no credentials found for auth-id"); TracingHelper.logError(span, "no credentials found for tenant");
/** * Marks an <em>OpenTracing</em> span as erroneous and logs an exception. * <p> * This method does <em>not</em> finish the span. * * @param span The span to mark. * @param error The exception that has occurred. If the exception is a * {@link ServiceInvocationException} then a {@link Tags#HTTP_STATUS} * tag is added containing the exception's error code property value. * @throws NullPointerException if error is {@code null}. */ protected final void logError(final Span span, final Throwable error) { if (span != null) { if (ServiceInvocationException.class.isInstance(error)) { final ServiceInvocationException e = (ServiceInvocationException) error; Tags.HTTP_STATUS.set(span, e.getErrorCode()); } TracingHelper.logError(span, error); } }
TracingHelper.logError(span, "no credentials found for tenant"); resultHandler.handle(Future.succeededFuture(CredentialsResult.from(HttpURLConnection.HTTP_NOT_FOUND))); } else { TracingHelper.logError(span, "no credentials found for device"); resultHandler.handle(Future.succeededFuture(CredentialsResult.from(HttpURLConnection.HTTP_NOT_FOUND))); } else {
TenantResult<JsonObject> getTenantResult(final String tenantId, final Span span) { final TenantObject tenant = tenants.get(tenantId); if (tenant == null) { TracingHelper.logError(span, "tenant not found"); return TenantResult.from(HttpURLConnection.HTTP_NOT_FOUND); } else { return TenantResult.from( HttpURLConnection.HTTP_OK, JsonObject.mapFrom(tenant), CacheDirective.maxAgeDirective(MAX_AGE_GET_TENANT)); } }
private TenantResult<JsonObject> getForCertificateAuthority(final X500Principal subjectDn, final Span span) { if (subjectDn == null) { TracingHelper.logError(span, "missing subject DN"); return TenantResult.from(HttpURLConnection.HTTP_BAD_REQUEST); } else { final TenantObject tenant = getByCa(subjectDn); if (tenant == null) { TracingHelper.logError(span, "no tenant found for subject DN"); return TenantResult.from(HttpURLConnection.HTTP_NOT_FOUND); } else { return TenantResult.from(HttpURLConnection.HTTP_OK, JsonObject.mapFrom(tenant), CacheDirective.maxAgeDirective(MAX_AGE_GET_TENANT)); } } }
/** * Settles the command message with the <em>rejected</em> outcome * and flows credit to the peer. * <p> * This method also finishes the OpenTracing span returned by * {@link #getCurrentSpan()}. * * @param errorCondition The error condition to send in the disposition frame (may be {@code null}). * @param credit The number of credits to flow to the peer. * @throws IllegalArgumentException if credit is negative. */ public void reject(final ErrorCondition errorCondition, final int credit) { final Rejected rejected = new Rejected(); final Map<String, Object> items = new HashMap<>(2); items.put(Fields.EVENT, "rejected command for device"); if (errorCondition != null) { rejected.setError(errorCondition); Optional.ofNullable(errorCondition.getDescription()).ifPresent(s -> items.put(Fields.MESSAGE, s)); } TracingHelper.logError(currentSpan, items); delivery.disposition(rejected, true); if (credit > 0) { flow(credit); } currentSpan.finish(); }
final Future<EventBusMessage> resultFuture; if (tenantId == null || payload == null) { TracingHelper.logError(span, "missing tenant and/or payload"); resultFuture = Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST)); } else { TracingHelper.logError(span, "missing type"); resultFuture = Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST)); } else if (authId != null && deviceId == null) { resultFuture = processGetByDeviceIdRequest(request, tenantId, type, deviceId, span); } else { TracingHelper.logError(span, String.format( "invalid search criteria [type: %s, device-id: %s, auth-id: %s]", type, deviceId, authId)); log.debug("get credentials request contains invalid search criteria [type: {}, device-id: {}, auth-id: {}]",
} else { LOG.debug("verification of client certificate failed: {}", verificationAttempt.cause().getMessage()); TracingHelper.logError(span, verificationAttempt.cause()); handler.handle(Future.failedFuture(UNAUTHORIZED));
final Future<EventBusMessage> resultFuture; if (tenantId == null && payload == null) { TracingHelper.logError(span, "request does not contain any query parameters"); log.debug("request does not contain any query parameters"); resultFuture = Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST)); TracingHelper.logError(span, "request does not contain any query parameters"); log.debug("payload does not contain any query parameters"); resultFuture = Future.failedFuture(new ClientErrorException(HttpURLConnection.HTTP_BAD_REQUEST));