@graphql-hive/plugin-opentelemetry 1.2.1-alpha-6eb80c8595c2094712a91dceffae42799f922807 → 1.2.1-alpha-ddc12a9e4831789ab7d677ef93157e9fb5f92edc
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 +32 -35
- package/dist/setup.d.cts +2 -1
- package/dist/setup.d.ts +2 -1
- package/dist/setup.js +32 -35
- 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-ddc12a9e4831789ab7d677ef93157e9fb5f92edc
|
|
4
4
|
### Patch Changes
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
- [#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
- [#1721](https://github.com/graphql-hive/gateway/pull/1721) [`ddc12a9`](https://github.com/graphql-hive/gateway/commit/ddc12a9e4831789ab7d677ef93157e9fb5f92edc) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Have a default endpoint for Hive Tracing
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
- [#1721](https://github.com/graphql-hive/gateway/pull/1721) [`ddc12a9`](https://github.com/graphql-hive/gateway/commit/ddc12a9e4831789ab7d677ef93157e9fb5f92edc) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Improved default resource service name and version to use Hive Gateway
|
|
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-ddc12a9e4831789ab7d677ef93157e9fb5f92edc';
|
|
228
228
|
let initialized = false;
|
|
229
229
|
function openTelemetrySetup(options) {
|
|
230
230
|
const log = options.log || new logger.Logger();
|
|
@@ -289,15 +289,7 @@ function openTelemetrySetup(options) {
|
|
|
289
289
|
logMessage += " in addition to an stdout debug exporter";
|
|
290
290
|
logAttributes["console"] = true;
|
|
291
291
|
}
|
|
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
|
-
);
|
|
292
|
+
const resource = createResource(options);
|
|
301
293
|
logAttributes["resource"] = resource.attributes;
|
|
302
294
|
logAttributes["sampling"] = options.sampler ? "custom" : options.samplingRate;
|
|
303
295
|
logAttributes["registrationResults"].tracerProvider = api.trace.setGlobalTracerProvider(
|
|
@@ -339,33 +331,41 @@ function hiveTracingSetup(options) {
|
|
|
339
331
|
...options._initialization?.logAttributes,
|
|
340
332
|
target: options.target
|
|
341
333
|
};
|
|
342
|
-
|
|
334
|
+
let processorOptions;
|
|
335
|
+
if (options.processor) {
|
|
336
|
+
processorOptions = { processor: options.processor };
|
|
337
|
+
} else {
|
|
343
338
|
options.accessToken ??= plugin.getEnvStr("HIVE_TRACING_ACCESS_TOKEN") ?? plugin.getEnvStr("HIVE_ACCESS_TOKEN");
|
|
344
339
|
if (!options.accessToken) {
|
|
345
340
|
throw new Error(
|
|
346
|
-
|
|
341
|
+
'You must specify the Hive Registry access token. Either provide the "accessToken" option or "HIVE_ACCESS_TOKEN"/"HIVE_TRACE_ACCESS_TOKEN" environment variable.'
|
|
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.'
|
|
347
348
|
);
|
|
348
349
|
}
|
|
350
|
+
processorOptions = {
|
|
351
|
+
target: options.target,
|
|
352
|
+
accessToken: options.accessToken,
|
|
353
|
+
endpoint: options.endpoint,
|
|
354
|
+
batching: options.batching
|
|
355
|
+
};
|
|
349
356
|
logAttributes["endpoint"] = options.endpoint;
|
|
350
357
|
logAttributes["batching"] = options.batching;
|
|
351
358
|
}
|
|
352
359
|
openTelemetrySetup({
|
|
353
360
|
...options,
|
|
354
361
|
log,
|
|
355
|
-
resource: createResource(
|
|
362
|
+
resource: createResource(options).merge(
|
|
356
363
|
resources.resourceFromAttributes({
|
|
357
|
-
"hive.target_id": options.target
|
|
358
|
-
|
|
359
|
-
[semanticConventions.ATTR_SERVICE_VERSION]: plugin.getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
360
|
-
}),
|
|
361
|
-
options.resource
|
|
364
|
+
"hive.target_id": options.target
|
|
365
|
+
})
|
|
362
366
|
),
|
|
363
367
|
traces: {
|
|
364
|
-
processors: [
|
|
365
|
-
new HiveTracingSpanProcessor(
|
|
366
|
-
options
|
|
367
|
-
)
|
|
368
|
-
],
|
|
368
|
+
processors: [new HiveTracingSpanProcessor(processorOptions)],
|
|
369
369
|
spanLimits: options.spanLimits,
|
|
370
370
|
console: options.console
|
|
371
371
|
},
|
|
@@ -386,19 +386,16 @@ 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
|
-
[semanticConventions.ATTR_SERVICE_VERSION]: userResource.serviceVersion
|
|
398
|
-
})
|
|
399
|
-
);
|
|
389
|
+
function createResource(opts) {
|
|
390
|
+
let resource = resources.resourceFromAttributes({
|
|
391
|
+
[semanticConventions.ATTR_SERVICE_NAME]: opts.resource && "serviceName" in opts.resource ? opts.resource.serviceName : plugin.getEnvStr("OTEL_SERVICE_NAME") || "hive-gateway",
|
|
392
|
+
[semanticConventions.ATTR_SERVICE_VERSION]: opts.resource && "serviceVersion" in opts.resource ? opts.resource.serviceVersion : plugin.getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__VERSION__ || "unknown",
|
|
393
|
+
["hive.otel.version"]: globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
394
|
+
});
|
|
395
|
+
if (opts.resource && "attributes" in opts.resource) {
|
|
396
|
+
resource = resource.merge(opts.resource);
|
|
400
397
|
}
|
|
401
|
-
return
|
|
398
|
+
return resource;
|
|
402
399
|
}
|
|
403
400
|
function getStackTrace() {
|
|
404
401
|
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,6 +179,7 @@ type HiveTracingOptions = {
|
|
|
179
179
|
accessToken?: string;
|
|
180
180
|
batching?: BufferConfig;
|
|
181
181
|
processor?: never;
|
|
182
|
+
/** @default 'https://api.graphql-hive.com/otel/v1/traces' */
|
|
182
183
|
endpoint?: string;
|
|
183
184
|
} | {
|
|
184
185
|
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,6 +179,7 @@ type HiveTracingOptions = {
|
|
|
179
179
|
accessToken?: string;
|
|
180
180
|
batching?: BufferConfig;
|
|
181
181
|
processor?: never;
|
|
182
|
+
/** @default 'https://api.graphql-hive.com/otel/v1/traces' */
|
|
182
183
|
endpoint?: string;
|
|
183
184
|
} | {
|
|
184
185
|
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-ddc12a9e4831789ab7d677ef93157e9fb5f92edc';
|
|
228
228
|
let initialized = false;
|
|
229
229
|
function openTelemetrySetup(options) {
|
|
230
230
|
const log = options.log || new Logger();
|
|
@@ -289,15 +289,7 @@ function openTelemetrySetup(options) {
|
|
|
289
289
|
logMessage += " in addition to an stdout debug exporter";
|
|
290
290
|
logAttributes["console"] = true;
|
|
291
291
|
}
|
|
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
|
-
);
|
|
292
|
+
const resource = createResource(options);
|
|
301
293
|
logAttributes["resource"] = resource.attributes;
|
|
302
294
|
logAttributes["sampling"] = options.sampler ? "custom" : options.samplingRate;
|
|
303
295
|
logAttributes["registrationResults"].tracerProvider = trace.setGlobalTracerProvider(
|
|
@@ -339,33 +331,41 @@ function hiveTracingSetup(options) {
|
|
|
339
331
|
...options._initialization?.logAttributes,
|
|
340
332
|
target: options.target
|
|
341
333
|
};
|
|
342
|
-
|
|
334
|
+
let processorOptions;
|
|
335
|
+
if (options.processor) {
|
|
336
|
+
processorOptions = { processor: options.processor };
|
|
337
|
+
} else {
|
|
343
338
|
options.accessToken ??= getEnvStr("HIVE_TRACING_ACCESS_TOKEN") ?? getEnvStr("HIVE_ACCESS_TOKEN");
|
|
344
339
|
if (!options.accessToken) {
|
|
345
340
|
throw new Error(
|
|
346
|
-
|
|
341
|
+
'You must specify the Hive Registry access token. Either provide the "accessToken" option or "HIVE_ACCESS_TOKEN"/"HIVE_TRACE_ACCESS_TOKEN" environment variable.'
|
|
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.'
|
|
347
348
|
);
|
|
348
349
|
}
|
|
350
|
+
processorOptions = {
|
|
351
|
+
target: options.target,
|
|
352
|
+
accessToken: options.accessToken,
|
|
353
|
+
endpoint: options.endpoint,
|
|
354
|
+
batching: options.batching
|
|
355
|
+
};
|
|
349
356
|
logAttributes["endpoint"] = options.endpoint;
|
|
350
357
|
logAttributes["batching"] = options.batching;
|
|
351
358
|
}
|
|
352
359
|
openTelemetrySetup({
|
|
353
360
|
...options,
|
|
354
361
|
log,
|
|
355
|
-
resource: createResource(
|
|
362
|
+
resource: createResource(options).merge(
|
|
356
363
|
resourceFromAttributes({
|
|
357
|
-
"hive.target_id": options.target
|
|
358
|
-
|
|
359
|
-
[ATTR_SERVICE_VERSION]: getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
360
|
-
}),
|
|
361
|
-
options.resource
|
|
364
|
+
"hive.target_id": options.target
|
|
365
|
+
})
|
|
362
366
|
),
|
|
363
367
|
traces: {
|
|
364
|
-
processors: [
|
|
365
|
-
new HiveTracingSpanProcessor(
|
|
366
|
-
options
|
|
367
|
-
)
|
|
368
|
-
],
|
|
368
|
+
processors: [new HiveTracingSpanProcessor(processorOptions)],
|
|
369
369
|
spanLimits: options.spanLimits,
|
|
370
370
|
console: options.console
|
|
371
371
|
},
|
|
@@ -386,19 +386,16 @@ 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
|
-
[ATTR_SERVICE_VERSION]: userResource.serviceVersion
|
|
398
|
-
})
|
|
399
|
-
);
|
|
389
|
+
function createResource(opts) {
|
|
390
|
+
let resource = resourceFromAttributes({
|
|
391
|
+
[ATTR_SERVICE_NAME]: opts.resource && "serviceName" in opts.resource ? opts.resource.serviceName : getEnvStr("OTEL_SERVICE_NAME") || "hive-gateway",
|
|
392
|
+
[ATTR_SERVICE_VERSION]: opts.resource && "serviceVersion" in opts.resource ? opts.resource.serviceVersion : getEnvStr("OTEL_SERVICE_VERSION") || globalThis.__VERSION__ || "unknown",
|
|
393
|
+
["hive.otel.version"]: globalThis.__OTEL_PLUGIN_VERSION__ || "unknown"
|
|
394
|
+
});
|
|
395
|
+
if (opts.resource && "attributes" in opts.resource) {
|
|
396
|
+
resource = resource.merge(opts.resource);
|
|
400
397
|
}
|
|
401
|
-
return
|
|
398
|
+
return resource;
|
|
402
399
|
}
|
|
403
400
|
function getStackTrace() {
|
|
404
401
|
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-ddc12a9e4831789ab7d677ef93157e9fb5f92edc",
|
|
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": "2.3.
|
|
65
|
+
"@graphql-hive/core": "^0.13.2",
|
|
66
|
+
"@graphql-hive/gateway-runtime": "^2.3.5",
|
|
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.20.1",
|
|
94
94
|
"rimraf": "^6.1.0",
|
|
95
95
|
"rollup": "^4.53.2",
|
|
96
96
|
"tsx": "^4.20.6"
|