@envelop/opentelemetry 3.4.0-alpha-26c4ae2.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +62 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ ## `@envelop/opentelemetry`
2
+
3
+ This plugins integrates [Open Telemetry](https://opentelemetry.io/) tracing with your GraphQL execution. It also collects GraphQL execution errors and reports it as Exceptions.
4
+
5
+ You can use this plugin with any kind of Open Telemetry [tracer](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#tracer), and integrate it to any tracing/metric platform that supports this standard.
6
+
7
+ ## Getting Started
8
+
9
+ ```
10
+ yarn add @envelop/opentelemetry
11
+ ```
12
+
13
+ ## Usage Example
14
+
15
+ By default, this plugin prints the collected telemetry to the console:
16
+
17
+ ```ts
18
+ import { envelop } from '@envelop/core';
19
+ import { useOpenTelemetry } from '@envelop/opentelemetry';
20
+
21
+ const getEnveloped = envelop({
22
+ plugins: [
23
+ // ... other plugins ...
24
+ useOpenTelemetry({
25
+ resolvers: true, // Tracks resolvers calls, and tracks resolvers thrown errors
26
+ variables: true, // Includes the operation variables values as part of the metadata collected
27
+ result: true, // Includes execution result object as part of the metadata collected
28
+ }),
29
+ ],
30
+ });
31
+ ```
32
+
33
+ If you wish to use custom tracer/exporter, create it and pass it. This example integrates Jaeger tracer:
34
+
35
+ ```ts
36
+ import { envelop } from '@envelop/core';
37
+ import { useOpenTelemetry } from '@envelop/opentelemetry';
38
+ import { JaegerExporter } from '@opentelemetry/exporter-jaeger';
39
+ import { SimpleSpanProcessor, BasicTracerProvider } from '@opentelemetry/tracing';
40
+
41
+ const exporter = new JaegerExporter({
42
+ serviceName: 'my-service-name',
43
+ });
44
+
45
+ const provider = new BasicTracerProvider();
46
+ provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
47
+ provider.register();
48
+
49
+ const getEnveloped = envelop({
50
+ plugins: [
51
+ // ... other plugins ...
52
+ useOpenTelemetry(
53
+ {
54
+ resolvers: true, // Tracks resolvers calls, and tracks resolvers thrown errors
55
+ variables: true, // Includes the operation variables values as part of the metadata collected
56
+ result: true, // Includes execution result object as part of the metadata collected
57
+ },
58
+ provider
59
+ ),
60
+ ],
61
+ });
62
+ ```
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/opentelemetry",
3
- "version": "3.4.0-alpha-26c4ae2.0",
3
+ "version": "3.4.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-26c4ae2.0",
6
+ "@envelop/core": "^2.4.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {