diff --git a/src/config/apis.js b/src/config/apis.js index 43de8a8..a6a6519 100644 --- a/src/config/apis.js +++ b/src/config/apis.js @@ -7,9 +7,7 @@ exports.API_LIST = { // also accessible by v1/team/Service Provider/ endpoints and by api-specific endpoints { id: "d22b657426375a5295e7da8a303b9893", - name: "BioLink API", - // also known as Monarch: https://monarchinitiative.org/ - // NOT the same as the Biolink-model + name: "Monarch API", }, { id: "0212611d1c670f9107baf00b77f0889a", @@ -72,6 +70,14 @@ exports.API_LIST = { id: "1f47552dabd67351d4c625adb0a10d00", name: "BioThings EBIgene2phenotype API", }, + { + id: "f1b8f64c316a01d1722f0fb842499fe5", + name: "BioThings FooDB API", + }, + { + id: "895ec14a3650ec7ad85959a2d1554e2f", + name: "BioThings FoodData Central API", + }, { id: "cc857d5b7c8b7609b5bbb38ff990bfff", name: "BioThings GO Biological Process API", @@ -112,6 +118,10 @@ exports.API_LIST = { id: "b772ebfbfa536bba37764d7fddb11d6f", name: "BioThings RARe-SOURCE API", }, + { + id: "1138c3297e8e403b6ac10cff5609b319", + name: "BioThings repoDB API", + }, { id: "03283cc2b21c077be6794e1704b1d230", name: "BioThings Rhea API", diff --git a/src/config/smartapi_overrides.json b/src/config/smartapi_overrides.json index 3ecf519..36ee72e 100644 --- a/src/config/smartapi_overrides.json +++ b/src/config/smartapi_overrides.json @@ -2,12 +2,5 @@ "conf": { "only_overrides": false }, - "apis": { - "671b45c0301c8624abbd26ae78449ca2": "https://raw.githubusercontent.com/NCATS-Tangerine/translator-api-registry/orphanet-change/mydisease.info/smartapi.yaml", - "b772ebfbfa536bba37764d7fddb11d6f": "https://raw.githubusercontent.com/NCATS-Tangerine/translator-api-registry/orphanet-change/ncats_rare_source/smartapi.yaml", - "326eb1e437303bee27d3cef29227125d": "https://raw.githubusercontent.com/NCATS-Tangerine/translator-api-registry/orphanet-change/complexportal/smartapi.yaml", - "0212611d1c670f9107baf00b77f0889a": "https://raw.githubusercontent.com/NCATS-Tangerine/translator-api-registry/ctd-batch-query/CTD/smartapi.yaml", - "8f08d1446e0bb9c2b323713ce83e2bd3": "https://raw.githubusercontent.com/NCATS-Tangerine/translator-api-registry/mychem-fda-orphan-edit/mychem.info/openapi_full.yml", - "d22b657426375a5295e7da8a303b9893": "https://raw.githubusercontent.com/NCATS-Tangerine/translator-api-registry/v3-biolink-monarch/biolink/openapi.yml" - } + "apis": {} } diff --git a/src/controllers/cron/update_local_smartapi.js b/src/controllers/cron/update_local_smartapi.js index f09443b..3b3243d 100644 --- a/src/controllers/cron/update_local_smartapi.js +++ b/src/controllers/cron/update_local_smartapi.js @@ -63,6 +63,22 @@ const getServerFromSpec = spec => { return sorted_servers[0].url; }; +const sortObject = object => { + if (Array.isArray(object)) { + return object.sort(); + } + + // apparently typeof null is object + if (typeof object === 'object' && object !== null) { + return Object.keys(object).sort().reduce((acc, key) => { + acc[key] = sortObject(object[key]); + return acc; + }, {}); + } + + return object; +} + const getTRAPIWithPredicatesEndpoint = specs => { const trapi = []; let excluded_list = config.EXCLUDE_LIST.map(api => api.id); @@ -194,12 +210,13 @@ const getOpsFromEndpoint = async metadata => { const getOpsFromPredicatesEndpoints = async specs => { const metadatas = getTRAPIWithPredicatesEndpoint(specs); + metadatas.sort((a, b) => a.association.smartapi.id.localeCompare(b.association.smartapi.id)); let res = []; debug(`Now caching predicates from ${metadatas.length} TRAPI APIs`); await Promise.allSettled(metadatas.map(metadata => getOpsFromEndpoint(metadata))).then(results => { results.map(rec => { if (rec.status === "fulfilled" && rec.value) { - res.push(rec.value); + res.push(sortObject(rec.value)); } }); }); diff --git a/src/controllers/threading/taskHandler.js b/src/controllers/threading/taskHandler.js index f056ad5..bc488de 100644 --- a/src/controllers/threading/taskHandler.js +++ b/src/controllers/threading/taskHandler.js @@ -44,7 +44,7 @@ try { debug(error); } -const runTask = async ({ req, route, port, job: { jobId, queueName } = {} }) => { +const runTask = async ({ req, route, traceparent, tracestate, port, job: { jobId, queueName } = {} }) => { debug(`Worker thread ${threadId} beginning ${workerData.queue} task.`); global.SCHEMA_VERSION = "1.4.0"; @@ -81,7 +81,7 @@ const runTask = async ({ req, route, port, job: { jobId, queueName } = {} }) => scope.setSpan(transaction); }); - span = opentelemetry.trace.getTracer('biothings-explorer-thread').startSpan(routeNames[route]) + span = opentelemetry.trace.getTracer('biothings-explorer-thread').startSpan(routeNames[route], undefined, opentelemetry.propagation.extract(opentelemetry.context.active(), {traceparent, tracestate})) span.setAttribute("bte.requestData", JSON.stringify(req.data.queryGraph)); Telemetry.setOtelSpan(span); } catch (error) { diff --git a/src/controllers/threading/threadHandler.js b/src/controllers/threading/threadHandler.js index 12267b4..ac0bf3c 100644 --- a/src/controllers/threading/threadHandler.js +++ b/src/controllers/threading/threadHandler.js @@ -1,4 +1,5 @@ const { MessageChannel, threadId } = require("worker_threads"); +const { context, propagation, trace } = require("@opentelemetry/api"); const debug = require("debug")("bte:biothings-explorer-trapi:threading"); const path = require("path"); // const taskHandler = require("./taskHandler"); @@ -98,8 +99,15 @@ const queueTaskToWorkers = async (pool, req, route, job) => { let WorkerThreadID; const abortController = new AbortController(); const { port1: toWorker, port2: fromWorker } = new MessageChannel(); - const taskData = { req, route, port: toWorker }; - taskData.req.data.options = {...taskData.req.optoins, metakg: global.metakg?.ops}; + + // get otel context + const otelData = {}; + propagation.inject(context.active(), otelData); + const { traceparent, tracestate } = otelData; + + const taskData = { req, route, traceparent, tracestate, port: toWorker }; + taskData.req.data.options = {...taskData.req.data.options, metakg: global.metakg?.ops}; + if (job) taskData.job = { jobId: job.id, queueName: job.queue.name }; const task = pool.run(taskData, { signal: abortController.signal, transferList: [toWorker] }); if (job) {