Skip to content

Commit

Permalink
manual instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rjawesome committed Dec 23, 2023
1 parent a6369fe commit 635226e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/controllers/threading/taskHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const { getQueryQueue } = require("../async/asyncquery_queue");
const Sentry = require("@sentry/node");
const { ProfilingIntegration } = require("@sentry/profiling-node");
const opentelemetry = require('@opentelemetry/api');
const { Telemetry } = require('@biothings-explorer/utils');

// use SENTRY_DSN environment variable
try {
Expand Down Expand Up @@ -82,6 +83,7 @@ const runTask = async ({ req, route, port, job: { jobId, queueName } = {} }) =>

span = opentelemetry.trace.getTracer('biothings-explorer-thread').startSpan(routeNames[route])
span.setAttribute("request", req.data.queryGraph);
Telemetry.setOtelContext(opentelemetry.trace.setSpan(opentelemetry.context.active(), span));
} catch (error) {
debug("Sentry/OpenTelemetry transaction start error. This does not affect execution.");
debug(error);
Expand All @@ -93,6 +95,7 @@ const runTask = async ({ req, route, port, job: { jobId, queueName } = {} }) =>
try {
transaction.finish();
span.end();
Telemetry.removeOtelContext();
} catch (error) {
debug("Sentry/OpenTelemetry transaction finish error. This does not affect execution.");
debug(error);
Expand Down

0 comments on commit 635226e

Please sign in to comment.