Python library for tracing graphql calls with Datadog
Project description
Python library to trace graphql calls with Datadog.
Screenshots for pyramid app serving GraphQL with tracing enabled:
Installation
Using pip
$ pip install ddtrace-graphql
From source
$ git clone https://github.com/beezz/ddtrace-graphql.git
$ cd ddtrace-graphql && python setup.py install
Usage
To trace all GraphQL requests patch the library. Put this snippet to your application main entry point.
__import__('ddtrace_graphql').patch()
# OR
from ddtrace_graphql import patch
patch()
Check out the datadog trace client for all supported libraries and frameworks.
# app/__init__.py
__import__('ddtrace_graphql').patch()
# from that point all calls to graphql are traced
from graphql import graphql
result = graphql(schema, query)
Trace only certain calls with traced_graphql function
from ddtrace_graphql import traced_graphql
traced_graphql(schema, query)
Configuration
Environment variables
- DDTRACE_GRAPHQL_SERVICE:
Define service name under which traces are shown in Datadog. Default value is graphql
$ export DDTRACE_GRAPHQL_SERVICE=foobar.graphql
span_kwargs
Default arguments passed to the tracing context manager can be updated using span_kwargs argument of ddtrace_graphql.patch or ddtrace_graphql.traced_graphql functions.
Default values:
- name:
Wrapped resource name. Default graphql.graphql.
- span_type:
Span type. Default graphql.
- service:
Service name. Defaults to DDTRACE_GRAPHQL_SERVICE environment variable if present, else graphql.
- resource:
Processed resource. Defaults to query / mutation signature.
For more information visit ddtrace.Tracer.trace documentation.
from ddtrace_graphql import patch
patch(span_kwargs=dict(service='foo.graphql'))
from ddtrace_graphql import traced_graphql
traced_graphql(schema, query, span_kwargs=dict(resource='bar.resource'))
Development
Install from source in development mode
$ git clone https://github.com/beezz/ddtrace-graphql.git
$ pip install --editable ddtrace-graphql[test]
Run tests
$ cd ddtrace-graphql
$ tox
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ddtrace_graphql-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e2de24051146703a11ce68ea31b317d4b918b8d340c4343be2f98e6667db8df |
|
MD5 | 61c33b1414ec69ea90e9b09c063f239b |
|
BLAKE2b-256 | c3ac3d59f0c6dd3ab9000f8998bec386a0040010b85a83ea8743e12b948fe5b5 |