@graphql-hive/plugin-opentelemetry 1.2.1-alpha-1bfda770fe8ac08e452e19fceb9f1e162148ae75 → 1.2.1-alpha-733211e59a08254c37aa5a53c25943d64070bab3
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 +6 -6
- package/dist/setup.cjs +35 -33
- package/dist/setup.d.cts +1 -2
- package/dist/setup.d.ts +1 -2
- package/dist/setup.js +35 -33
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @graphql-hive/plugin-opentelemetry
|
|
2
2
|
|
|
3
|
-
## 1.2.1-alpha-
|
|
3
|
+
## 1.2.1-alpha-733211e59a08254c37aa5a53c25943d64070bab3
|
|
4
4
|
### Patch Changes
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
- [#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
8
|
+
- [#1725](https://github.com/graphql-hive/gateway/pull/1725) [`733211e`](https://github.com/graphql-hive/gateway/commit/733211e59a08254c37aa5a53c25943d64070bab3) Thanks [@dependabot](https://github.com/apps/dependabot)! - dependencies updates:
|
|
9
|
+
|
|
10
|
+
- 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 [[`733211e`](https://github.com/graphql-hive/gateway/commit/733211e59a08254c37aa5a53c25943d64070bab3)]:
|
|
12
|
+
- @graphql-hive/gateway-runtime@2.3.6-alpha-733211e59a08254c37aa5a53c25943d64070bab3
|
|
13
13
|
|
|
14
14
|
## 1.2.0
|
|
15
15
|
### Minor Changes
|
package/dist/setup.cjs
CHANGED
|
@@ -224,7 +224,7 @@ function getContextForRequest(attributes) {
|
|
|
224
224
|
return plugin.otelCtxForRequestId.get(attributes.requestId) ?? api.ROOT_CONTEXT;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.2.1-alpha-
|
|
227
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.2.1-alpha-733211e59a08254c37aa5a53c25943d64070bab3';
|
|
228
228
|
let initialized = false;
|
|
229
229
|
function openTelemetrySetup(options) {
|
|
230
230
|
const log = options.log || new logger.Logger();
|
|
@@ -289,7 +289,15 @@ function openTelemetrySetup(options) {
|
|
|
289
289
|
logMessage += " in addition to an stdout debug exporter";
|
|
290
290
|
logAttributes["console"] = true;
|
|
291
291
|
}
|
|
292
|
-
const resource = createResource(
|
|
292
|
+
const resource = createResource(
|
|
293
|
+
resources.resourceFromAttributes({
|
|
294
|
+
[semanticConventions.ATTR_SERVICE_NAME]: plugin.getEnvStr("OTEL_SERVICE_NAME") || "@graphql-hive/plugin-opentelemetry",
|
|
295
|
+
[semanticConventions.ATTR_SERVICE_VERSION]: plugin.getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__OTEL_PLUGIN_VERSION__ || "unknown",
|
|
296
|
+
["hive.gateway.version"]: globalThis.__VERSION__,
|
|
297
|
+
["hive.otel.version"]: globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
298
|
+
}),
|
|
299
|
+
options.resource
|
|
300
|
+
);
|
|
293
301
|
logAttributes["resource"] = resource.attributes;
|
|
294
302
|
logAttributes["sampling"] = options.sampler ? "custom" : options.samplingRate;
|
|
295
303
|
logAttributes["registrationResults"].tracerProvider = api.trace.setGlobalTracerProvider(
|
|
@@ -331,41 +339,33 @@ function hiveTracingSetup(options) {
|
|
|
331
339
|
...options._initialization?.logAttributes,
|
|
332
340
|
target: options.target
|
|
333
341
|
};
|
|
334
|
-
|
|
335
|
-
if (options.processor) {
|
|
336
|
-
processorOptions = { processor: options.processor };
|
|
337
|
-
} else {
|
|
342
|
+
if (!options.processor) {
|
|
338
343
|
options.accessToken ??= plugin.getEnvStr("HIVE_TRACING_ACCESS_TOKEN") ?? plugin.getEnvStr("HIVE_ACCESS_TOKEN");
|
|
339
344
|
if (!options.accessToken) {
|
|
340
345
|
throw new Error(
|
|
341
|
-
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
options.endpoint ??= plugin.getEnvStr("HIVE_TRACING_ENDPOINT") ?? "https://api.graphql-hive.com/otel/v1/traces";
|
|
345
|
-
if (!options.endpoint) {
|
|
346
|
-
throw new Error(
|
|
347
|
-
'You must specify the Hive Tracing endpoint. Either provide the "endpoint" option or the "HIVE_TRACING_ENDPOINT" environment variable.'
|
|
346
|
+
"You must specify the Hive Registry `accessToken`. Either provide `accessToken` option or `HIVE_ACCESS_TOKEN`/`HIVE_TRACE_ACCESS_TOKEN` environment variable."
|
|
348
347
|
);
|
|
349
348
|
}
|
|
350
|
-
processorOptions = {
|
|
351
|
-
target: options.target,
|
|
352
|
-
accessToken: options.accessToken,
|
|
353
|
-
endpoint: options.endpoint,
|
|
354
|
-
batching: options.batching
|
|
355
|
-
};
|
|
356
349
|
logAttributes["endpoint"] = options.endpoint;
|
|
357
350
|
logAttributes["batching"] = options.batching;
|
|
358
351
|
}
|
|
359
352
|
openTelemetrySetup({
|
|
360
353
|
...options,
|
|
361
354
|
log,
|
|
362
|
-
resource: createResource(
|
|
355
|
+
resource: createResource(
|
|
363
356
|
resources.resourceFromAttributes({
|
|
364
|
-
"hive.target_id": options.target
|
|
365
|
-
|
|
357
|
+
"hive.target_id": options.target,
|
|
358
|
+
[semanticConventions.ATTR_SERVICE_NAME]: plugin.getEnvStr("OTEL_SERVICE_NAME") || "hive-gateway",
|
|
359
|
+
[semanticConventions.ATTR_SERVICE_VERSION]: plugin.getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
360
|
+
}),
|
|
361
|
+
options.resource
|
|
366
362
|
),
|
|
367
363
|
traces: {
|
|
368
|
-
processors: [
|
|
364
|
+
processors: [
|
|
365
|
+
new HiveTracingSpanProcessor(
|
|
366
|
+
options
|
|
367
|
+
)
|
|
368
|
+
],
|
|
369
369
|
spanLimits: options.spanLimits,
|
|
370
370
|
console: options.console
|
|
371
371
|
},
|
|
@@ -386,17 +386,19 @@ function resolveBatchingConfig(exporter, batchingConfig) {
|
|
|
386
386
|
return new sdkTraceBase.BatchSpanProcessor(exporter, value);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
function createResource(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
389
|
+
function createResource(baseResource, userResource) {
|
|
390
|
+
if (!userResource) {
|
|
391
|
+
return baseResource;
|
|
392
|
+
}
|
|
393
|
+
if ("serviceName" in userResource) {
|
|
394
|
+
return baseResource.merge(
|
|
395
|
+
resources.resourceFromAttributes({
|
|
396
|
+
[semanticConventions.ATTR_SERVICE_NAME]: userResource.serviceName,
|
|
397
|
+
[semanticConventions.ATTR_SERVICE_VERSION]: userResource.serviceVersion
|
|
398
|
+
})
|
|
399
|
+
);
|
|
398
400
|
}
|
|
399
|
-
return
|
|
401
|
+
return baseResource.merge(userResource);
|
|
400
402
|
}
|
|
401
403
|
function getStackTrace() {
|
|
402
404
|
return (new Error().stack ?? "").split("\n").slice(3).join("\n").trim();
|
package/dist/setup.d.cts
CHANGED
|
@@ -133,7 +133,7 @@ type BaseOptions = {
|
|
|
133
133
|
*/
|
|
134
134
|
resource?: Resource | {
|
|
135
135
|
serviceName: string;
|
|
136
|
-
serviceVersion
|
|
136
|
+
serviceVersion: string;
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
139
|
* The Context Manager to be used to track OTEL Context.
|
|
@@ -179,7 +179,6 @@ type HiveTracingOptions = {
|
|
|
179
179
|
accessToken?: string;
|
|
180
180
|
batching?: BufferConfig;
|
|
181
181
|
processor?: never;
|
|
182
|
-
/** @default 'https://api.graphql-hive.com/otel/v1/traces' */
|
|
183
182
|
endpoint?: string;
|
|
184
183
|
} | {
|
|
185
184
|
processor: SpanProcessor;
|
package/dist/setup.d.ts
CHANGED
|
@@ -133,7 +133,7 @@ type BaseOptions = {
|
|
|
133
133
|
*/
|
|
134
134
|
resource?: Resource | {
|
|
135
135
|
serviceName: string;
|
|
136
|
-
serviceVersion
|
|
136
|
+
serviceVersion: string;
|
|
137
137
|
};
|
|
138
138
|
/**
|
|
139
139
|
* The Context Manager to be used to track OTEL Context.
|
|
@@ -179,7 +179,6 @@ type HiveTracingOptions = {
|
|
|
179
179
|
accessToken?: string;
|
|
180
180
|
batching?: BufferConfig;
|
|
181
181
|
processor?: never;
|
|
182
|
-
/** @default 'https://api.graphql-hive.com/otel/v1/traces' */
|
|
183
182
|
endpoint?: string;
|
|
184
183
|
} | {
|
|
185
184
|
processor: SpanProcessor;
|
package/dist/setup.js
CHANGED
|
@@ -224,7 +224,7 @@ function getContextForRequest(attributes) {
|
|
|
224
224
|
return otelCtxForRequestId.get(attributes.requestId) ?? ROOT_CONTEXT;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.2.1-alpha-
|
|
227
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.2.1-alpha-733211e59a08254c37aa5a53c25943d64070bab3';
|
|
228
228
|
let initialized = false;
|
|
229
229
|
function openTelemetrySetup(options) {
|
|
230
230
|
const log = options.log || new Logger();
|
|
@@ -289,7 +289,15 @@ function openTelemetrySetup(options) {
|
|
|
289
289
|
logMessage += " in addition to an stdout debug exporter";
|
|
290
290
|
logAttributes["console"] = true;
|
|
291
291
|
}
|
|
292
|
-
const resource = createResource(
|
|
292
|
+
const resource = createResource(
|
|
293
|
+
resourceFromAttributes({
|
|
294
|
+
[ATTR_SERVICE_NAME]: getEnvStr("OTEL_SERVICE_NAME") || "@graphql-hive/plugin-opentelemetry",
|
|
295
|
+
[ATTR_SERVICE_VERSION]: getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__OTEL_PLUGIN_VERSION__ || "unknown",
|
|
296
|
+
["hive.gateway.version"]: globalThis.__VERSION__,
|
|
297
|
+
["hive.otel.version"]: globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
298
|
+
}),
|
|
299
|
+
options.resource
|
|
300
|
+
);
|
|
293
301
|
logAttributes["resource"] = resource.attributes;
|
|
294
302
|
logAttributes["sampling"] = options.sampler ? "custom" : options.samplingRate;
|
|
295
303
|
logAttributes["registrationResults"].tracerProvider = trace.setGlobalTracerProvider(
|
|
@@ -331,41 +339,33 @@ function hiveTracingSetup(options) {
|
|
|
331
339
|
...options._initialization?.logAttributes,
|
|
332
340
|
target: options.target
|
|
333
341
|
};
|
|
334
|
-
|
|
335
|
-
if (options.processor) {
|
|
336
|
-
processorOptions = { processor: options.processor };
|
|
337
|
-
} else {
|
|
342
|
+
if (!options.processor) {
|
|
338
343
|
options.accessToken ??= getEnvStr("HIVE_TRACING_ACCESS_TOKEN") ?? getEnvStr("HIVE_ACCESS_TOKEN");
|
|
339
344
|
if (!options.accessToken) {
|
|
340
345
|
throw new Error(
|
|
341
|
-
|
|
342
|
-
);
|
|
343
|
-
}
|
|
344
|
-
options.endpoint ??= getEnvStr("HIVE_TRACING_ENDPOINT") ?? "https://api.graphql-hive.com/otel/v1/traces";
|
|
345
|
-
if (!options.endpoint) {
|
|
346
|
-
throw new Error(
|
|
347
|
-
'You must specify the Hive Tracing endpoint. Either provide the "endpoint" option or the "HIVE_TRACING_ENDPOINT" environment variable.'
|
|
346
|
+
"You must specify the Hive Registry `accessToken`. Either provide `accessToken` option or `HIVE_ACCESS_TOKEN`/`HIVE_TRACE_ACCESS_TOKEN` environment variable."
|
|
348
347
|
);
|
|
349
348
|
}
|
|
350
|
-
processorOptions = {
|
|
351
|
-
target: options.target,
|
|
352
|
-
accessToken: options.accessToken,
|
|
353
|
-
endpoint: options.endpoint,
|
|
354
|
-
batching: options.batching
|
|
355
|
-
};
|
|
356
349
|
logAttributes["endpoint"] = options.endpoint;
|
|
357
350
|
logAttributes["batching"] = options.batching;
|
|
358
351
|
}
|
|
359
352
|
openTelemetrySetup({
|
|
360
353
|
...options,
|
|
361
354
|
log,
|
|
362
|
-
resource: createResource(
|
|
355
|
+
resource: createResource(
|
|
363
356
|
resourceFromAttributes({
|
|
364
|
-
"hive.target_id": options.target
|
|
365
|
-
|
|
357
|
+
"hive.target_id": options.target,
|
|
358
|
+
[ATTR_SERVICE_NAME]: getEnvStr("OTEL_SERVICE_NAME") || "hive-gateway",
|
|
359
|
+
[ATTR_SERVICE_VERSION]: getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
360
|
+
}),
|
|
361
|
+
options.resource
|
|
366
362
|
),
|
|
367
363
|
traces: {
|
|
368
|
-
processors: [
|
|
364
|
+
processors: [
|
|
365
|
+
new HiveTracingSpanProcessor(
|
|
366
|
+
options
|
|
367
|
+
)
|
|
368
|
+
],
|
|
369
369
|
spanLimits: options.spanLimits,
|
|
370
370
|
console: options.console
|
|
371
371
|
},
|
|
@@ -386,17 +386,19 @@ function resolveBatchingConfig(exporter, batchingConfig) {
|
|
|
386
386
|
return new BatchSpanProcessor(exporter, value);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
function createResource(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
389
|
+
function createResource(baseResource, userResource) {
|
|
390
|
+
if (!userResource) {
|
|
391
|
+
return baseResource;
|
|
392
|
+
}
|
|
393
|
+
if ("serviceName" in userResource) {
|
|
394
|
+
return baseResource.merge(
|
|
395
|
+
resourceFromAttributes({
|
|
396
|
+
[ATTR_SERVICE_NAME]: userResource.serviceName,
|
|
397
|
+
[ATTR_SERVICE_VERSION]: userResource.serviceVersion
|
|
398
|
+
})
|
|
399
|
+
);
|
|
398
400
|
}
|
|
399
|
-
return
|
|
401
|
+
return baseResource.merge(userResource);
|
|
400
402
|
}
|
|
401
403
|
function getStackTrace() {
|
|
402
404
|
return (new Error().stack ?? "").split("\n").slice(3).join("\n").trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-hive/plugin-opentelemetry",
|
|
3
|
-
"version": "1.2.1-alpha-
|
|
3
|
+
"version": "1.2.1-alpha-733211e59a08254c37aa5a53c25943d64070bab3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"graphql": "^15.9.0 || ^16.9.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@graphql-hive/core": "^0.
|
|
66
|
-
"@graphql-hive/gateway-runtime": "
|
|
65
|
+
"@graphql-hive/core": "^0.15.1",
|
|
66
|
+
"@graphql-hive/gateway-runtime": "2.3.6-alpha-733211e59a08254c37aa5a53c25943d64070bab3",
|
|
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",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@whatwg-node/server": "^0.10.17",
|
|
91
91
|
"graphql": "^16.12.0",
|
|
92
92
|
"graphql-yoga": "^5.16.2",
|
|
93
|
-
"pkgroll": "2.
|
|
93
|
+
"pkgroll": "2.21.3",
|
|
94
94
|
"rimraf": "^6.1.0",
|
|
95
95
|
"rollup": "^4.53.2",
|
|
96
96
|
"tsx": "^4.20.6"
|