@graphql-hive/plugin-opentelemetry 1.0.0 → 1.0.1-alpha-8561cee07b36caa6aea9cb87f8940ba34dbf206a
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 +7 -0
- package/dist/setup.cjs +8 -6
- package/dist/setup.js +8 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @graphql-hive/plugin-opentelemetry
|
|
2
2
|
|
|
3
|
+
## 1.0.1-alpha-8561cee07b36caa6aea9cb87f8940ba34dbf206a
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#1439](https://github.com/graphql-hive/gateway/pull/1439) [`9fcf4a6`](https://github.com/graphql-hive/gateway/commit/9fcf4a631592e4b3db46da8543e840de2d97c535) Thanks [@enisdenjo](https://github.com/enisdenjo)! - Create default logger if not supplied when setting up
|
|
9
|
+
|
|
3
10
|
## 1.0.0
|
|
4
11
|
### Major Changes
|
|
5
12
|
|
package/dist/setup.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var logger = require('@graphql-hive/logger');
|
|
3
4
|
var api = require('@opentelemetry/api');
|
|
4
5
|
var core = require('@opentelemetry/core');
|
|
5
6
|
var resources = require('@opentelemetry/resources');
|
|
@@ -208,11 +209,11 @@ function getContextForRequest(attributes) {
|
|
|
208
209
|
return plugin.otelCtxForRequestId.get(attributes.requestId) ?? api.ROOT_CONTEXT;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.0.
|
|
212
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.0.1-alpha-8561cee07b36caa6aea9cb87f8940ba34dbf206a';
|
|
212
213
|
function openTelemetrySetup(options) {
|
|
213
|
-
const log = options.log
|
|
214
|
+
const log = options.log || new logger.Logger();
|
|
214
215
|
if (plugin.getEnvBool("OTEL_SDK_DISABLED")) {
|
|
215
|
-
log
|
|
216
|
+
log.warn(
|
|
216
217
|
"OpenTelemetry integration is disabled because `OTEL_SDK_DISABLED` environment variable is truthy"
|
|
217
218
|
);
|
|
218
219
|
return;
|
|
@@ -278,10 +279,10 @@ function openTelemetrySetup(options) {
|
|
|
278
279
|
propagators.length === 1 ? propagators[0] : new core.CompositePropagator({ propagators })
|
|
279
280
|
);
|
|
280
281
|
}
|
|
281
|
-
log
|
|
282
|
+
log.info(logAttributes, logMessage);
|
|
282
283
|
}
|
|
283
284
|
function hiveTracingSetup(config) {
|
|
284
|
-
const log = config.log
|
|
285
|
+
const log = config.log || new logger.Logger();
|
|
285
286
|
config.target ??= plugin.getEnvStr("HIVE_TARGET");
|
|
286
287
|
if (!config.target) {
|
|
287
288
|
throw new Error(
|
|
@@ -300,6 +301,7 @@ function hiveTracingSetup(config) {
|
|
|
300
301
|
logAttributes["batching"] = config.batching;
|
|
301
302
|
}
|
|
302
303
|
openTelemetrySetup({
|
|
304
|
+
log,
|
|
303
305
|
contextManager: config.contextManager,
|
|
304
306
|
resource: resources.resourceFromAttributes({
|
|
305
307
|
"hive.target_id": config.target
|
|
@@ -310,7 +312,7 @@ function hiveTracingSetup(config) {
|
|
|
310
312
|
]
|
|
311
313
|
}
|
|
312
314
|
});
|
|
313
|
-
log
|
|
315
|
+
log.info(logAttributes, "Hive Tracing integration has been enabled");
|
|
314
316
|
}
|
|
315
317
|
function resolveBatchingConfig(exporter, batchingConfig) {
|
|
316
318
|
const value = batchingConfig ?? true;
|
package/dist/setup.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Logger } from '@graphql-hive/logger';
|
|
1
2
|
import { context, ROOT_CONTEXT, trace, propagation } from '@opentelemetry/api';
|
|
2
3
|
import { hrTimeDuration, W3CBaggagePropagator, W3CTraceContextPropagator, CompositePropagator } from '@opentelemetry/core';
|
|
3
4
|
import { resourceFromAttributes } from '@opentelemetry/resources';
|
|
@@ -208,11 +209,11 @@ function getContextForRequest(attributes) {
|
|
|
208
209
|
return otelCtxForRequestId.get(attributes.requestId) ?? ROOT_CONTEXT;
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
globalThis.__OTEL_PLUGIN_VERSION__ = '1.0.
|
|
212
|
+
globalThis.__OTEL_PLUGIN_VERSION__ = '1.0.1-alpha-8561cee07b36caa6aea9cb87f8940ba34dbf206a';
|
|
212
213
|
function openTelemetrySetup(options) {
|
|
213
|
-
const log = options.log
|
|
214
|
+
const log = options.log || new Logger();
|
|
214
215
|
if (getEnvBool("OTEL_SDK_DISABLED")) {
|
|
215
|
-
log
|
|
216
|
+
log.warn(
|
|
216
217
|
"OpenTelemetry integration is disabled because `OTEL_SDK_DISABLED` environment variable is truthy"
|
|
217
218
|
);
|
|
218
219
|
return;
|
|
@@ -278,10 +279,10 @@ function openTelemetrySetup(options) {
|
|
|
278
279
|
propagators.length === 1 ? propagators[0] : new CompositePropagator({ propagators })
|
|
279
280
|
);
|
|
280
281
|
}
|
|
281
|
-
log
|
|
282
|
+
log.info(logAttributes, logMessage);
|
|
282
283
|
}
|
|
283
284
|
function hiveTracingSetup(config) {
|
|
284
|
-
const log = config.log
|
|
285
|
+
const log = config.log || new Logger();
|
|
285
286
|
config.target ??= getEnvStr("HIVE_TARGET");
|
|
286
287
|
if (!config.target) {
|
|
287
288
|
throw new Error(
|
|
@@ -300,6 +301,7 @@ function hiveTracingSetup(config) {
|
|
|
300
301
|
logAttributes["batching"] = config.batching;
|
|
301
302
|
}
|
|
302
303
|
openTelemetrySetup({
|
|
304
|
+
log,
|
|
303
305
|
contextManager: config.contextManager,
|
|
304
306
|
resource: resourceFromAttributes({
|
|
305
307
|
"hive.target_id": config.target
|
|
@@ -310,7 +312,7 @@ function hiveTracingSetup(config) {
|
|
|
310
312
|
]
|
|
311
313
|
}
|
|
312
314
|
});
|
|
313
|
-
log
|
|
315
|
+
log.info(logAttributes, "Hive Tracing integration has been enabled");
|
|
314
316
|
}
|
|
315
317
|
function resolveBatchingConfig(exporter, batchingConfig) {
|
|
316
318
|
const value = batchingConfig ?? true;
|