Skip to content

Commit

Permalink
chore: add type hints to otel vars
Browse files Browse the repository at this point in the history
  • Loading branch information
NeuralFlux committed Oct 10, 2024
1 parent daac52b commit 08aefaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/controllers/threading/taskHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { tasks } from "../../routes/index";
import { getQueryQueue } from "../async/asyncquery_queue";
import * as Sentry from "@sentry/node";
import { ProfilingIntegration } from "@sentry/profiling-node";
import { Span, trace, context, propagation, Context } from "@opentelemetry/api";
import { Span, trace, context, propagation, Context, Tracer } from "@opentelemetry/api";
import { Telemetry } from "@biothings-explorer/utils";
import { InnerTaskData } from "@biothings-explorer/types";

Expand Down Expand Up @@ -92,7 +92,7 @@ async function runTask({

let activeContext: Context = propagation.extract(context.active(), { traceparent, tracestate });
debug(`OTel task context: ${traceparent} and ${tracestate}`);
let tracer = trace.getTracer("biothings-explorer-thread")
let tracer: Tracer = trace.getTracer("biothings-explorer-thread")
span = tracer.startSpan(
routeNames[route],
{kind: 1}, // specifies internal span
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/threading/threadHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MessageChannel, threadId } from "worker_threads";
import Debug from "debug";
import { context, propagation, trace } from "@opentelemetry/api";
import { context, propagation, trace, Context, Span } from "@opentelemetry/api";
const debug = Debug("bte:biothings-explorer-trapi:threading");
import path from "path";
import { redisClient } from "@biothings-explorer/utils";
Expand Down Expand Up @@ -222,8 +222,8 @@ export async function runTask(req: Request, res: Response, route: string, useBul
const { traceparent, tracestate } = otelData;

// add req dest to root span name as HTTP instrumentation doesn't do it automatically
const activeContext = context.active();
const rootSpan = trace.getSpan(activeContext);
const activeContext: Context = context.active();
const rootSpan: Span = trace.getSpan(activeContext);
if (rootSpan != undefined) rootSpan.updateName(`${req.method} ${req.originalUrl}`);

const taskInfo: TaskInfo = {
Expand Down

0 comments on commit 08aefaa

Please sign in to comment.