class HttpSampler implements SamplerFunction<HttpRequest> {

  @Override @Nullable public Boolean trySample(HttpRequest request) {
    if (request == null) return null;

    Object unwrapped = request.unwrap();
    if (unwrapped == null) unwrapped = NULL_SENTINEL; // Ensure adapter methods never see null

    HttpAdapter<Object, Void> adapter;
    if (request instanceof HttpClientRequest) {
      adapter = new HttpClientAdapters.ToRequestAdapter((HttpClientRequest) request, unwrapped);
    } else {
      adapter = new HttpServerAdapters.ToRequestAdapter((HttpServerRequest) request, unwrapped);
    }

    return trySample(adapter, unwrapped);
  }

}