Skip to content

Commit

Permalink
style: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Sep 4, 2024
1 parent 84708cf commit 0e577b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function getUnique<Type>(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;
Expand All @@ -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<Type>(setA: Set<Type>, setB: Set<Type>): Set<Type> {
export function intersection<Type>(
setA: Set<Type>,
setB: Set<Type>,
): Set<Type> {
const resultSet: Set<Type> = new Set();
for (const elem of setB) {
if (setA.has(elem)) {
Expand Down
26 changes: 21 additions & 5 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 0e577b6

Please sign in to comment.