Comments (16)
Another possibility (alluded to by @KyleAMathews) is adding a __duration
field to every field:
query {
viewer {
__duration
name {
__duration
}
}
}
Might be too complex/backwards-incompatible (i.e. now name
can either be a scalar or an instrumented type). But it has the benefit that now all you need to do is traverse the GraphQL data response to get instrumentation data, instead of a per-implementation API
from graphql-js.
And the live updating monitor of queries would also be huge to use during development as it'd give a lot of insight to what's actually happening under the hood. Very helpful to those new to GraphQL (read everyone) to help understand how the system works and also very helpful when prototyping new types.
from graphql-js.
+1 to this.
from graphql-js.
Wow, that's a great idea! Even if it doesn't make it into the spec, seems like servers could implement it and expose it through the extensions
key (http://facebook.github.io/graphql/#sec-Response-Format)
from graphql-js.
@rmosolgo as I understand it, there wouldn't need to be any changes to the spec. The metrics gathering / logging would be handled internally and be exposed as built-in types e.g. queryLogType
from graphql-js.
So you could do queries something like:
query slowQueries {
queryLog(durationGreaterThan: "100", since: "2015-08-08T18:58:27+00:00") {
type
duration
fields {
name
description
duration
}
}
}
from graphql-js.
We do something really similar to what's proposed here!
We actually do not query the results of query executions using GraphQL itself, but we do have a logging interface throughout GraphQL which allows us to measure access and performance on a per-field basis.
from graphql-js.
@leebyron do you see value in standardizing a type or two for exposing this data? I think that'd be a boon to the GraphQL ecosystem as it'd allow a lot of new or existing Ops tools to be build on top of or integrated with GraphQL which is absolutely necessary for widespread adoption.
from graphql-js.
I think it's way too early to standardize that. We have our internal representation of this which is extremely specific to our internal metric tools. Standardizing what we have would mean no one would pay attention to the standard. Standardizing something else would mean the thing we have is not really standard.
If a standard emerges across many implementations that tools are taking advantage of, then we should consider a standardization effort. Otherwise I think this fits well into the realm of experimentation.
from graphql-js.
It's also not entirely clear to me that this kind of metadata needs to be exposed through GraphQL itself. We have lots of ops tools that measure GraphQL usage but do not expose their data through GraphQL since our client applications do not need access to that information - but our infrastructure ops systems do and GraphQL is not the right tool for their data access needs.
The important piece that I'm excited to add here is a logging interface which will allow for flexibility in connecting any type of ops service to measure GraphQL usage.
from graphql-js.
I agree with your argument that it'd be too early to standardize any sort of types. I'll experiment with creating types internally and report back.
from graphql-js.
Huey Petersen just wrote this http://hueypetersen.com/posts/2015/11/06/instrumenting-graphql-js/
from graphql-js.
I used the information above and hackily implemented a simple API in GraphQLHub.
Some ideas on a first-class API:
// on the Schema objects
let schema = new GraphQLSchema();
schema.instrumentation((instrumentation) => {
});
// at the graphql fn level
// opt-in is probably best to remove perf overhead
graphql(schema, query, { instrumentation : true }).then((result) => {
console.log(result.instrumentation);
});
// perhaps support it at the express-graphql level, which returns it inside `extensions.instrumentation`)
graphqlHTTP({ schema: MyGraphQLSchema, instrumentation: true });
// or via a callback
let handleInstrumentation = (instrumentation) => ...
graphqlHTTP({ schema: MyGraphQLSchema, instrumentation: handleInstrumentation });
from graphql-js.
I think Apollo Optics is the first one to do it.
we can get some insights from them
from graphql-js.
Any progress on this? Any suggestions for instrumenting graphql-js?
from graphql-js.
I think #1516 would a good first step and allow 3rd-party dev to produce middlewares that will work with any graphql-js
based server. After that as Lee suggested we need to observe and standardize emerging pattern.
It's the only realistic goal that we have ATM so I'm closing this issue in favor of #1516
from graphql-js.
Related Issues (20)
- IHeyReally.org
- Suggestion: Bundling in v17, ESM, CJS, and the dual package hazard HOT 9
- Just to give my 2c, I'm not sure if `exports.development` and `exports.production` target conditionsa are widely supported, so some `import.env` shenanigans may still be necessary until that's widely adopted. HOT 1
- Collection of libraries and how they import from `graphql` HOT 20
- `process.env`, `globalThis`, and `typeof process` HOT 21
- Introspection queries don't support `@oneOf` HOT 2
- Tutorial data HOT 2
- astFromValue fails with a custom scalar serializing to an object value HOT 5
- In a response to a query about an Issue, the URL and other info is missing for links created with Reference editor button HOT 5
- author/committer -> user fields returning NULL for commits committed by user
- [email protected]
- npm link with graphql package breaks application HOT 2
- IHeyReally.com HOT 1
- Can I ask what is the progress here? Is there a solution being worked on? Do we have some timeline? Or progress with issue? Thanks!
- IHeyReally.com
- Typescript error with 16.9.0 (re ThunkObjMap) HOT 3
- Notice: default branch is now `16.x.x` HOT 2
- <a href="https://api.easycla.lfx.linuxfoundation.org/v2/repository-provider/github/sign/12261526/38307428/4135/#/?version=2"><img src="https://s3.amazonaws.com/cla-project-logo-prod/cla-not-signed.svg" alt="CLA Not Signed" align="left" height="28" width="328"></a><br/><br /><ul><li><a href='https://api.easycla.lfx.linuxfoundation.org/v2/repository-provider/github/sign/12261526/38307428/4135/#/?version=2' target='_blank'>:x:</a> - login: @Heyitsquoracom / name: [email protected] . The commit (b6081f914f0c5c22ee48d26aff4b473bf17627ce) is not authorized under a signed CLA. <a href='https://api.easycla.lfx.linuxfoundation.org/v2/repository-provider/github/sign/12261526/38307428/4135/#/?version=2' target='_blank'>Please click here to be authorized</a>. For further assistance with EasyCLA, <a href='https://jira.linuxfoundation.org/servicedesk/customer/portal/4' target='_blank'>please submit a support request ticket</a>.</li></ul><!-- Date Modified: 2024-06-28 04:40:51.630768 -->
- Error with version v16.9.0: `Can't resolve '@apollo/subgraph/dist/directives''` HOT 1
- Type is incorrect in graphql ExecutionResult with new type GraphQLFormattedError HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-js.