@cran/gql.koa
Version:
Cran/GraphQL Koa Server
38 lines (37 loc) • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetricTracer = void 0;
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
const instrumentation_graphql_1 = require("@opentelemetry/instrumentation-graphql");
const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
const instrumentation_koa_1 = require("@opentelemetry/instrumentation-koa");
const MetricSpanExporter_1 = require("./MetricSpanExporter");
const sdk_node_1 = require("@opentelemetry/sdk-node");
class MetricTracer {
sdk;
constructor(config = {}) {
const instrumentations = config.instrumentations ||
MetricTracer.defaultInstrumentations;
if (config.instrumentations && !config.overrideInstrumentations) {
instrumentations.push(...MetricTracer.defaultInstrumentations);
}
this.sdk = new sdk_node_1.NodeSDK({
spanProcessor: new sdk_trace_base_1.BatchSpanProcessor(new MetricSpanExporter_1.MetricSpanExporter(config)),
instrumentations,
});
}
async start() {
process.on("SIGTERM", () => {
void this.sdk.shutdown();
});
return this.sdk.start();
}
}
exports.MetricTracer = MetricTracer;
(function (MetricTracer) {
MetricTracer.defaultInstrumentations = [
new instrumentation_http_1.HttpInstrumentation(),
new instrumentation_koa_1.KoaInstrumentation(),
new instrumentation_graphql_1.GraphQLInstrumentation(),
];
})(MetricTracer = exports.MetricTracer || (exports.MetricTracer = {}));