From 08aefaabf08440bf1b34dd7d7959cd258a0f2edc Mon Sep 17 00:00:00 2001 From: NeuralFlux <40491005+NeuralFlux@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:01:10 -0400 Subject: [PATCH] chore: add type hints to otel vars --- src/controllers/threading/taskHandler.ts | 4 ++-- src/controllers/threading/threadHandler.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controllers/threading/taskHandler.ts b/src/controllers/threading/taskHandler.ts index 4e9705a..1a42dbd 100644 --- a/src/controllers/threading/taskHandler.ts +++ b/src/controllers/threading/taskHandler.ts @@ -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"; @@ -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 diff --git a/src/controllers/threading/threadHandler.ts b/src/controllers/threading/threadHandler.ts index 5a8a771..c23e69c 100644 --- a/src/controllers/threading/threadHandler.ts +++ b/src/controllers/threading/threadHandler.ts @@ -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"; @@ -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 = {