From 0e577b6a96a62ada3e393d2d8cddd0b4f6e42c69 Mon Sep 17 00:00:00 2001 From: tokebe <43009413+tokebe@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:10:04 -0400 Subject: [PATCH] style: run prettier --- src/misc.ts | 7 +++++-- src/telemetry.ts | 26 +++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/misc.ts b/src/misc.ts index bd41f14..715d447 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -10,7 +10,7 @@ export function getUnique(input: Type[]): Type[] { } export function removeBioLinkPrefix(input: string): string { - if (input && input.startsWith('biolink:')) { + if (input && input.startsWith("biolink:")) { return input.slice(8); } return input; @@ -19,7 +19,10 @@ export function removeBioLinkPrefix(input: string): string { // This gets the intersection of two sets. // Lodash _.intersection gets the intersection of two arrays. // see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set -export function intersection(setA: Set, setB: Set): Set { +export function intersection( + setA: Set, + setB: Set, +): Set { const resultSet: Set = new Set(); for (const elem of setB) { if (setA.has(elem)) { diff --git a/src/telemetry.ts b/src/telemetry.ts index 1515411..84ed321 100644 --- a/src/telemetry.ts +++ b/src/telemetry.ts @@ -1,6 +1,10 @@ import * as Sentry from "@sentry/node"; import Debug from "debug"; -import opentelemetry, { Span as OtelSpan, Context as OtelContext, SpanStatusCode } from '@opentelemetry/api'; +import opentelemetry, { + Span as OtelSpan, + Context as OtelContext, + SpanStatusCode, +} from "@opentelemetry/api"; const debug = Debug("bte:telemetry-interface"); const reassurance = "This doesn't affect execution"; @@ -15,7 +19,16 @@ class Span { ?.getTransaction() ?.startChild(data); - this.otelSpan = opentelemetry.trace.getTracer('biothings-explorer-thread').startSpan((data as any).description ?? "", undefined, opentelemetry.trace.setSpan(opentelemetry.context.active(), Telemetry.getOtelSpan())); + this.otelSpan = opentelemetry.trace + .getTracer("biothings-explorer-thread") + .startSpan( + (data as any).description ?? "", + undefined, + opentelemetry.trace.setSpan( + opentelemetry.context.active(), + Telemetry.getOtelSpan(), + ), + ); } catch (error) { debug(`Sentry span start error. ${reassurance}`); debug(error); @@ -25,7 +38,10 @@ class Span { setData(key: string, data: unknown) { try { this.span?.setData(key, data); - this.otelSpan?.setAttribute(`bte.${key}`, typeof data === 'object' ? JSON.stringify(data) : data as any); + this.otelSpan?.setAttribute( + `bte.${key}`, + typeof data === "object" ? JSON.stringify(data) : (data as any), + ); } catch (error) { debug(`Sentry setData error. ${reassurance}`); debug(error); @@ -51,8 +67,8 @@ export class Telemetry { Sentry.captureException(error); if (this.getOtelSpan()) { - this.getOtelSpan().recordException(error); - this.getOtelSpan().setStatus({ code: SpanStatusCode.ERROR }); + this.getOtelSpan().recordException(error); + this.getOtelSpan().setStatus({ code: SpanStatusCode.ERROR }); } } static addBreadcrumb(breadcrumb?: Sentry.Breadcrumb) {