@graphql-hive/plugin-opentelemetry 1.2.2-rc-70ab4bd21a7f4dd67d993b256d03184f5f6129d8 → 1.3.0-alpha-10edca19a47a0212f09bb75e24751faa4186544a
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.
- package/CHANGELOG.md +30 -3
- package/dist/attributes-BjUFTXMN.d.ts +16 -0
- package/dist/index.cjs +7 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{plugin-DSqlDQ_l.js → plugin-CW1kfhP8.js} +154 -38
- package/dist/{plugin-BsCbZ1j2.cjs → plugin-uVxk_ok_.cjs} +164 -42
- package/dist/setup.cjs +10 -13
- package/dist/setup.d.cts +2 -2
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +6 -15
- package/package.json +4 -3
- package/dist/attributes-mikIPKnv.d.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
# @graphql-hive/plugin-opentelemetry
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.3.0-alpha-10edca19a47a0212f09bb75e24751faa4186544a
|
|
4
|
+
### Minor Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#1636](https://github.com/graphql-hive/gateway/pull/1636) [`f19b9ef`](https://github.com/graphql-hive/gateway/commit/f19b9ef6994fbabefa85f1f9e2527ca79223fb6a) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - Expose GraphQLError as OpenTelemetry Events.
|
|
9
|
+
|
|
10
|
+
Errors contains in the result of a graphql operation are now reported as standalone OpenTelemetry
|
|
11
|
+
Events (name `graphql.error`) instead of OpenTelemetry Exceptions.
|
|
12
|
+
|
|
13
|
+
This is aligned with the guidance of the Graphql OpenTelemetry working group.
|
|
14
|
+
|
|
15
|
+
It allows to add more graphql specific attributes to errors reported in a response:
|
|
16
|
+
|
|
17
|
+
- `message`: The error message
|
|
18
|
+
- `path`: The path in the operation document from which the error originated
|
|
19
|
+
- `locations`: The list of related locations in the document source
|
|
20
|
+
- `coordinate`: The schema coordinate of the resolver which is the source of the error
|
|
21
|
+
|
|
22
|
+
This brings the experimental support of the `coordinate` error attribute in the Yoga Runtime. For
|
|
23
|
+
security reason, this attribute is purposefully not serialized, to avoid leaking schema information
|
|
24
|
+
to clients.
|
|
25
|
+
|
|
4
26
|
### Patch Changes
|
|
5
27
|
|
|
6
28
|
|
|
7
29
|
|
|
30
|
+
- [#1636](https://github.com/graphql-hive/gateway/pull/1636) [`bff4e5b`](https://github.com/graphql-hive/gateway/commit/bff4e5b5189c0962b14de4b58f03e7cc6cfd3fdc) Thanks [@EmrysMyrddin](https://github.com/EmrysMyrddin)! - dependencies updates:
|
|
31
|
+
|
|
32
|
+
- Added dependency [`@graphql-tools/executor@^1.4.9` ↗︎](https://www.npmjs.com/package/@graphql-tools/executor/v/1.4.9) (to `dependencies`)
|
|
33
|
+
|
|
34
|
+
|
|
8
35
|
- [#1725](https://github.com/graphql-hive/gateway/pull/1725) [`0ded04f`](https://github.com/graphql-hive/gateway/commit/0ded04f56d9d9dea8c412e2e320fb89815108362) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
|
|
9
36
|
|
|
10
37
|
- Updated dependency [`@graphql-hive/core@^0.15.1` ↗︎](https://www.npmjs.com/package/@graphql-hive/core/v/0.15.1) (from `^0.13.2`, in `dependencies`)
|
|
11
|
-
- Updated dependencies [[`0ded04f`](https://github.com/graphql-hive/gateway/commit/0ded04f56d9d9dea8c412e2e320fb89815108362)]:
|
|
12
|
-
- @graphql-hive/gateway-runtime@2.
|
|
38
|
+
- Updated dependencies [[`cc0feba`](https://github.com/graphql-hive/gateway/commit/cc0feba56c0bf379a3d5aed326b3db1abf7c4681), [`0ded04f`](https://github.com/graphql-hive/gateway/commit/0ded04f56d9d9dea8c412e2e320fb89815108362), [`f19b9ef`](https://github.com/graphql-hive/gateway/commit/f19b9ef6994fbabefa85f1f9e2527ca79223fb6a)]:
|
|
39
|
+
- @graphql-hive/gateway-runtime@2.4.0-alpha-10edca19a47a0212f09bb75e24751faa4186544a
|
|
13
40
|
|
|
14
41
|
## 1.2.1
|
|
15
42
|
### Patch Changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const SEMATTRS_GRAPHQL_DOCUMENT = "graphql.document";
|
|
2
|
+
declare const SEMATTRS_GRAPHQL_OPERATION_TYPE = "graphql.operation.type";
|
|
3
|
+
declare const SEMATTRS_GRAPHQL_OPERATION_NAME = "graphql.operation.name";
|
|
4
|
+
declare const SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = "hive.graphql.operation.hash";
|
|
5
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = "hive.graphql.error.count";
|
|
6
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = "hive.graphql.error.codes";
|
|
7
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES = "hive.graphql.error.coordinates";
|
|
8
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_CODE = "hive.graphql.error.code";
|
|
9
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE = "hive.graphql.error.coordinate";
|
|
10
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_PATH = "hive.graphql.error.path";
|
|
11
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE = "hive.graphql.error.message";
|
|
12
|
+
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS = "hive.graphql.error.locations";
|
|
13
|
+
declare const SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = "hive.gateway.upstream.subgraph.name";
|
|
14
|
+
declare const SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = "hive.gateway.operation.subgraph.names";
|
|
15
|
+
|
|
16
|
+
export { SEMATTRS_GRAPHQL_DOCUMENT as S, SEMATTRS_GRAPHQL_OPERATION_TYPE as a, SEMATTRS_GRAPHQL_OPERATION_NAME as b, SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH as c, SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT as d, SEMATTRS_HIVE_GRAPHQL_ERROR_CODES as e, SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES as f, SEMATTRS_HIVE_GRAPHQL_ERROR_CODE as g, SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE as h, SEMATTRS_HIVE_GRAPHQL_ERROR_PATH as i, SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE as j, SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS as k, SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME as l, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES as m };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var plugin = require('./plugin-
|
|
3
|
+
var plugin = require('./plugin-uVxk_ok_.cjs');
|
|
4
4
|
var api = require('@opentelemetry/api');
|
|
5
5
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
6
6
|
require('@graphql-hive/gateway-runtime');
|
|
@@ -19,8 +19,14 @@ exports.SEMATTRS_GRAPHQL_OPERATION_NAME = plugin.SEMATTRS_GRAPHQL_OPERATION_NAME
|
|
|
19
19
|
exports.SEMATTRS_GRAPHQL_OPERATION_TYPE = plugin.SEMATTRS_GRAPHQL_OPERATION_TYPE;
|
|
20
20
|
exports.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = plugin.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES;
|
|
21
21
|
exports.SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = plugin.SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME;
|
|
22
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODE = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_CODE;
|
|
22
23
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES;
|
|
23
24
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT;
|
|
25
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS;
|
|
26
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE;
|
|
27
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_PATH = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_PATH;
|
|
28
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE;
|
|
29
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES;
|
|
24
30
|
exports.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = plugin.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH;
|
|
25
31
|
exports.useOpenTelemetry = plugin.useOpenTelemetry;
|
|
26
32
|
Object.defineProperty(exports, "OpenTelemetryDiagLogLevel", {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { O as OpenTelemetryContextExtension, a as OpenTelemetryGatewayPluginOptions, b as OpenTelemetryPlugin, c as OpenTelemetryPluginUtils, u as useOpenTelemetry } from './plugin-BBy_tfA5.js';
|
|
2
2
|
export { DiagLogLevel as OpenTelemetryDiagLogLevel } from '@opentelemetry/api';
|
|
3
|
-
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE,
|
|
3
|
+
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE, m as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, l as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, g as SEMATTRS_HIVE_GRAPHQL_ERROR_CODE, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, k as SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS, j as SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE, i as SEMATTRS_HIVE_GRAPHQL_ERROR_PATH, h as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE, f as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-BjUFTXMN.js';
|
|
4
4
|
export { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_SERVER_NAME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_NAME } from '@opentelemetry/semantic-conventions';
|
|
5
5
|
import '@graphql-hive/gateway-runtime';
|
|
6
6
|
import '@graphql-tools/utils';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { O as OpenTelemetryContextExtension, a as OpenTelemetryGatewayPluginOptions, b as OpenTelemetryPlugin, c as OpenTelemetryPluginUtils, u as useOpenTelemetry } from './plugin-BBy_tfA5.js';
|
|
2
2
|
export { DiagLogLevel as OpenTelemetryDiagLogLevel } from '@opentelemetry/api';
|
|
3
|
-
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE,
|
|
3
|
+
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE, m as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, l as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, g as SEMATTRS_HIVE_GRAPHQL_ERROR_CODE, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, k as SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS, j as SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE, i as SEMATTRS_HIVE_GRAPHQL_ERROR_PATH, h as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE, f as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-BjUFTXMN.js';
|
|
4
4
|
export { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_SERVER_NAME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_NAME } from '@opentelemetry/semantic-conventions';
|
|
5
5
|
import '@graphql-hive/gateway-runtime';
|
|
6
6
|
import '@graphql-tools/utils';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE,
|
|
1
|
+
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE, m as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, l as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, g as SEMATTRS_HIVE_GRAPHQL_ERROR_CODE, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, k as SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS, j as SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE, i as SEMATTRS_HIVE_GRAPHQL_ERROR_PATH, h as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE, f as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH, u as useOpenTelemetry } from './plugin-CW1kfhP8.js';
|
|
2
2
|
export { DiagLogLevel as OpenTelemetryDiagLogLevel } from '@opentelemetry/api';
|
|
3
3
|
export { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_SERVER_NAME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_NAME } from '@opentelemetry/semantic-conventions';
|
|
4
4
|
import '@graphql-hive/gateway-runtime';
|
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { isRetryExecutionRequest as isRetryExecutionRequest$1, getRetryInfo as getRetryInfo$1, Logger } from '@graphql-hive/gateway-runtime';
|
|
2
2
|
import { getHeadersObj } from '@graphql-mesh/utils';
|
|
3
|
-
import { isAsyncIterable, getOperationASTFromDocument, fakePromise } from '@graphql-tools/utils';
|
|
3
|
+
import { isAsyncIterable, getOperationASTFromDocument, getSchemaCoordinate, fakePromise } from '@graphql-tools/utils';
|
|
4
4
|
import { unfakePromise } from '@whatwg-node/promise-helpers';
|
|
5
5
|
import { hive } from './api.js';
|
|
6
6
|
import { trace, SpanStatusCode, context, ROOT_CONTEXT, SpanKind, DiagLogLevel, diag, propagation } from '@opentelemetry/api';
|
|
7
7
|
import { hashOperation } from '@graphql-hive/core';
|
|
8
8
|
import { defaultPrintFn } from '@graphql-mesh/transport-common';
|
|
9
|
-
import { SEMATTRS_EXCEPTION_STACKTRACE, SEMATTRS_EXCEPTION_MESSAGE, SEMATTRS_EXCEPTION_TYPE, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_URL, SEMATTRS_NET_HOST_NAME, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_CLIENT_IP } from '@opentelemetry/semantic-conventions';
|
|
9
|
+
import { SEMATTRS_EXCEPTION_STACKTRACE, SEMATTRS_EXCEPTION_MESSAGE, SEMATTRS_EXCEPTION_TYPE, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_URL, SEMATTRS_NET_HOST_NAME, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_HTTP_CLIENT_IP, ATTR_EXCEPTION_STACKTRACE } from '@opentelemetry/semantic-conventions';
|
|
10
10
|
import { printSchema, TypeInfo } from 'graphql';
|
|
11
11
|
|
|
12
|
+
function useErrorCoordinate() {
|
|
13
|
+
return {
|
|
14
|
+
onExecute({ args }) {
|
|
15
|
+
args.schemaCoordinateInErrors = true;
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
12
20
|
class OtelContextStack {
|
|
13
21
|
#root;
|
|
14
22
|
#current;
|
|
@@ -122,6 +130,12 @@ const SEMATTRS_GRAPHQL_OPERATION_NAME = "graphql.operation.name";
|
|
|
122
130
|
const SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = "hive.graphql.operation.hash";
|
|
123
131
|
const SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = "hive.graphql.error.count";
|
|
124
132
|
const SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = "hive.graphql.error.codes";
|
|
133
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES = "hive.graphql.error.coordinates";
|
|
134
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_CODE = "hive.graphql.error.code";
|
|
135
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE = "hive.graphql.error.coordinate";
|
|
136
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_PATH = "hive.graphql.error.path";
|
|
137
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE = "hive.graphql.error.message";
|
|
138
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS = "hive.graphql.error.locations";
|
|
125
139
|
const SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = "hive.gateway.upstream.subgraph.name";
|
|
126
140
|
const SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = "hive.gateway.operation.subgraph.names";
|
|
127
141
|
|
|
@@ -241,7 +255,27 @@ function setGraphQLParseAttributes(input) {
|
|
|
241
255
|
span.setAttribute(SEMATTRS_GRAPHQL_DOCUMENT, input.query);
|
|
242
256
|
}
|
|
243
257
|
if (input.result instanceof Error) {
|
|
244
|
-
|
|
258
|
+
if (isGraphQLError(input.result)) {
|
|
259
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, 1);
|
|
260
|
+
span.setStatus({
|
|
261
|
+
code: SpanStatusCode.ERROR,
|
|
262
|
+
message: "GraphQL Parse Error"
|
|
263
|
+
});
|
|
264
|
+
const operationSpan = trace.getSpan(input.operationCtx);
|
|
265
|
+
if (operationSpan) {
|
|
266
|
+
recordGraphqlErrors(
|
|
267
|
+
operationSpan,
|
|
268
|
+
[input.result],
|
|
269
|
+
"GraphQL Parse Error"
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
span.recordException(input.result);
|
|
274
|
+
span.setStatus({
|
|
275
|
+
code: SpanStatusCode.ERROR,
|
|
276
|
+
message: input.result.message
|
|
277
|
+
});
|
|
278
|
+
}
|
|
245
279
|
} else {
|
|
246
280
|
const document = input.result;
|
|
247
281
|
const operation = getOperationFromDocument(document, input.operationName);
|
|
@@ -280,21 +314,34 @@ function setGraphQLValidateAttributes(input) {
|
|
|
280
314
|
if (result instanceof Error) {
|
|
281
315
|
errors.push(result);
|
|
282
316
|
}
|
|
283
|
-
if (errors.length
|
|
317
|
+
if (errors.length === 0) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const graphqlErrors = [];
|
|
321
|
+
const exceptions = [];
|
|
322
|
+
for (const error of errors) {
|
|
323
|
+
(isGraphQLError(error) ? graphqlErrors : exceptions).push(error);
|
|
324
|
+
}
|
|
325
|
+
if (graphqlErrors.length > 0) {
|
|
284
326
|
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.length);
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
codes.push(`${error.extensions.code}`);
|
|
293
|
-
}
|
|
294
|
-
span.recordException(error);
|
|
327
|
+
const operationSpan = trace.getSpan(input.operationCtx);
|
|
328
|
+
if (operationSpan) {
|
|
329
|
+
recordGraphqlErrors(
|
|
330
|
+
operationSpan,
|
|
331
|
+
graphqlErrors,
|
|
332
|
+
"GraphQL Validation Error"
|
|
333
|
+
);
|
|
295
334
|
}
|
|
296
|
-
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
297
335
|
}
|
|
336
|
+
if (exceptions.length > 0) {
|
|
337
|
+
for (const exception of exceptions) {
|
|
338
|
+
span.recordException(exception);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
span.setStatus({
|
|
342
|
+
code: SpanStatusCode.ERROR,
|
|
343
|
+
message: "GraphQL Validation Error"
|
|
344
|
+
});
|
|
298
345
|
}
|
|
299
346
|
function createGraphQLExecuteSpan(input) {
|
|
300
347
|
const span = input.tracer.startSpan(
|
|
@@ -333,33 +380,30 @@ function setGraphQLExecutionAttributes(input) {
|
|
|
333
380
|
}
|
|
334
381
|
}
|
|
335
382
|
function setGraphQLExecutionResultAttributes(input) {
|
|
336
|
-
const { ctx, result } = input;
|
|
383
|
+
const { ctx, operationCtx, result } = input;
|
|
337
384
|
const span = trace.getSpan(ctx);
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
);
|
|
385
|
+
if (span) {
|
|
386
|
+
if (input.subgraphNames?.length) {
|
|
387
|
+
span.setAttribute(
|
|
388
|
+
SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES,
|
|
389
|
+
input.subgraphNames
|
|
390
|
+
);
|
|
391
|
+
}
|
|
346
392
|
}
|
|
393
|
+
const operationSpan = trace.getSpan(operationCtx);
|
|
347
394
|
if (!isAsyncIterable(result) && // FIXME: Handle async iterable too
|
|
348
395
|
result.errors && result.errors.length > 0) {
|
|
349
|
-
span
|
|
350
|
-
span
|
|
396
|
+
span?.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.errors.length);
|
|
397
|
+
span?.setStatus({
|
|
351
398
|
code: SpanStatusCode.ERROR,
|
|
352
|
-
message:
|
|
399
|
+
message: "GraphQL Execution Error"
|
|
353
400
|
});
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
if (codes.length > 0) {
|
|
362
|
-
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
401
|
+
if (operationSpan) {
|
|
402
|
+
recordGraphqlErrors(
|
|
403
|
+
operationSpan,
|
|
404
|
+
result.errors,
|
|
405
|
+
"GraphQL Execution Error"
|
|
406
|
+
);
|
|
363
407
|
}
|
|
364
408
|
}
|
|
365
409
|
}
|
|
@@ -504,6 +548,70 @@ const getOperationFromDocument = (document, operationName) => {
|
|
|
504
548
|
operationNameMap.set(operationName ?? null, operation);
|
|
505
549
|
return operation;
|
|
506
550
|
};
|
|
551
|
+
function recordGraphqlErrors(span, errors, message) {
|
|
552
|
+
const codes = [];
|
|
553
|
+
const schemaCoordinates = [];
|
|
554
|
+
span.setStatus({
|
|
555
|
+
code: SpanStatusCode.ERROR,
|
|
556
|
+
message: message ?? "GraphQL Error"
|
|
557
|
+
});
|
|
558
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, errors.length);
|
|
559
|
+
for (const error of errors) {
|
|
560
|
+
const attributes = attributesFromGraphqlError(error);
|
|
561
|
+
if (attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_CODE]) {
|
|
562
|
+
codes.push(attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_CODE]);
|
|
563
|
+
}
|
|
564
|
+
if (attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE]) {
|
|
565
|
+
schemaCoordinates.push(
|
|
566
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE]
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
span.addEvent("graphql.error", attributes);
|
|
570
|
+
}
|
|
571
|
+
if (codes.length > 0) {
|
|
572
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
573
|
+
}
|
|
574
|
+
if (schemaCoordinates.length > 0) {
|
|
575
|
+
span.setAttribute(
|
|
576
|
+
SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES,
|
|
577
|
+
schemaCoordinates
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
function attributesFromGraphqlError(error) {
|
|
582
|
+
const attributes = {
|
|
583
|
+
[SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE]: error.message
|
|
584
|
+
};
|
|
585
|
+
if (error.path) {
|
|
586
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_PATH] = error.path.map(
|
|
587
|
+
(p) => p.toString()
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
if (error.locations) {
|
|
591
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS] = error.locations.map(
|
|
592
|
+
({ line, column }) => `${line}:${column}`
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
if (error.extensions) {
|
|
596
|
+
const code = error.extensions?.["code"];
|
|
597
|
+
if (code) {
|
|
598
|
+
const codeStr = `${code}`;
|
|
599
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_CODE] = codeStr;
|
|
600
|
+
}
|
|
601
|
+
const schemaCoordinate = getSchemaCoordinate(error);
|
|
602
|
+
if (schemaCoordinate) {
|
|
603
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE] = schemaCoordinate;
|
|
604
|
+
}
|
|
605
|
+
const originalError = error.extensions["originalError"];
|
|
606
|
+
if (originalError?.stack) {
|
|
607
|
+
attributes[ATTR_EXCEPTION_STACKTRACE] = originalError.stack;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return attributes;
|
|
611
|
+
}
|
|
612
|
+
function isGraphQLError(error) {
|
|
613
|
+
return !error.name || error.name === "GraphQLError";
|
|
614
|
+
}
|
|
507
615
|
|
|
508
616
|
function getEnvStr(key, opts = {}) {
|
|
509
617
|
const globalThat = opts.globalThis ?? globalThis;
|
|
@@ -724,7 +832,9 @@ function useOpenTelemetry(options) {
|
|
|
724
832
|
try {
|
|
725
833
|
wrapped();
|
|
726
834
|
} catch (err) {
|
|
727
|
-
|
|
835
|
+
if (err instanceof Error && !isGraphQLError(err)) {
|
|
836
|
+
registerException(forOperation.otel.current, err);
|
|
837
|
+
}
|
|
728
838
|
throw err;
|
|
729
839
|
} finally {
|
|
730
840
|
trace.getSpan(forOperation.otel.current)?.end();
|
|
@@ -857,6 +967,9 @@ function useOpenTelemetry(options) {
|
|
|
857
967
|
);
|
|
858
968
|
}
|
|
859
969
|
},
|
|
970
|
+
onPluginInit({ addPlugin }) {
|
|
971
|
+
addPlugin(useErrorCoordinate());
|
|
972
|
+
},
|
|
860
973
|
onYogaInit({ yoga }) {
|
|
861
974
|
pluginLogger ??= new Logger({
|
|
862
975
|
writers: [
|
|
@@ -949,6 +1062,7 @@ function useOpenTelemetry(options) {
|
|
|
949
1062
|
return ({ result }) => {
|
|
950
1063
|
setGraphQLParseAttributes({
|
|
951
1064
|
ctx: getContext(state),
|
|
1065
|
+
operationCtx: state.forOperation.otel.root,
|
|
952
1066
|
operationName: gqlCtx.params.operationName,
|
|
953
1067
|
query: gqlCtx.params.query?.trim(),
|
|
954
1068
|
result
|
|
@@ -969,6 +1083,7 @@ function useOpenTelemetry(options) {
|
|
|
969
1083
|
return ({ result }) => {
|
|
970
1084
|
setGraphQLValidateAttributes({
|
|
971
1085
|
ctx: getContext(state),
|
|
1086
|
+
operationCtx: state.forOperation.otel.root,
|
|
972
1087
|
result,
|
|
973
1088
|
document: params.documentAST,
|
|
974
1089
|
operationName: gqlCtx.params.operationName
|
|
@@ -992,6 +1107,7 @@ function useOpenTelemetry(options) {
|
|
|
992
1107
|
setGraphQLExecutionResultAttributes({
|
|
993
1108
|
ctx,
|
|
994
1109
|
result,
|
|
1110
|
+
operationCtx: state.forOperation.otel.root,
|
|
995
1111
|
subgraphNames: state.forOperation.subgraphNames
|
|
996
1112
|
});
|
|
997
1113
|
}
|
|
@@ -1099,4 +1215,4 @@ function resolveTracesConfig(options, useContextManager, log) {
|
|
|
1099
1215
|
return traces;
|
|
1100
1216
|
}
|
|
1101
1217
|
|
|
1102
|
-
export { SEMATTRS_GRAPHQL_DOCUMENT as S, SEMATTRS_GRAPHQL_OPERATION_TYPE as a, SEMATTRS_GRAPHQL_OPERATION_NAME as b, SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH as c, SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT as d, SEMATTRS_HIVE_GRAPHQL_ERROR_CODES as e,
|
|
1218
|
+
export { SEMATTRS_GRAPHQL_DOCUMENT as S, SEMATTRS_GRAPHQL_OPERATION_TYPE as a, SEMATTRS_GRAPHQL_OPERATION_NAME as b, SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH as c, SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT as d, SEMATTRS_HIVE_GRAPHQL_ERROR_CODES as e, SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES as f, SEMATTRS_HIVE_GRAPHQL_ERROR_CODE as g, SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE as h, SEMATTRS_HIVE_GRAPHQL_ERROR_PATH as i, SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE as j, SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS as k, SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME as l, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES as m, getEnvBool as n, otelCtxForRequestId as o, diagLogLevelFromEnv as p, getEnvStr as q, useOpenTelemetry as u };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var gatewayRuntime = require('@graphql-hive/gateway-runtime');
|
|
4
4
|
var utils$1 = require('@graphql-mesh/utils');
|
|
5
5
|
var utils = require('@graphql-tools/utils');
|
|
6
|
-
var
|
|
6
|
+
var require$$2 = require('@whatwg-node/promise-helpers');
|
|
7
7
|
var api$1 = require('./api.cjs');
|
|
8
8
|
var api = require('@opentelemetry/api');
|
|
9
9
|
var core = require('@graphql-hive/core');
|
|
@@ -11,6 +11,14 @@ var transportCommon = require('@graphql-mesh/transport-common');
|
|
|
11
11
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
12
12
|
var graphql = require('graphql');
|
|
13
13
|
|
|
14
|
+
function useErrorCoordinate() {
|
|
15
|
+
return {
|
|
16
|
+
onExecute({ args }) {
|
|
17
|
+
args.schemaCoordinateInErrors = true;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
class OtelContextStack {
|
|
15
23
|
#root;
|
|
16
24
|
#current;
|
|
@@ -124,6 +132,12 @@ const SEMATTRS_GRAPHQL_OPERATION_NAME = "graphql.operation.name";
|
|
|
124
132
|
const SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = "hive.graphql.operation.hash";
|
|
125
133
|
const SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = "hive.graphql.error.count";
|
|
126
134
|
const SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = "hive.graphql.error.codes";
|
|
135
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES = "hive.graphql.error.coordinates";
|
|
136
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_CODE = "hive.graphql.error.code";
|
|
137
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE = "hive.graphql.error.coordinate";
|
|
138
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_PATH = "hive.graphql.error.path";
|
|
139
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE = "hive.graphql.error.message";
|
|
140
|
+
const SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS = "hive.graphql.error.locations";
|
|
127
141
|
const SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = "hive.gateway.upstream.subgraph.name";
|
|
128
142
|
const SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = "hive.gateway.operation.subgraph.names";
|
|
129
143
|
|
|
@@ -243,7 +257,27 @@ function setGraphQLParseAttributes(input) {
|
|
|
243
257
|
span.setAttribute(SEMATTRS_GRAPHQL_DOCUMENT, input.query);
|
|
244
258
|
}
|
|
245
259
|
if (input.result instanceof Error) {
|
|
246
|
-
|
|
260
|
+
if (isGraphQLError(input.result)) {
|
|
261
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, 1);
|
|
262
|
+
span.setStatus({
|
|
263
|
+
code: api.SpanStatusCode.ERROR,
|
|
264
|
+
message: "GraphQL Parse Error"
|
|
265
|
+
});
|
|
266
|
+
const operationSpan = api.trace.getSpan(input.operationCtx);
|
|
267
|
+
if (operationSpan) {
|
|
268
|
+
recordGraphqlErrors(
|
|
269
|
+
operationSpan,
|
|
270
|
+
[input.result],
|
|
271
|
+
"GraphQL Parse Error"
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
} else {
|
|
275
|
+
span.recordException(input.result);
|
|
276
|
+
span.setStatus({
|
|
277
|
+
code: api.SpanStatusCode.ERROR,
|
|
278
|
+
message: input.result.message
|
|
279
|
+
});
|
|
280
|
+
}
|
|
247
281
|
} else {
|
|
248
282
|
const document = input.result;
|
|
249
283
|
const operation = getOperationFromDocument(document, input.operationName);
|
|
@@ -282,21 +316,34 @@ function setGraphQLValidateAttributes(input) {
|
|
|
282
316
|
if (result instanceof Error) {
|
|
283
317
|
errors.push(result);
|
|
284
318
|
}
|
|
285
|
-
if (errors.length
|
|
319
|
+
if (errors.length === 0) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const graphqlErrors = [];
|
|
323
|
+
const exceptions = [];
|
|
324
|
+
for (const error of errors) {
|
|
325
|
+
(isGraphQLError(error) ? graphqlErrors : exceptions).push(error);
|
|
326
|
+
}
|
|
327
|
+
if (graphqlErrors.length > 0) {
|
|
286
328
|
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.length);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
codes.push(`${error.extensions.code}`);
|
|
295
|
-
}
|
|
296
|
-
span.recordException(error);
|
|
329
|
+
const operationSpan = api.trace.getSpan(input.operationCtx);
|
|
330
|
+
if (operationSpan) {
|
|
331
|
+
recordGraphqlErrors(
|
|
332
|
+
operationSpan,
|
|
333
|
+
graphqlErrors,
|
|
334
|
+
"GraphQL Validation Error"
|
|
335
|
+
);
|
|
297
336
|
}
|
|
298
|
-
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
299
337
|
}
|
|
338
|
+
if (exceptions.length > 0) {
|
|
339
|
+
for (const exception of exceptions) {
|
|
340
|
+
span.recordException(exception);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
span.setStatus({
|
|
344
|
+
code: api.SpanStatusCode.ERROR,
|
|
345
|
+
message: "GraphQL Validation Error"
|
|
346
|
+
});
|
|
300
347
|
}
|
|
301
348
|
function createGraphQLExecuteSpan(input) {
|
|
302
349
|
const span = input.tracer.startSpan(
|
|
@@ -335,33 +382,30 @@ function setGraphQLExecutionAttributes(input) {
|
|
|
335
382
|
}
|
|
336
383
|
}
|
|
337
384
|
function setGraphQLExecutionResultAttributes(input) {
|
|
338
|
-
const { ctx, result } = input;
|
|
385
|
+
const { ctx, operationCtx, result } = input;
|
|
339
386
|
const span = api.trace.getSpan(ctx);
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
);
|
|
387
|
+
if (span) {
|
|
388
|
+
if (input.subgraphNames?.length) {
|
|
389
|
+
span.setAttribute(
|
|
390
|
+
SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES,
|
|
391
|
+
input.subgraphNames
|
|
392
|
+
);
|
|
393
|
+
}
|
|
348
394
|
}
|
|
395
|
+
const operationSpan = api.trace.getSpan(operationCtx);
|
|
349
396
|
if (!utils.isAsyncIterable(result) && // FIXME: Handle async iterable too
|
|
350
397
|
result.errors && result.errors.length > 0) {
|
|
351
|
-
span
|
|
352
|
-
span
|
|
398
|
+
span?.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.errors.length);
|
|
399
|
+
span?.setStatus({
|
|
353
400
|
code: api.SpanStatusCode.ERROR,
|
|
354
|
-
message:
|
|
401
|
+
message: "GraphQL Execution Error"
|
|
355
402
|
});
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
if (codes.length > 0) {
|
|
364
|
-
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
403
|
+
if (operationSpan) {
|
|
404
|
+
recordGraphqlErrors(
|
|
405
|
+
operationSpan,
|
|
406
|
+
result.errors,
|
|
407
|
+
"GraphQL Execution Error"
|
|
408
|
+
);
|
|
365
409
|
}
|
|
366
410
|
}
|
|
367
411
|
}
|
|
@@ -506,6 +550,70 @@ const getOperationFromDocument = (document, operationName) => {
|
|
|
506
550
|
operationNameMap.set(operationName ?? null, operation);
|
|
507
551
|
return operation;
|
|
508
552
|
};
|
|
553
|
+
function recordGraphqlErrors(span, errors, message) {
|
|
554
|
+
const codes = [];
|
|
555
|
+
const schemaCoordinates = [];
|
|
556
|
+
span.setStatus({
|
|
557
|
+
code: api.SpanStatusCode.ERROR,
|
|
558
|
+
message: message ?? "GraphQL Error"
|
|
559
|
+
});
|
|
560
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, errors.length);
|
|
561
|
+
for (const error of errors) {
|
|
562
|
+
const attributes = attributesFromGraphqlError(error);
|
|
563
|
+
if (attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_CODE]) {
|
|
564
|
+
codes.push(attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_CODE]);
|
|
565
|
+
}
|
|
566
|
+
if (attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE]) {
|
|
567
|
+
schemaCoordinates.push(
|
|
568
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE]
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
span.addEvent("graphql.error", attributes);
|
|
572
|
+
}
|
|
573
|
+
if (codes.length > 0) {
|
|
574
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
575
|
+
}
|
|
576
|
+
if (schemaCoordinates.length > 0) {
|
|
577
|
+
span.setAttribute(
|
|
578
|
+
SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES,
|
|
579
|
+
schemaCoordinates
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function attributesFromGraphqlError(error) {
|
|
584
|
+
const attributes = {
|
|
585
|
+
[SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE]: error.message
|
|
586
|
+
};
|
|
587
|
+
if (error.path) {
|
|
588
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_PATH] = error.path.map(
|
|
589
|
+
(p) => p.toString()
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
if (error.locations) {
|
|
593
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS] = error.locations.map(
|
|
594
|
+
({ line, column }) => `${line}:${column}`
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
if (error.extensions) {
|
|
598
|
+
const code = error.extensions?.["code"];
|
|
599
|
+
if (code) {
|
|
600
|
+
const codeStr = `${code}`;
|
|
601
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_CODE] = codeStr;
|
|
602
|
+
}
|
|
603
|
+
const schemaCoordinate = utils.getSchemaCoordinate(error);
|
|
604
|
+
if (schemaCoordinate) {
|
|
605
|
+
attributes[SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE] = schemaCoordinate;
|
|
606
|
+
}
|
|
607
|
+
const originalError = error.extensions["originalError"];
|
|
608
|
+
if (originalError?.stack) {
|
|
609
|
+
attributes[semanticConventions.ATTR_EXCEPTION_STACKTRACE] = originalError.stack;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return attributes;
|
|
613
|
+
}
|
|
614
|
+
function isGraphQLError(error) {
|
|
615
|
+
return !error.name || error.name === "GraphQLError";
|
|
616
|
+
}
|
|
509
617
|
|
|
510
618
|
function getEnvStr(key, opts = {}) {
|
|
511
619
|
const globalThat = opts.globalThis ?? globalThis;
|
|
@@ -640,7 +748,7 @@ function useOpenTelemetry(options) {
|
|
|
640
748
|
},
|
|
641
749
|
instrumentation: {
|
|
642
750
|
request({ state: { forRequest }, request }, wrapped) {
|
|
643
|
-
return
|
|
751
|
+
return require$$2.unfakePromise(
|
|
644
752
|
preparation$.then(() => {
|
|
645
753
|
if (!traces || !shouldTrace(traces.spans?.http, { request, ignoredRequests })) {
|
|
646
754
|
return wrapped();
|
|
@@ -671,7 +779,7 @@ function useOpenTelemetry(options) {
|
|
|
671
779
|
if (!traces || !isParentEnabled(parentState) || !shouldTrace(traces.spans?.graphql, { context: gqlCtx })) {
|
|
672
780
|
return wrapped();
|
|
673
781
|
}
|
|
674
|
-
return
|
|
782
|
+
return require$$2.unfakePromise(
|
|
675
783
|
preparation$.then(() => {
|
|
676
784
|
const ctx = getContext(parentState);
|
|
677
785
|
forOperation.otel = new OtelContextStack(
|
|
@@ -726,7 +834,9 @@ function useOpenTelemetry(options) {
|
|
|
726
834
|
try {
|
|
727
835
|
wrapped();
|
|
728
836
|
} catch (err) {
|
|
729
|
-
|
|
837
|
+
if (err instanceof Error && !isGraphQLError(err)) {
|
|
838
|
+
registerException(forOperation.otel.current, err);
|
|
839
|
+
}
|
|
730
840
|
throw err;
|
|
731
841
|
} finally {
|
|
732
842
|
api.trace.getSpan(forOperation.otel.current)?.end();
|
|
@@ -765,7 +875,7 @@ function useOpenTelemetry(options) {
|
|
|
765
875
|
if (useContextManager) {
|
|
766
876
|
wrapped = api.context.bind(forOperation.otel.current, wrapped);
|
|
767
877
|
}
|
|
768
|
-
return
|
|
878
|
+
return require$$2.unfakePromise(
|
|
769
879
|
utils.fakePromise().then(wrapped).catch((err) => {
|
|
770
880
|
registerException(forOperation.otel.current, err);
|
|
771
881
|
throw err;
|
|
@@ -802,7 +912,7 @@ function useOpenTelemetry(options) {
|
|
|
802
912
|
if (useContextManager) {
|
|
803
913
|
wrapped = api.context.bind(forSubgraphExecution.otel.current, wrapped);
|
|
804
914
|
}
|
|
805
|
-
return
|
|
915
|
+
return require$$2.unfakePromise(
|
|
806
916
|
utils.fakePromise().then(wrapped).catch((err) => {
|
|
807
917
|
registerException(forSubgraphExecution.otel.current, err);
|
|
808
918
|
throw err;
|
|
@@ -816,7 +926,7 @@ function useOpenTelemetry(options) {
|
|
|
816
926
|
if (gatewayRuntime.isRetryExecutionRequest(executionRequest)) {
|
|
817
927
|
state = getState(gatewayRuntime.getRetryInfo(executionRequest));
|
|
818
928
|
}
|
|
819
|
-
return
|
|
929
|
+
return require$$2.unfakePromise(
|
|
820
930
|
preparation$.then(() => {
|
|
821
931
|
if (!traces || !isParentEnabled(state) || !shouldTrace(traces.spans?.upstreamFetch, { executionRequest })) {
|
|
822
932
|
return wrapped();
|
|
@@ -841,7 +951,7 @@ function useOpenTelemetry(options) {
|
|
|
841
951
|
);
|
|
842
952
|
},
|
|
843
953
|
schema(_, wrapped) {
|
|
844
|
-
return
|
|
954
|
+
return require$$2.unfakePromise(
|
|
845
955
|
preparation$.then(() => {
|
|
846
956
|
if (!traces || !shouldTrace(traces.spans?.schema, null)) {
|
|
847
957
|
return wrapped();
|
|
@@ -859,6 +969,9 @@ function useOpenTelemetry(options) {
|
|
|
859
969
|
);
|
|
860
970
|
}
|
|
861
971
|
},
|
|
972
|
+
onPluginInit({ addPlugin }) {
|
|
973
|
+
addPlugin(useErrorCoordinate());
|
|
974
|
+
},
|
|
862
975
|
onYogaInit({ yoga }) {
|
|
863
976
|
pluginLogger ??= new gatewayRuntime.Logger({
|
|
864
977
|
writers: [
|
|
@@ -951,6 +1064,7 @@ function useOpenTelemetry(options) {
|
|
|
951
1064
|
return ({ result }) => {
|
|
952
1065
|
setGraphQLParseAttributes({
|
|
953
1066
|
ctx: getContext(state),
|
|
1067
|
+
operationCtx: state.forOperation.otel.root,
|
|
954
1068
|
operationName: gqlCtx.params.operationName,
|
|
955
1069
|
query: gqlCtx.params.query?.trim(),
|
|
956
1070
|
result
|
|
@@ -971,6 +1085,7 @@ function useOpenTelemetry(options) {
|
|
|
971
1085
|
return ({ result }) => {
|
|
972
1086
|
setGraphQLValidateAttributes({
|
|
973
1087
|
ctx: getContext(state),
|
|
1088
|
+
operationCtx: state.forOperation.otel.root,
|
|
974
1089
|
result,
|
|
975
1090
|
document: params.documentAST,
|
|
976
1091
|
operationName: gqlCtx.params.operationName
|
|
@@ -994,6 +1109,7 @@ function useOpenTelemetry(options) {
|
|
|
994
1109
|
setGraphQLExecutionResultAttributes({
|
|
995
1110
|
ctx,
|
|
996
1111
|
result,
|
|
1112
|
+
operationCtx: state.forOperation.otel.root,
|
|
997
1113
|
subgraphNames: state.forOperation.subgraphNames
|
|
998
1114
|
});
|
|
999
1115
|
}
|
|
@@ -1106,8 +1222,14 @@ exports.SEMATTRS_GRAPHQL_OPERATION_NAME = SEMATTRS_GRAPHQL_OPERATION_NAME;
|
|
|
1106
1222
|
exports.SEMATTRS_GRAPHQL_OPERATION_TYPE = SEMATTRS_GRAPHQL_OPERATION_TYPE;
|
|
1107
1223
|
exports.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES;
|
|
1108
1224
|
exports.SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME;
|
|
1225
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODE = SEMATTRS_HIVE_GRAPHQL_ERROR_CODE;
|
|
1109
1226
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = SEMATTRS_HIVE_GRAPHQL_ERROR_CODES;
|
|
1110
1227
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT;
|
|
1228
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS = SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS;
|
|
1229
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE = SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE;
|
|
1230
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_PATH = SEMATTRS_HIVE_GRAPHQL_ERROR_PATH;
|
|
1231
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE = SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE;
|
|
1232
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES = SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES;
|
|
1111
1233
|
exports.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH;
|
|
1112
1234
|
exports.diagLogLevelFromEnv = diagLogLevelFromEnv;
|
|
1113
1235
|
exports.getEnvBool = getEnvBool;
|
package/dist/setup.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var core = require('@opentelemetry/core');
|
|
|
6
6
|
var resources = require('@opentelemetry/resources');
|
|
7
7
|
var sdkTraceBase = require('@opentelemetry/sdk-trace-base');
|
|
8
8
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
9
|
-
var plugin = require('./plugin-
|
|
9
|
+
var plugin = require('./plugin-uVxk_ok_.cjs');
|
|
10
10
|
var exporterTraceOtlpHttp = require('@opentelemetry/exporter-trace-otlp-http');
|
|
11
11
|
var apiLogs = require('@opentelemetry/api-logs');
|
|
12
12
|
var sdkLogs = require('@opentelemetry/sdk-logs');
|
|
@@ -104,10 +104,6 @@ class HiveTracingSpanProcessor {
|
|
|
104
104
|
if (operationSpan === span) {
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
if (SPANS_WITH_ERRORS.includes(span.name)) {
|
|
108
|
-
copyAttribute(span, operationSpan, plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES);
|
|
109
|
-
copyAttribute(span, operationSpan, plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT);
|
|
110
|
-
}
|
|
111
107
|
if (span.name === "graphql.execute") {
|
|
112
108
|
copyAttribute(
|
|
113
109
|
span,
|
|
@@ -145,11 +141,6 @@ function isOperationSpan(span) {
|
|
|
145
141
|
const followingChar = span.name.at(17);
|
|
146
142
|
return !followingChar || followingChar === " ";
|
|
147
143
|
}
|
|
148
|
-
const SPANS_WITH_ERRORS = [
|
|
149
|
-
"graphql.parse",
|
|
150
|
-
"graphql.validate",
|
|
151
|
-
"graphql.execute"
|
|
152
|
-
];
|
|
153
144
|
|
|
154
145
|
class OpenTelemetryLogWriter {
|
|
155
146
|
logger;
|
|
@@ -224,10 +215,10 @@ function getContextForRequest(attributes) {
|
|
|
224
215
|
return plugin.otelCtxForRequestId.get(attributes.requestId) ?? api.ROOT_CONTEXT;
|
|
225
216
|
}
|
|
226
217
|
|
|
227
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.
|
|
218
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.3.0-alpha-10edca19a47a0212f09bb75e24751faa4186544a';
|
|
228
219
|
let initialized = false;
|
|
229
220
|
function openTelemetrySetup(options) {
|
|
230
|
-
const log = options.log || new logger.Logger();
|
|
221
|
+
const log = !options.log || typeof options.log === "string" ? new logger.Logger({ level: options.log }) : options.log;
|
|
231
222
|
if (initialized) {
|
|
232
223
|
log.error(
|
|
233
224
|
`${initialized.name} integration has already been initialized by ${initialized.source}`
|
|
@@ -320,7 +311,7 @@ function openTelemetrySetup(options) {
|
|
|
320
311
|
log.info(logAttributes, logMessage);
|
|
321
312
|
}
|
|
322
313
|
function hiveTracingSetup(options) {
|
|
323
|
-
const log = options.log || new logger.Logger();
|
|
314
|
+
const log = !options.log || typeof options.log === "string" ? new logger.Logger({ level: options.log }) : options.log;
|
|
324
315
|
options.target ??= plugin.getEnvStr("HIVE_TARGET");
|
|
325
316
|
if (!options.target) {
|
|
326
317
|
throw new Error(
|
|
@@ -461,8 +452,14 @@ exports.SEMATTRS_GRAPHQL_OPERATION_NAME = plugin.SEMATTRS_GRAPHQL_OPERATION_NAME
|
|
|
461
452
|
exports.SEMATTRS_GRAPHQL_OPERATION_TYPE = plugin.SEMATTRS_GRAPHQL_OPERATION_TYPE;
|
|
462
453
|
exports.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = plugin.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES;
|
|
463
454
|
exports.SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = plugin.SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME;
|
|
455
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODE = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_CODE;
|
|
464
456
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES;
|
|
465
457
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT;
|
|
458
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS;
|
|
459
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE;
|
|
460
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_PATH = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_PATH;
|
|
461
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE;
|
|
462
|
+
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES;
|
|
466
463
|
exports.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = plugin.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH;
|
|
467
464
|
exports.HIVE_LOG_LEVEL_NUMBERS = HIVE_LOG_LEVEL_NUMBERS;
|
|
468
465
|
exports.HiveTracingSpanProcessor = HiveTracingSpanProcessor;
|
package/dist/setup.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { LogWriter, LogLevel, Attributes, Logger as Logger$1 } from '@graphql-hi
|
|
|
2
2
|
import { Context, TracerProvider, ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
3
3
|
import { Resource } from '@opentelemetry/resources';
|
|
4
4
|
import { BufferConfig, SpanProcessor, Span, SpanLimits, SpanExporter, Sampler, GeneralLimits } from '@opentelemetry/sdk-trace-base';
|
|
5
|
-
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE,
|
|
5
|
+
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE, m as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, l as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, g as SEMATTRS_HIVE_GRAPHQL_ERROR_CODE, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, k as SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS, j as SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE, i as SEMATTRS_HIVE_GRAPHQL_ERROR_PATH, h as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE, f as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-BjUFTXMN.js';
|
|
6
6
|
import { Logger, SeverityNumber } from '@opentelemetry/api-logs';
|
|
7
7
|
import { LoggerProvider, LogRecordLimits, LogRecordProcessor, LogRecordExporter } from '@opentelemetry/sdk-logs';
|
|
8
8
|
export { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_SERVER_NAME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_NAME } from '@opentelemetry/semantic-conventions';
|
|
@@ -152,7 +152,7 @@ type BaseOptions = {
|
|
|
152
152
|
* The Logger to be used by this utility.
|
|
153
153
|
* A child of this logger will be used for OTEL diag API, unless `configureDiagLogger` is false
|
|
154
154
|
*/
|
|
155
|
-
log?: Logger$1;
|
|
155
|
+
log?: Logger$1 | false | LogLevel;
|
|
156
156
|
/**
|
|
157
157
|
* Configure Opentelemetry `diag` API to use Gateway's logger.
|
|
158
158
|
*
|
package/dist/setup.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LogWriter, LogLevel, Attributes, Logger as Logger$1 } from '@graphql-hi
|
|
|
2
2
|
import { Context, TracerProvider, ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
3
3
|
import { Resource } from '@opentelemetry/resources';
|
|
4
4
|
import { BufferConfig, SpanProcessor, Span, SpanLimits, SpanExporter, Sampler, GeneralLimits } from '@opentelemetry/sdk-trace-base';
|
|
5
|
-
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE,
|
|
5
|
+
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE, m as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, l as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, g as SEMATTRS_HIVE_GRAPHQL_ERROR_CODE, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, k as SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS, j as SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE, i as SEMATTRS_HIVE_GRAPHQL_ERROR_PATH, h as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE, f as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-BjUFTXMN.js';
|
|
6
6
|
import { Logger, SeverityNumber } from '@opentelemetry/api-logs';
|
|
7
7
|
import { LoggerProvider, LogRecordLimits, LogRecordProcessor, LogRecordExporter } from '@opentelemetry/sdk-logs';
|
|
8
8
|
export { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_SERVER_NAME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_NAME } from '@opentelemetry/semantic-conventions';
|
|
@@ -152,7 +152,7 @@ type BaseOptions = {
|
|
|
152
152
|
* The Logger to be used by this utility.
|
|
153
153
|
* A child of this logger will be used for OTEL diag API, unless `configureDiagLogger` is false
|
|
154
154
|
*/
|
|
155
|
-
log?: Logger$1;
|
|
155
|
+
log?: Logger$1 | false | LogLevel;
|
|
156
156
|
/**
|
|
157
157
|
* Configure Opentelemetry `diag` API to use Gateway's logger.
|
|
158
158
|
*
|
package/dist/setup.js
CHANGED
|
@@ -5,8 +5,8 @@ import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
|
5
5
|
import { BatchSpanProcessor, SimpleSpanProcessor, ConsoleSpanExporter, BasicTracerProvider, ParentBasedSampler, AlwaysOnSampler, TraceIdRatioBasedSampler } from '@opentelemetry/sdk-trace-base';
|
|
6
6
|
import { SEMATTRS_HTTP_METHOD, ATTR_SERVICE_VERSION, ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
7
7
|
export { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, SEMATTRS_HTTP_CLIENT_IP, SEMATTRS_HTTP_HOST, SEMATTRS_HTTP_METHOD, SEMATTRS_HTTP_ROUTE, SEMATTRS_HTTP_SCHEME, SEMATTRS_HTTP_SERVER_NAME, SEMATTRS_HTTP_STATUS_CODE, SEMATTRS_HTTP_URL, SEMATTRS_HTTP_USER_AGENT, SEMATTRS_NET_HOST_NAME } from '@opentelemetry/semantic-conventions';
|
|
8
|
-
import {
|
|
9
|
-
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE,
|
|
8
|
+
import { m as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, o as otelCtxForRequestId, n as getEnvBool, p as diagLogLevelFromEnv, q as getEnvStr } from './plugin-CW1kfhP8.js';
|
|
9
|
+
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE, l as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, g as SEMATTRS_HIVE_GRAPHQL_ERROR_CODE, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, k as SEMATTRS_HIVE_GRAPHQL_ERROR_LOCATIONS, j as SEMATTRS_HIVE_GRAPHQL_ERROR_MESSAGE, i as SEMATTRS_HIVE_GRAPHQL_ERROR_PATH, h as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATE, f as SEMATTRS_HIVE_GRAPHQL_ERROR_SCHEMA_COORDINATES, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './plugin-CW1kfhP8.js';
|
|
10
10
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
11
11
|
import { SeverityNumber, logs } from '@opentelemetry/api-logs';
|
|
12
12
|
import { BatchLogRecordProcessor, SimpleLogRecordProcessor, ConsoleLogRecordExporter, LoggerProvider } from '@opentelemetry/sdk-logs';
|
|
@@ -104,10 +104,6 @@ class HiveTracingSpanProcessor {
|
|
|
104
104
|
if (operationSpan === span) {
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
if (SPANS_WITH_ERRORS.includes(span.name)) {
|
|
108
|
-
copyAttribute(span, operationSpan, SEMATTRS_HIVE_GRAPHQL_ERROR_CODES);
|
|
109
|
-
copyAttribute(span, operationSpan, SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT);
|
|
110
|
-
}
|
|
111
107
|
if (span.name === "graphql.execute") {
|
|
112
108
|
copyAttribute(
|
|
113
109
|
span,
|
|
@@ -145,11 +141,6 @@ function isOperationSpan(span) {
|
|
|
145
141
|
const followingChar = span.name.at(17);
|
|
146
142
|
return !followingChar || followingChar === " ";
|
|
147
143
|
}
|
|
148
|
-
const SPANS_WITH_ERRORS = [
|
|
149
|
-
"graphql.parse",
|
|
150
|
-
"graphql.validate",
|
|
151
|
-
"graphql.execute"
|
|
152
|
-
];
|
|
153
144
|
|
|
154
145
|
class OpenTelemetryLogWriter {
|
|
155
146
|
logger;
|
|
@@ -224,10 +215,10 @@ function getContextForRequest(attributes) {
|
|
|
224
215
|
return otelCtxForRequestId.get(attributes.requestId) ?? ROOT_CONTEXT;
|
|
225
216
|
}
|
|
226
217
|
|
|
227
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.
|
|
218
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.3.0-alpha-10edca19a47a0212f09bb75e24751faa4186544a';
|
|
228
219
|
let initialized = false;
|
|
229
220
|
function openTelemetrySetup(options) {
|
|
230
|
-
const log = options.log || new Logger();
|
|
221
|
+
const log = !options.log || typeof options.log === "string" ? new Logger({ level: options.log }) : options.log;
|
|
231
222
|
if (initialized) {
|
|
232
223
|
log.error(
|
|
233
224
|
`${initialized.name} integration has already been initialized by ${initialized.source}`
|
|
@@ -320,7 +311,7 @@ function openTelemetrySetup(options) {
|
|
|
320
311
|
log.info(logAttributes, logMessage);
|
|
321
312
|
}
|
|
322
313
|
function hiveTracingSetup(options) {
|
|
323
|
-
const log = options.log || new Logger();
|
|
314
|
+
const log = !options.log || typeof options.log === "string" ? new Logger({ level: options.log }) : options.log;
|
|
324
315
|
options.target ??= getEnvStr("HIVE_TARGET");
|
|
325
316
|
if (!options.target) {
|
|
326
317
|
throw new Error(
|
|
@@ -408,4 +399,4 @@ function disable() {
|
|
|
408
399
|
initialized = false;
|
|
409
400
|
}
|
|
410
401
|
|
|
411
|
-
export { HIVE_LOG_LEVEL_NUMBERS, HiveTracingSpanProcessor, OpenTelemetryLogWriter, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES,
|
|
402
|
+
export { HIVE_LOG_LEVEL_NUMBERS, HiveTracingSpanProcessor, OpenTelemetryLogWriter, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, disable, getContextForRequest, hiveTracingSetup, openTelemetrySetup };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-hive/plugin-opentelemetry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha-10edca19a47a0212f09bb75e24751faa4186544a",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,12 +63,13 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@graphql-hive/core": "^0.15.1",
|
|
66
|
-
"@graphql-hive/gateway-runtime": "2.
|
|
66
|
+
"@graphql-hive/gateway-runtime": "2.4.0-alpha-10edca19a47a0212f09bb75e24751faa4186544a",
|
|
67
67
|
"@graphql-hive/logger": "^1.0.9",
|
|
68
68
|
"@graphql-mesh/cross-helpers": "^0.4.10",
|
|
69
69
|
"@graphql-mesh/transport-common": "^1.0.12",
|
|
70
70
|
"@graphql-mesh/types": "^0.104.16",
|
|
71
71
|
"@graphql-mesh/utils": "^0.104.16",
|
|
72
|
+
"@graphql-tools/executor": "^1.4.9",
|
|
72
73
|
"@graphql-tools/utils": "^10.10.3",
|
|
73
74
|
"@opentelemetry/api": "^1.9.0",
|
|
74
75
|
"@opentelemetry/api-logs": "^0.208.0",
|
|
@@ -89,7 +90,7 @@
|
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@whatwg-node/server": "^0.10.17",
|
|
91
92
|
"graphql": "^16.12.0",
|
|
92
|
-
"graphql-yoga": "^5.
|
|
93
|
+
"graphql-yoga": "^5.17.0",
|
|
93
94
|
"pkgroll": "2.21.3",
|
|
94
95
|
"rimraf": "^6.1.0",
|
|
95
96
|
"rollup": "^4.53.2",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare const SEMATTRS_GRAPHQL_DOCUMENT = "graphql.document";
|
|
2
|
-
declare const SEMATTRS_GRAPHQL_OPERATION_TYPE = "graphql.operation.type";
|
|
3
|
-
declare const SEMATTRS_GRAPHQL_OPERATION_NAME = "graphql.operation.name";
|
|
4
|
-
declare const SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = "hive.graphql.operation.hash";
|
|
5
|
-
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = "hive.graphql.error.count";
|
|
6
|
-
declare const SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = "hive.graphql.error.codes";
|
|
7
|
-
declare const SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = "hive.gateway.upstream.subgraph.name";
|
|
8
|
-
declare const SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = "hive.gateway.operation.subgraph.names";
|
|
9
|
-
|
|
10
|
-
export { SEMATTRS_GRAPHQL_DOCUMENT as S, SEMATTRS_GRAPHQL_OPERATION_TYPE as a, SEMATTRS_GRAPHQL_OPERATION_NAME as b, SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH as c, SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT as d, SEMATTRS_HIVE_GRAPHQL_ERROR_CODES as e, SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME as f, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES as g };
|