@graphql-hive/plugin-opentelemetry 1.3.0-alpha-59307ccb5034b0b2116c4faa27174921b267c388 → 1.3.0-alpha-b079a2654a7efe1afbc720b58220e3474da04a3a
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 +9 -23
- package/dist/attributes-mikIPKnv.d.ts +10 -0
- package/dist/index.cjs +1 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{plugin-CW1kfhP8.js → plugin-CepZPqbb.js} +40 -156
- package/dist/{plugin-uVxk_ok_.cjs → plugin-DOyRaHdT.cjs} +44 -166
- package/dist/setup.cjs +13 -10
- package/dist/setup.d.cts +2 -2
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +15 -6
- package/package.json +3 -4
- package/dist/attributes-BjUFTXMN.d.ts +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,37 +1,23 @@
|
|
|
1
1
|
# @graphql-hive/plugin-opentelemetry
|
|
2
2
|
|
|
3
|
-
## 1.3.0-alpha-
|
|
3
|
+
## 1.3.0-alpha-b079a2654a7efe1afbc720b58220e3474da04a3a
|
|
4
4
|
### Minor Changes
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
- [#
|
|
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.
|
|
8
|
+
- [#1786](https://github.com/graphql-hive/gateway/pull/1786) [`b079a26`](https://github.com/graphql-hive/gateway/commit/b079a2654a7efe1afbc720b58220e3474da04a3a) Thanks [@ardatan](https://github.com/ardatan)! - Respect both \`graphql-client-name\` and \`x-graphql-client-name\` for client name header, and both \`graphql-client-version\` and \`x-graphql-client-version\` for client version header by default if not configured otherwise.
|
|
9
|
+
|
|
25
10
|
|
|
26
11
|
### Patch Changes
|
|
27
12
|
|
|
13
|
+
- Updated dependencies [[`15b9e50`](https://github.com/graphql-hive/gateway/commit/15b9e5037fa74f8c1a8e662e196268a88642c27d), [`b079a26`](https://github.com/graphql-hive/gateway/commit/b079a2654a7efe1afbc720b58220e3474da04a3a)]:
|
|
14
|
+
- @graphql-hive/gateway-runtime@2.5.0-alpha-b079a2654a7efe1afbc720b58220e3474da04a3a
|
|
28
15
|
|
|
16
|
+
## 1.2.5
|
|
17
|
+
### Patch Changes
|
|
29
18
|
|
|
30
|
-
- [
|
|
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
|
-
- Updated dependencies [[`4602329`](https://github.com/graphql-hive/gateway/commit/4602329266206712c332a73faac50404df1edbdd), [`01fd715`](https://github.com/graphql-hive/gateway/commit/01fd7156d6a40f5d855cfa6ba0b78d9bf54564c0)]:
|
|
34
|
-
- @graphql-hive/gateway-runtime@2.5.0-alpha-59307ccb5034b0b2116c4faa27174921b267c388
|
|
19
|
+
- Updated dependencies [[`7e33249`](https://github.com/graphql-hive/gateway/commit/7e332496179d213cf10f055b282ce30ab68279d1), [`db20a29`](https://github.com/graphql-hive/gateway/commit/db20a298c57c717495cbdbcaa6a8aa5b369da909), [`db20a29`](https://github.com/graphql-hive/gateway/commit/db20a298c57c717495cbdbcaa6a8aa5b369da909)]:
|
|
20
|
+
- @graphql-hive/gateway-runtime@2.4.1
|
|
35
21
|
|
|
36
22
|
## 1.2.4
|
|
37
23
|
### Patch Changes
|
|
@@ -0,0 +1,10 @@
|
|
|
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 };
|
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-DOyRaHdT.cjs');
|
|
4
4
|
var api = require('@opentelemetry/api');
|
|
5
5
|
var semanticConventions = require('@opentelemetry/semantic-conventions');
|
|
6
6
|
require('@graphql-hive/gateway-runtime');
|
|
@@ -19,14 +19,8 @@ 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;
|
|
23
22
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES;
|
|
24
23
|
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;
|
|
30
24
|
exports.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = plugin.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH;
|
|
31
25
|
exports.useOpenTelemetry = plugin.useOpenTelemetry;
|
|
32
26
|
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, g as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, f as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-mikIPKnv.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, g as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, f as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-mikIPKnv.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, g as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, f as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH, u as useOpenTelemetry } from './plugin-CepZPqbb.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,22 +1,14 @@
|
|
|
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,
|
|
3
|
+
import { isAsyncIterable, getOperationASTFromDocument, 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
|
|
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';
|
|
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
|
-
|
|
20
12
|
class OtelContextStack {
|
|
21
13
|
#root;
|
|
22
14
|
#current;
|
|
@@ -130,12 +122,6 @@ const SEMATTRS_GRAPHQL_OPERATION_NAME = "graphql.operation.name";
|
|
|
130
122
|
const SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = "hive.graphql.operation.hash";
|
|
131
123
|
const SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = "hive.graphql.error.count";
|
|
132
124
|
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";
|
|
139
125
|
const SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = "hive.gateway.upstream.subgraph.name";
|
|
140
126
|
const SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = "hive.gateway.operation.subgraph.names";
|
|
141
127
|
|
|
@@ -153,8 +139,8 @@ function createHttpSpan(input) {
|
|
|
153
139
|
[SEMATTRS_HTTP_HOST]: url.host || request.headers.get("host") || void 0,
|
|
154
140
|
[SEMATTRS_HTTP_CLIENT_IP]: request.headers.get("x-forwarded-for")?.split(",")[0],
|
|
155
141
|
[SEMATTRS_HTTP_USER_AGENT]: request.headers.get("user-agent") || void 0,
|
|
156
|
-
"hive.client.name": request.headers.get("x-graphql-client-name") || void 0,
|
|
157
|
-
"hive.client.version": request.headers.get("x-graphql-client-version") || void 0
|
|
142
|
+
"hive.client.name": request.headers.get("graphql-client-name") || request.headers.get("x-graphql-client-name") || void 0,
|
|
143
|
+
"hive.client.version": request.headers.get("graphql-client-version") || request.headers.get("x-graphql-client-version") || void 0
|
|
158
144
|
},
|
|
159
145
|
kind: SpanKind.SERVER
|
|
160
146
|
},
|
|
@@ -255,27 +241,7 @@ function setGraphQLParseAttributes(input) {
|
|
|
255
241
|
span.setAttribute(SEMATTRS_GRAPHQL_DOCUMENT, input.query);
|
|
256
242
|
}
|
|
257
243
|
if (input.result instanceof Error) {
|
|
258
|
-
|
|
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
|
-
}
|
|
244
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, 1);
|
|
279
245
|
} else {
|
|
280
246
|
const document = input.result;
|
|
281
247
|
const operation = getOperationFromDocument(document, input.operationName);
|
|
@@ -314,34 +280,21 @@ function setGraphQLValidateAttributes(input) {
|
|
|
314
280
|
if (result instanceof Error) {
|
|
315
281
|
errors.push(result);
|
|
316
282
|
}
|
|
317
|
-
if (errors.length
|
|
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) {
|
|
283
|
+
if (errors.length > 0) {
|
|
326
284
|
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.length);
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
)
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
for (const exception of exceptions) {
|
|
338
|
-
span.recordException(exception);
|
|
285
|
+
span.setStatus({
|
|
286
|
+
code: SpanStatusCode.ERROR,
|
|
287
|
+
message: result.map((e) => e.message).join(", ")
|
|
288
|
+
});
|
|
289
|
+
const codes = [];
|
|
290
|
+
for (const error of result) {
|
|
291
|
+
if (error.extensions?.code) {
|
|
292
|
+
codes.push(`${error.extensions.code}`);
|
|
293
|
+
}
|
|
294
|
+
span.recordException(error);
|
|
339
295
|
}
|
|
296
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
340
297
|
}
|
|
341
|
-
span.setStatus({
|
|
342
|
-
code: SpanStatusCode.ERROR,
|
|
343
|
-
message: "GraphQL Validation Error"
|
|
344
|
-
});
|
|
345
298
|
}
|
|
346
299
|
function createGraphQLExecuteSpan(input) {
|
|
347
300
|
const span = input.tracer.startSpan(
|
|
@@ -380,30 +333,33 @@ function setGraphQLExecutionAttributes(input) {
|
|
|
380
333
|
}
|
|
381
334
|
}
|
|
382
335
|
function setGraphQLExecutionResultAttributes(input) {
|
|
383
|
-
const { ctx,
|
|
336
|
+
const { ctx, result } = input;
|
|
384
337
|
const span = trace.getSpan(ctx);
|
|
385
|
-
if (span) {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
338
|
+
if (!span) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (input.subgraphNames?.length) {
|
|
342
|
+
span.setAttribute(
|
|
343
|
+
SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES,
|
|
344
|
+
input.subgraphNames
|
|
345
|
+
);
|
|
392
346
|
}
|
|
393
|
-
const operationSpan = trace.getSpan(operationCtx);
|
|
394
347
|
if (!isAsyncIterable(result) && // FIXME: Handle async iterable too
|
|
395
348
|
result.errors && result.errors.length > 0) {
|
|
396
|
-
span
|
|
397
|
-
span
|
|
349
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.errors.length);
|
|
350
|
+
span.setStatus({
|
|
398
351
|
code: SpanStatusCode.ERROR,
|
|
399
|
-
message:
|
|
352
|
+
message: result.errors.map((e) => e.message).join(", ")
|
|
400
353
|
});
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
"
|
|
406
|
-
|
|
354
|
+
const codes = [];
|
|
355
|
+
for (const error of result.errors) {
|
|
356
|
+
span.recordException(error);
|
|
357
|
+
if (error.extensions?.["code"]) {
|
|
358
|
+
codes.push(`${error.extensions["code"]}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (codes.length > 0) {
|
|
362
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
407
363
|
}
|
|
408
364
|
}
|
|
409
365
|
}
|
|
@@ -548,70 +504,6 @@ const getOperationFromDocument = (document, operationName) => {
|
|
|
548
504
|
operationNameMap.set(operationName ?? null, operation);
|
|
549
505
|
return operation;
|
|
550
506
|
};
|
|
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
|
-
}
|
|
615
507
|
|
|
616
508
|
function getEnvStr(key, opts = {}) {
|
|
617
509
|
const globalThat = opts.globalThis ?? globalThis;
|
|
@@ -832,9 +724,7 @@ function useOpenTelemetry(options) {
|
|
|
832
724
|
try {
|
|
833
725
|
wrapped();
|
|
834
726
|
} catch (err) {
|
|
835
|
-
|
|
836
|
-
registerException(forOperation.otel.current, err);
|
|
837
|
-
}
|
|
727
|
+
registerException(forOperation.otel.current, err);
|
|
838
728
|
throw err;
|
|
839
729
|
} finally {
|
|
840
730
|
trace.getSpan(forOperation.otel.current)?.end();
|
|
@@ -967,9 +857,6 @@ function useOpenTelemetry(options) {
|
|
|
967
857
|
);
|
|
968
858
|
}
|
|
969
859
|
},
|
|
970
|
-
onPluginInit({ addPlugin }) {
|
|
971
|
-
addPlugin(useErrorCoordinate());
|
|
972
|
-
},
|
|
973
860
|
onYogaInit({ yoga }) {
|
|
974
861
|
pluginLogger ??= new Logger({
|
|
975
862
|
writers: [
|
|
@@ -1062,7 +949,6 @@ function useOpenTelemetry(options) {
|
|
|
1062
949
|
return ({ result }) => {
|
|
1063
950
|
setGraphQLParseAttributes({
|
|
1064
951
|
ctx: getContext(state),
|
|
1065
|
-
operationCtx: state.forOperation.otel.root,
|
|
1066
952
|
operationName: gqlCtx.params.operationName,
|
|
1067
953
|
query: gqlCtx.params.query?.trim(),
|
|
1068
954
|
result
|
|
@@ -1083,7 +969,6 @@ function useOpenTelemetry(options) {
|
|
|
1083
969
|
return ({ result }) => {
|
|
1084
970
|
setGraphQLValidateAttributes({
|
|
1085
971
|
ctx: getContext(state),
|
|
1086
|
-
operationCtx: state.forOperation.otel.root,
|
|
1087
972
|
result,
|
|
1088
973
|
document: params.documentAST,
|
|
1089
974
|
operationName: gqlCtx.params.operationName
|
|
@@ -1107,7 +992,6 @@ function useOpenTelemetry(options) {
|
|
|
1107
992
|
setGraphQLExecutionResultAttributes({
|
|
1108
993
|
ctx,
|
|
1109
994
|
result,
|
|
1110
|
-
operationCtx: state.forOperation.otel.root,
|
|
1111
995
|
subgraphNames: state.forOperation.subgraphNames
|
|
1112
996
|
});
|
|
1113
997
|
}
|
|
@@ -1215,4 +1099,4 @@ function resolveTracesConfig(options, useContextManager, log) {
|
|
|
1215
1099
|
return traces;
|
|
1216
1100
|
}
|
|
1217
1101
|
|
|
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,
|
|
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, SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME as f, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES as g, getEnvBool as h, diagLogLevelFromEnv as i, getEnvStr as j, otelCtxForRequestId as o, 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 promiseHelpers = 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,14 +11,6 @@ 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
|
-
|
|
22
14
|
class OtelContextStack {
|
|
23
15
|
#root;
|
|
24
16
|
#current;
|
|
@@ -132,12 +124,6 @@ const SEMATTRS_GRAPHQL_OPERATION_NAME = "graphql.operation.name";
|
|
|
132
124
|
const SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = "hive.graphql.operation.hash";
|
|
133
125
|
const SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT = "hive.graphql.error.count";
|
|
134
126
|
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";
|
|
141
127
|
const SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME = "hive.gateway.upstream.subgraph.name";
|
|
142
128
|
const SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = "hive.gateway.operation.subgraph.names";
|
|
143
129
|
|
|
@@ -155,8 +141,8 @@ function createHttpSpan(input) {
|
|
|
155
141
|
[semanticConventions.SEMATTRS_HTTP_HOST]: url.host || request.headers.get("host") || void 0,
|
|
156
142
|
[semanticConventions.SEMATTRS_HTTP_CLIENT_IP]: request.headers.get("x-forwarded-for")?.split(",")[0],
|
|
157
143
|
[semanticConventions.SEMATTRS_HTTP_USER_AGENT]: request.headers.get("user-agent") || void 0,
|
|
158
|
-
"hive.client.name": request.headers.get("x-graphql-client-name") || void 0,
|
|
159
|
-
"hive.client.version": request.headers.get("x-graphql-client-version") || void 0
|
|
144
|
+
"hive.client.name": request.headers.get("graphql-client-name") || request.headers.get("x-graphql-client-name") || void 0,
|
|
145
|
+
"hive.client.version": request.headers.get("graphql-client-version") || request.headers.get("x-graphql-client-version") || void 0
|
|
160
146
|
},
|
|
161
147
|
kind: api.SpanKind.SERVER
|
|
162
148
|
},
|
|
@@ -257,27 +243,7 @@ function setGraphQLParseAttributes(input) {
|
|
|
257
243
|
span.setAttribute(SEMATTRS_GRAPHQL_DOCUMENT, input.query);
|
|
258
244
|
}
|
|
259
245
|
if (input.result instanceof Error) {
|
|
260
|
-
|
|
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
|
-
}
|
|
246
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, 1);
|
|
281
247
|
} else {
|
|
282
248
|
const document = input.result;
|
|
283
249
|
const operation = getOperationFromDocument(document, input.operationName);
|
|
@@ -316,34 +282,21 @@ function setGraphQLValidateAttributes(input) {
|
|
|
316
282
|
if (result instanceof Error) {
|
|
317
283
|
errors.push(result);
|
|
318
284
|
}
|
|
319
|
-
if (errors.length
|
|
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) {
|
|
285
|
+
if (errors.length > 0) {
|
|
328
286
|
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.length);
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
for (const exception of exceptions) {
|
|
340
|
-
span.recordException(exception);
|
|
287
|
+
span.setStatus({
|
|
288
|
+
code: api.SpanStatusCode.ERROR,
|
|
289
|
+
message: result.map((e) => e.message).join(", ")
|
|
290
|
+
});
|
|
291
|
+
const codes = [];
|
|
292
|
+
for (const error of result) {
|
|
293
|
+
if (error.extensions?.code) {
|
|
294
|
+
codes.push(`${error.extensions.code}`);
|
|
295
|
+
}
|
|
296
|
+
span.recordException(error);
|
|
341
297
|
}
|
|
298
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
342
299
|
}
|
|
343
|
-
span.setStatus({
|
|
344
|
-
code: api.SpanStatusCode.ERROR,
|
|
345
|
-
message: "GraphQL Validation Error"
|
|
346
|
-
});
|
|
347
300
|
}
|
|
348
301
|
function createGraphQLExecuteSpan(input) {
|
|
349
302
|
const span = input.tracer.startSpan(
|
|
@@ -382,30 +335,33 @@ function setGraphQLExecutionAttributes(input) {
|
|
|
382
335
|
}
|
|
383
336
|
}
|
|
384
337
|
function setGraphQLExecutionResultAttributes(input) {
|
|
385
|
-
const { ctx,
|
|
338
|
+
const { ctx, result } = input;
|
|
386
339
|
const span = api.trace.getSpan(ctx);
|
|
387
|
-
if (span) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
340
|
+
if (!span) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (input.subgraphNames?.length) {
|
|
344
|
+
span.setAttribute(
|
|
345
|
+
SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES,
|
|
346
|
+
input.subgraphNames
|
|
347
|
+
);
|
|
394
348
|
}
|
|
395
|
-
const operationSpan = api.trace.getSpan(operationCtx);
|
|
396
349
|
if (!utils.isAsyncIterable(result) && // FIXME: Handle async iterable too
|
|
397
350
|
result.errors && result.errors.length > 0) {
|
|
398
|
-
span
|
|
399
|
-
span
|
|
351
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, result.errors.length);
|
|
352
|
+
span.setStatus({
|
|
400
353
|
code: api.SpanStatusCode.ERROR,
|
|
401
|
-
message:
|
|
354
|
+
message: result.errors.map((e) => e.message).join(", ")
|
|
402
355
|
});
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
"
|
|
408
|
-
|
|
356
|
+
const codes = [];
|
|
357
|
+
for (const error of result.errors) {
|
|
358
|
+
span.recordException(error);
|
|
359
|
+
if (error.extensions?.["code"]) {
|
|
360
|
+
codes.push(`${error.extensions["code"]}`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (codes.length > 0) {
|
|
364
|
+
span.setAttribute(SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, codes);
|
|
409
365
|
}
|
|
410
366
|
}
|
|
411
367
|
}
|
|
@@ -550,70 +506,6 @@ const getOperationFromDocument = (document, operationName) => {
|
|
|
550
506
|
operationNameMap.set(operationName ?? null, operation);
|
|
551
507
|
return operation;
|
|
552
508
|
};
|
|
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
|
-
}
|
|
617
509
|
|
|
618
510
|
function getEnvStr(key, opts = {}) {
|
|
619
511
|
const globalThat = opts.globalThis ?? globalThis;
|
|
@@ -748,7 +640,7 @@ function useOpenTelemetry(options) {
|
|
|
748
640
|
},
|
|
749
641
|
instrumentation: {
|
|
750
642
|
request({ state: { forRequest }, request }, wrapped) {
|
|
751
|
-
return
|
|
643
|
+
return promiseHelpers.unfakePromise(
|
|
752
644
|
preparation$.then(() => {
|
|
753
645
|
if (!traces || !shouldTrace(traces.spans?.http, { request, ignoredRequests })) {
|
|
754
646
|
return wrapped();
|
|
@@ -779,7 +671,7 @@ function useOpenTelemetry(options) {
|
|
|
779
671
|
if (!traces || !isParentEnabled(parentState) || !shouldTrace(traces.spans?.graphql, { context: gqlCtx })) {
|
|
780
672
|
return wrapped();
|
|
781
673
|
}
|
|
782
|
-
return
|
|
674
|
+
return promiseHelpers.unfakePromise(
|
|
783
675
|
preparation$.then(() => {
|
|
784
676
|
const ctx = getContext(parentState);
|
|
785
677
|
forOperation.otel = new OtelContextStack(
|
|
@@ -834,9 +726,7 @@ function useOpenTelemetry(options) {
|
|
|
834
726
|
try {
|
|
835
727
|
wrapped();
|
|
836
728
|
} catch (err) {
|
|
837
|
-
|
|
838
|
-
registerException(forOperation.otel.current, err);
|
|
839
|
-
}
|
|
729
|
+
registerException(forOperation.otel.current, err);
|
|
840
730
|
throw err;
|
|
841
731
|
} finally {
|
|
842
732
|
api.trace.getSpan(forOperation.otel.current)?.end();
|
|
@@ -875,7 +765,7 @@ function useOpenTelemetry(options) {
|
|
|
875
765
|
if (useContextManager) {
|
|
876
766
|
wrapped = api.context.bind(forOperation.otel.current, wrapped);
|
|
877
767
|
}
|
|
878
|
-
return
|
|
768
|
+
return promiseHelpers.unfakePromise(
|
|
879
769
|
utils.fakePromise().then(wrapped).catch((err) => {
|
|
880
770
|
registerException(forOperation.otel.current, err);
|
|
881
771
|
throw err;
|
|
@@ -912,7 +802,7 @@ function useOpenTelemetry(options) {
|
|
|
912
802
|
if (useContextManager) {
|
|
913
803
|
wrapped = api.context.bind(forSubgraphExecution.otel.current, wrapped);
|
|
914
804
|
}
|
|
915
|
-
return
|
|
805
|
+
return promiseHelpers.unfakePromise(
|
|
916
806
|
utils.fakePromise().then(wrapped).catch((err) => {
|
|
917
807
|
registerException(forSubgraphExecution.otel.current, err);
|
|
918
808
|
throw err;
|
|
@@ -926,7 +816,7 @@ function useOpenTelemetry(options) {
|
|
|
926
816
|
if (gatewayRuntime.isRetryExecutionRequest(executionRequest)) {
|
|
927
817
|
state = getState(gatewayRuntime.getRetryInfo(executionRequest));
|
|
928
818
|
}
|
|
929
|
-
return
|
|
819
|
+
return promiseHelpers.unfakePromise(
|
|
930
820
|
preparation$.then(() => {
|
|
931
821
|
if (!traces || !isParentEnabled(state) || !shouldTrace(traces.spans?.upstreamFetch, { executionRequest })) {
|
|
932
822
|
return wrapped();
|
|
@@ -951,7 +841,7 @@ function useOpenTelemetry(options) {
|
|
|
951
841
|
);
|
|
952
842
|
},
|
|
953
843
|
schema(_, wrapped) {
|
|
954
|
-
return
|
|
844
|
+
return promiseHelpers.unfakePromise(
|
|
955
845
|
preparation$.then(() => {
|
|
956
846
|
if (!traces || !shouldTrace(traces.spans?.schema, null)) {
|
|
957
847
|
return wrapped();
|
|
@@ -969,9 +859,6 @@ function useOpenTelemetry(options) {
|
|
|
969
859
|
);
|
|
970
860
|
}
|
|
971
861
|
},
|
|
972
|
-
onPluginInit({ addPlugin }) {
|
|
973
|
-
addPlugin(useErrorCoordinate());
|
|
974
|
-
},
|
|
975
862
|
onYogaInit({ yoga }) {
|
|
976
863
|
pluginLogger ??= new gatewayRuntime.Logger({
|
|
977
864
|
writers: [
|
|
@@ -1064,7 +951,6 @@ function useOpenTelemetry(options) {
|
|
|
1064
951
|
return ({ result }) => {
|
|
1065
952
|
setGraphQLParseAttributes({
|
|
1066
953
|
ctx: getContext(state),
|
|
1067
|
-
operationCtx: state.forOperation.otel.root,
|
|
1068
954
|
operationName: gqlCtx.params.operationName,
|
|
1069
955
|
query: gqlCtx.params.query?.trim(),
|
|
1070
956
|
result
|
|
@@ -1085,7 +971,6 @@ function useOpenTelemetry(options) {
|
|
|
1085
971
|
return ({ result }) => {
|
|
1086
972
|
setGraphQLValidateAttributes({
|
|
1087
973
|
ctx: getContext(state),
|
|
1088
|
-
operationCtx: state.forOperation.otel.root,
|
|
1089
974
|
result,
|
|
1090
975
|
document: params.documentAST,
|
|
1091
976
|
operationName: gqlCtx.params.operationName
|
|
@@ -1109,7 +994,6 @@ function useOpenTelemetry(options) {
|
|
|
1109
994
|
setGraphQLExecutionResultAttributes({
|
|
1110
995
|
ctx,
|
|
1111
996
|
result,
|
|
1112
|
-
operationCtx: state.forOperation.otel.root,
|
|
1113
997
|
subgraphNames: state.forOperation.subgraphNames
|
|
1114
998
|
});
|
|
1115
999
|
}
|
|
@@ -1222,14 +1106,8 @@ exports.SEMATTRS_GRAPHQL_OPERATION_NAME = SEMATTRS_GRAPHQL_OPERATION_NAME;
|
|
|
1222
1106
|
exports.SEMATTRS_GRAPHQL_OPERATION_TYPE = SEMATTRS_GRAPHQL_OPERATION_TYPE;
|
|
1223
1107
|
exports.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES;
|
|
1224
1108
|
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;
|
|
1226
1109
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = SEMATTRS_HIVE_GRAPHQL_ERROR_CODES;
|
|
1227
1110
|
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;
|
|
1233
1111
|
exports.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH;
|
|
1234
1112
|
exports.diagLogLevelFromEnv = diagLogLevelFromEnv;
|
|
1235
1113
|
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-DOyRaHdT.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,6 +104,10 @@ 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
|
+
}
|
|
107
111
|
if (span.name === "graphql.execute") {
|
|
108
112
|
copyAttribute(
|
|
109
113
|
span,
|
|
@@ -141,6 +145,11 @@ function isOperationSpan(span) {
|
|
|
141
145
|
const followingChar = span.name.at(17);
|
|
142
146
|
return !followingChar || followingChar === " ";
|
|
143
147
|
}
|
|
148
|
+
const SPANS_WITH_ERRORS = [
|
|
149
|
+
"graphql.parse",
|
|
150
|
+
"graphql.validate",
|
|
151
|
+
"graphql.execute"
|
|
152
|
+
];
|
|
144
153
|
|
|
145
154
|
class OpenTelemetryLogWriter {
|
|
146
155
|
logger;
|
|
@@ -215,10 +224,10 @@ function getContextForRequest(attributes) {
|
|
|
215
224
|
return plugin.otelCtxForRequestId.get(attributes.requestId) ?? api.ROOT_CONTEXT;
|
|
216
225
|
}
|
|
217
226
|
|
|
218
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.3.0-alpha-
|
|
227
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.3.0-alpha-b079a2654a7efe1afbc720b58220e3474da04a3a';
|
|
219
228
|
let initialized = false;
|
|
220
229
|
function openTelemetrySetup(options) {
|
|
221
|
-
const log =
|
|
230
|
+
const log = options.log || new logger.Logger();
|
|
222
231
|
if (initialized) {
|
|
223
232
|
log.error(
|
|
224
233
|
`${initialized.name} integration has already been initialized by ${initialized.source}`
|
|
@@ -311,7 +320,7 @@ function openTelemetrySetup(options) {
|
|
|
311
320
|
log.info(logAttributes, logMessage);
|
|
312
321
|
}
|
|
313
322
|
function hiveTracingSetup(options) {
|
|
314
|
-
const log =
|
|
323
|
+
const log = options.log || new logger.Logger();
|
|
315
324
|
options.target ??= plugin.getEnvStr("HIVE_TARGET");
|
|
316
325
|
if (!options.target) {
|
|
317
326
|
throw new Error(
|
|
@@ -452,14 +461,8 @@ exports.SEMATTRS_GRAPHQL_OPERATION_NAME = plugin.SEMATTRS_GRAPHQL_OPERATION_NAME
|
|
|
452
461
|
exports.SEMATTRS_GRAPHQL_OPERATION_TYPE = plugin.SEMATTRS_GRAPHQL_OPERATION_TYPE;
|
|
453
462
|
exports.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES = plugin.SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES;
|
|
454
463
|
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;
|
|
456
464
|
exports.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES = plugin.SEMATTRS_HIVE_GRAPHQL_ERROR_CODES;
|
|
457
465
|
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;
|
|
463
466
|
exports.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH = plugin.SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH;
|
|
464
467
|
exports.HIVE_LOG_LEVEL_NUMBERS = HIVE_LOG_LEVEL_NUMBERS;
|
|
465
468
|
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, g as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, f as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-mikIPKnv.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;
|
|
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, g as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, f as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './attributes-mikIPKnv.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;
|
|
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 { e as SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, d as SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, g as SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, o as otelCtxForRequestId, h as getEnvBool, i as diagLogLevelFromEnv, j as getEnvStr } from './plugin-CepZPqbb.js';
|
|
9
|
+
export { S as SEMATTRS_GRAPHQL_DOCUMENT, b as SEMATTRS_GRAPHQL_OPERATION_NAME, a as SEMATTRS_GRAPHQL_OPERATION_TYPE, f as SEMATTRS_HIVE_GATEWAY_UPSTREAM_SUBGRAPH_NAME, c as SEMATTRS_HIVE_GRAPHQL_OPERATION_HASH } from './plugin-CepZPqbb.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,6 +104,10 @@ 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
|
+
}
|
|
107
111
|
if (span.name === "graphql.execute") {
|
|
108
112
|
copyAttribute(
|
|
109
113
|
span,
|
|
@@ -141,6 +145,11 @@ function isOperationSpan(span) {
|
|
|
141
145
|
const followingChar = span.name.at(17);
|
|
142
146
|
return !followingChar || followingChar === " ";
|
|
143
147
|
}
|
|
148
|
+
const SPANS_WITH_ERRORS = [
|
|
149
|
+
"graphql.parse",
|
|
150
|
+
"graphql.validate",
|
|
151
|
+
"graphql.execute"
|
|
152
|
+
];
|
|
144
153
|
|
|
145
154
|
class OpenTelemetryLogWriter {
|
|
146
155
|
logger;
|
|
@@ -215,10 +224,10 @@ function getContextForRequest(attributes) {
|
|
|
215
224
|
return otelCtxForRequestId.get(attributes.requestId) ?? ROOT_CONTEXT;
|
|
216
225
|
}
|
|
217
226
|
|
|
218
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.3.0-alpha-
|
|
227
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.3.0-alpha-b079a2654a7efe1afbc720b58220e3474da04a3a';
|
|
219
228
|
let initialized = false;
|
|
220
229
|
function openTelemetrySetup(options) {
|
|
221
|
-
const log =
|
|
230
|
+
const log = options.log || new Logger();
|
|
222
231
|
if (initialized) {
|
|
223
232
|
log.error(
|
|
224
233
|
`${initialized.name} integration has already been initialized by ${initialized.source}`
|
|
@@ -311,7 +320,7 @@ function openTelemetrySetup(options) {
|
|
|
311
320
|
log.info(logAttributes, logMessage);
|
|
312
321
|
}
|
|
313
322
|
function hiveTracingSetup(options) {
|
|
314
|
-
const log =
|
|
323
|
+
const log = options.log || new Logger();
|
|
315
324
|
options.target ??= getEnvStr("HIVE_TARGET");
|
|
316
325
|
if (!options.target) {
|
|
317
326
|
throw new Error(
|
|
@@ -399,4 +408,4 @@ function disable() {
|
|
|
399
408
|
initialized = false;
|
|
400
409
|
}
|
|
401
410
|
|
|
402
|
-
export { HIVE_LOG_LEVEL_NUMBERS, HiveTracingSpanProcessor, OpenTelemetryLogWriter, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, disable, getContextForRequest, hiveTracingSetup, openTelemetrySetup };
|
|
411
|
+
export { HIVE_LOG_LEVEL_NUMBERS, HiveTracingSpanProcessor, OpenTelemetryLogWriter, SEMATTRS_HIVE_GATEWAY_OPERATION_SUBGRAPH_NAMES, SEMATTRS_HIVE_GRAPHQL_ERROR_CODES, SEMATTRS_HIVE_GRAPHQL_ERROR_COUNT, 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.0-alpha-
|
|
3
|
+
"version": "1.3.0-alpha-b079a2654a7efe1afbc720b58220e3474da04a3a",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,13 +63,12 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@graphql-hive/core": "^0.18.0",
|
|
66
|
-
"@graphql-hive/gateway-runtime": "2.5.0-alpha-
|
|
66
|
+
"@graphql-hive/gateway-runtime": "2.5.0-alpha-b079a2654a7efe1afbc720b58220e3474da04a3a",
|
|
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",
|
|
73
72
|
"@graphql-tools/utils": "^10.10.3",
|
|
74
73
|
"@opentelemetry/api": "^1.9.0",
|
|
75
74
|
"@opentelemetry/api-logs": "^0.208.0",
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
"devDependencies": {
|
|
91
90
|
"@whatwg-node/server": "^0.10.17",
|
|
92
91
|
"graphql": "^16.12.0",
|
|
93
|
-
"graphql-yoga": "^5.
|
|
92
|
+
"graphql-yoga": "^5.16.2",
|
|
94
93
|
"pkgroll": "2.21.4",
|
|
95
94
|
"rimraf": "^6.1.0",
|
|
96
95
|
"rollup": "^4.53.2",
|
|
@@ -1,16 +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_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 };
|