Nordstrom / xrpc

Simple, production ready Java API server built on top of functional composition.
Apache License 2.0
17 stars 17 forks source link

Metrics endpoint is not returning correct value #172

Closed xjdr closed 6 years ago

xjdr commented 6 years ago

Summary

the /metrics/ endpoint is not returning the correct value. For HTTP/2 requests, the response is invalid. For http/1.1 it returns the metrics module name.

Steps to reproduce

$ curl -k https://localhost:8080/metrics -vvv (for http 2) $ curl -k https://localhost:8080/metrics -vvv --http1.1

Expected behavior

Should return the metrics as collected in JSON format.

Actual behavior

$ curl -k https://localhost:8080/metrics -vvv
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /usr/local/etc/openssl/cert.pem
  CApath: /usr/local/etc/openssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: C=US; ST=IL; L=Chicago; O=xio2; OU=dev; CN=xio2.example.com
*  start date: Aug 12 19:35:09 2015 GMT
*  expire date: Jun  1 19:35:09 2018 GMT
*  issuer: C=US; ST=IL; L=Chicago; O=xio2; OU=dev; CN=xio2.example.com
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7fd03b80b000)
> GET /metrics HTTP/2
> Host: localhost:8080
> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
> Accept: */*
> Referer:
>
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
* Failed receiving HTTP2 data
* Connection #0 to host localhost left intact
curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54

$ curl -k https://localhost:8080/metrics -vvv --http1.1
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /usr/local/etc/openssl/cert.pem
  CApath: /usr/local/etc/openssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: C=US; ST=IL; L=Chicago; O=xio2; OU=dev; CN=xio2.example.com
*  start date: Aug 12 19:35:09 2015 GMT
*  expire date: Jun  1 19:35:09 2018 GMT
*  issuer: C=US; ST=IL; L=Chicago; O=xio2; OU=dev; CN=xio2.example.com
*  SSL certificate verify result: self signed certificate (18), continuing anyway.
> GET /metrics HTTP/1.1
> Host: localhost:8080
> User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
> Accept: */*
> Referer:
>
< HTTP/1.1 200 OK
< content-type: application/json
< content-length: 86
<
{
  "moduleName" : "metrics",
  "typeId" : "com.codahale.metrics.json.MetricsModule"
* Connection #0 to host localhost left intact
}

Minimal yet complete reproducer code (or URL to code)

(see above)

xrpc version

git master as of March, 10 2018