mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-01-16 23:00:51 +00:00
feat: update Telemetry import paths and add CaptureSpan decorator for enhanced telemetry tracking
This commit is contained in:
parent
e45477fce8
commit
521e9ca1ed
7 changed files with 50 additions and 4 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import App from "./App";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry/Telemetry";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import App from "./App";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry/Telemetry";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { ClickhouseAppInstance } from "./ClickhouseDatabase";
|
|||
import PostgresAppInstance from "./PostgresDatabase";
|
||||
import Redis from "./Redis";
|
||||
import DatabaseNotConnectedException from "Common/Types/Exception/DatabaseNotConnectedException";
|
||||
import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
|
||||
|
||||
export default class InfrastructureStatus {
|
||||
public static async checkStatus(data: {
|
||||
|
|
@ -42,6 +43,7 @@ export default class InfrastructureStatus {
|
|||
}
|
||||
}
|
||||
|
||||
@CaptureSpan("Check Infrastructure Status With Retry")
|
||||
public static async checkStatusWithRetry(data: {
|
||||
retryCount: number;
|
||||
checkRedisStatus: boolean;
|
||||
|
|
|
|||
43
Common/Server/Utils/Telemetry/CaptureSpan.ts
Normal file
43
Common/Server/Utils/Telemetry/CaptureSpan.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import Telemetry from "../Telemetry";
|
||||
import { Span } from "@opentelemetry/api";
|
||||
|
||||
function CaptureSpan(name: string) {
|
||||
return function (
|
||||
_target: any,
|
||||
propertyKey: string,
|
||||
descriptor: PropertyDescriptor
|
||||
) {
|
||||
const originalMethod = descriptor.value;
|
||||
|
||||
descriptor.value = async function (...args: any[]) {
|
||||
const attributes = args.reduce((acc: { [key: string]: any }, arg: any, index: number) => {
|
||||
acc[`arg${index}`] = arg;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return await Telemetry.startActiveSpan<Promise<void>>({
|
||||
name: name || propertyKey,
|
||||
options: {
|
||||
attributes: attributes,
|
||||
},
|
||||
fn: async (span: Span): Promise<void> => {
|
||||
try {
|
||||
await originalMethod.apply(this, args);
|
||||
} catch (err) {
|
||||
Telemetry.recordExceptionMarkSpanAsErrorAndEndSpan({
|
||||
span,
|
||||
exception: err,
|
||||
});
|
||||
throw err;
|
||||
} finally {
|
||||
span.end();
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return descriptor;
|
||||
};
|
||||
}
|
||||
|
||||
export default CaptureSpan;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import App from "./App";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry/Telemetry";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ app.use([`/${APP_NAME}`, "/"], OTelIngestAPI);
|
|||
|
||||
const init: PromiseVoidFunction = async (): Promise<void> => {
|
||||
try {
|
||||
|
||||
const statusCheck: PromiseVoidFunction = async (): Promise<void> => {
|
||||
return await InfrastructureStatus.checkStatusWithRetry({
|
||||
checkClickhouseStatus: true,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import App from "./App";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry";
|
||||
import Telemetry from "Common/UI/Utils/Telemetry/Telemetry";
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue