99designs / gqlgen-contrib

Add-ons for gqlgen
The Unlicense
89 stars 34 forks source link

Added opencensus metrics #18

Closed cliedeman closed 4 years ago

cliedeman commented 5 years ago

TODO:

Prometheus Test Results

# HELP graphql_request_completed_total Total number of requests completed on the graphql server.
# TYPE graphql_request_completed_total counter
graphql_request_completed_total 100
# HELP graphql_request_duration_ms The time taken to handle a request by graphql server.
# TYPE graphql_request_duration_ms histogram
graphql_request_duration_ms_bucket{exitStatus="success",le="1"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="2"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="4"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="8"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="16"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="32"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="64"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="128"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="256"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="512"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="1024"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="+Inf"} 100
graphql_request_duration_ms_sum{exitStatus="success"} 0
graphql_request_duration_ms_count{exitStatus="success"} 100
# HELP graphql_request_started_total Total number of requests started on the graphql server.
# TYPE graphql_request_started_total counter
graphql_request_started_total 100
# HELP graphql_resolver_completed_total Total number of resolver completed on the graphql server.
# TYPE graphql_resolver_completed_total counter
graphql_resolver_completed_total{field="id",object="Todo"} 300
graphql_resolver_completed_total{field="text",object="Todo"} 300
graphql_resolver_completed_total{field="todos",object="Query"} 100
# HELP graphql_resolver_duration_ms The time taken to resolve a field by graphql server.
# TYPE graphql_resolver_duration_ms histogram
graphql_resolver_duration_ms_bucket{exitStatus="success",le="1"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="2"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="4"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="8"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="16"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="32"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="64"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="128"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="256"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="512"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="1024"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="+Inf"} 700
graphql_resolver_duration_ms_sum{exitStatus="success"} 0
graphql_resolver_duration_ms_count{exitStatus="success"} 700
# HELP graphql_resolver_started_total Total number of resolver started on the graphql server.
# TYPE graphql_resolver_started_total counter
graphql_resolver_started_total{field="id",object="Todo"} 300
graphql_resolver_started_total{field="text",object="Todo"} 300
graphql_resolver_started_total{field="todos",object="Query"} 100

Opencensus Results

# HELP graphql_request_completed_total Total number of requests completed on the graphql server.
# TYPE graphql_request_completed_total counter
graphql_request_completed_total 100
# HELP graphql_request_duration_ms The time taken to handle a request by graphql server.
# TYPE graphql_request_duration_ms histogram
graphql_request_duration_ms_bucket{exitStatus="success",le="4.294967296e+09"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="8.589934592e+09"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="1.2884901888e+10"} 100
graphql_request_duration_ms_bucket{exitStatus="success",le="+Inf"} 100
graphql_request_duration_ms_sum{exitStatus="success"} 0
graphql_request_duration_ms_count{exitStatus="success"} 100
# HELP graphql_request_started_total Total number of requests started on the graphql server.
# TYPE graphql_request_started_total counter
graphql_request_started_total 100
# HELP graphql_resolver_completed_total Total number of resolver completed on the graphql server.
# TYPE graphql_resolver_completed_total counter
graphql_resolver_completed_total{field="",object=""} 700
# HELP graphql_resolver_duration_ms The time taken to resolve a field by graphql server.
# TYPE graphql_resolver_duration_ms histogram
graphql_resolver_duration_ms_bucket{exitStatus="success",le="4.294967296e+09"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="8.589934592e+09"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="1.2884901888e+10"} 700
graphql_resolver_duration_ms_bucket{exitStatus="success",le="+Inf"} 700
graphql_resolver_duration_ms_sum{exitStatus="success"} 0
graphql_resolver_duration_ms_count{exitStatus="success"} 700
# HELP graphql_resolver_started_total Total number of resolver started on the graphql server.
# TYPE graphql_resolver_started_total counter
graphql_resolver_started_total{field="id",object="Todo"} 300
graphql_resolver_started_total{field="text",object="Todo"} 300
graphql_resolver_started_total{field="todos",object="Query"} 100
vvakame commented 4 years ago

@cliedeman sorry for very late response. Do you use this middleware in your production app?

I'm using below OC tracer. https://gist.github.com/vvakame/f966bdb8d8693257b9a6b39fd3312141 I think we needs some customizability. 🤔

cliedeman commented 4 years ago

Hi @vvakame I am not running gqlgen in production yet.

Should we try to merge the metrics in your version with the one in this library?

Metrics are very opinionated so I wouldn't bother with customisation too much but provide a good starting point for gqlgen users.

Ciaran

vvakame commented 4 years ago

sorry for late response. and, I'm trying my implementation in our production environment. I found a lot of issues... so, I'll try to merge our implementations next. please wait a couple of weeks...

cliedeman commented 4 years ago

Closing this. The tracing implementation has changed and I have decided to stay with opentracing until open telemetry hits stable - https://opentelemetry.io/project-status/

https://github.com/99designs/gqlgen/commit/bc98156929b06eeca1d95f475501470bd9034c2d#diff-c8f84f9dafb0af18ac536c527135d68d

cliedeman commented 4 years ago

@vvakame I created a work in progress opencensus gist