@envelop/opentelemetry 3.4.0-alpha-e9434aa.0 → 3.4.0-alpha-05dbec7.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/esm/index.js +12 -39
  2. package/package.json +2 -2
package/esm/index.js CHANGED
@@ -1,35 +1,9 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.useOpenTelemetry = exports.AttributeName = void 0;
27
- const core_1 = require("@envelop/core");
28
- const api_1 = require("@opentelemetry/api");
29
- const opentelemetry = __importStar(require("@opentelemetry/api"));
30
- const tracing_1 = require("@opentelemetry/tracing");
31
- const graphql_1 = require("graphql");
32
- var AttributeName;
1
+ import { isAsyncIterable } from '@envelop/core';
2
+ import { SpanKind } from '@opentelemetry/api';
3
+ import * as opentelemetry from '@opentelemetry/api';
4
+ import { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
5
+ import { print } from 'graphql';
6
+ export var AttributeName;
33
7
  (function (AttributeName) {
34
8
  AttributeName["EXECUTION_ERROR"] = "graphql.execute.error";
35
9
  AttributeName["EXECUTION_RESULT"] = "graphql.execute.result";
@@ -41,12 +15,12 @@ var AttributeName;
41
15
  AttributeName["EXECUTION_OPERATION_NAME"] = "graphql.execute.operationName";
42
16
  AttributeName["EXECUTION_OPERATION_DOCUMENT"] = "graphql.execute.document";
43
17
  AttributeName["EXECUTION_VARIABLES"] = "graphql.execute.variables";
44
- })(AttributeName = exports.AttributeName || (exports.AttributeName = {}));
18
+ })(AttributeName || (AttributeName = {}));
45
19
  const tracingSpanSymbol = Symbol('OPEN_TELEMETRY_GRAPHQL');
46
- const useOpenTelemetry = (options, tracingProvider, spanKind = api_1.SpanKind.SERVER, spanAdditionalAttributes = {}, serviceName = 'graphql') => {
20
+ export const useOpenTelemetry = (options, tracingProvider, spanKind = SpanKind.SERVER, spanAdditionalAttributes = {}, serviceName = 'graphql') => {
47
21
  if (!tracingProvider) {
48
- tracingProvider = new tracing_1.BasicTracerProvider();
49
- tracingProvider.addSpanProcessor(new tracing_1.SimpleSpanProcessor(new tracing_1.ConsoleSpanExporter()));
22
+ tracingProvider = new BasicTracerProvider();
23
+ tracingProvider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
50
24
  tracingProvider.register();
51
25
  }
52
26
  const tracer = tracingProvider.getTracer(serviceName);
@@ -87,13 +61,13 @@ const useOpenTelemetry = (options, tracingProvider, spanKind = api_1.SpanKind.SE
87
61
  attributes: {
88
62
  ...spanAdditionalAttributes,
89
63
  [AttributeName.EXECUTION_OPERATION_NAME]: (_a = args.operationName) !== null && _a !== void 0 ? _a : undefined,
90
- [AttributeName.EXECUTION_OPERATION_DOCUMENT]: (0, graphql_1.print)(args.document),
64
+ [AttributeName.EXECUTION_OPERATION_DOCUMENT]: print(args.document),
91
65
  ...(options.variables ? { [AttributeName.EXECUTION_VARIABLES]: JSON.stringify((_b = args.variableValues) !== null && _b !== void 0 ? _b : {}) } : {}),
92
66
  },
93
67
  });
94
68
  const resultCbs = {
95
69
  onExecuteDone({ result }) {
96
- if ((0, core_1.isAsyncIterable)(result)) {
70
+ if (isAsyncIterable(result)) {
97
71
  executionSpan.end();
98
72
  // eslint-disable-next-line no-console
99
73
  console.warn(`Plugin "newrelic" encountered a AsyncIterator which is not supported yet, so tracing data is not available for the operation.`);
@@ -120,4 +94,3 @@ const useOpenTelemetry = (options, tracingProvider, spanKind = api_1.SpanKind.SE
120
94
  },
121
95
  };
122
96
  };
123
- exports.useOpenTelemetry = useOpenTelemetry;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@envelop/opentelemetry",
3
- "version": "3.4.0-alpha-e9434aa.0",
3
+ "version": "3.4.0-alpha-05dbec7.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "2.4.0-alpha-e9434aa.0",
6
+ "@envelop/core": "2.4.0-alpha-05dbec7.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {