mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Refactor code and remove unnecessary blank lines
This commit is contained in:
parent
ed2574c449
commit
8232c4a4dc
@ -1,4 +1,3 @@
|
||||
|
||||
import OpenTelemetrySDK from 'CommonServer/Utils/OpenTelemetry';
|
||||
import 'ejs';
|
||||
import Redis from 'CommonServer/Infrastructure/Redis';
|
||||
@ -16,7 +15,6 @@ import './FeatureSet/ApiReference/Index';
|
||||
import Workers from './FeatureSet/Workers/Index';
|
||||
import Workflow from './FeatureSet/Workflow/Index';
|
||||
|
||||
|
||||
// home should be in the end.
|
||||
import './FeatureSet/Home/Index';
|
||||
|
||||
@ -48,7 +46,6 @@ const init: () => Promise<void> = async (): Promise<void> => {
|
||||
await Workflow.init();
|
||||
|
||||
OpenTelemetrySDK?.start();
|
||||
|
||||
} catch (err) {
|
||||
logger.error('App Init Failed:');
|
||||
logger.error(err);
|
||||
|
@ -810,7 +810,8 @@ export default class AnalyticsDatabaseService<
|
||||
throw new BadDataException(`${requiredField} is required`);
|
||||
}
|
||||
} else if (
|
||||
((data as any)[requiredField] === null || (data as any)[requiredField] === undefined) &&
|
||||
((data as any)[requiredField] === null ||
|
||||
(data as any)[requiredField] === undefined) &&
|
||||
!data.isDefaultValueColumn(requiredField)
|
||||
) {
|
||||
throw new BadDataException(`${requiredField} is required`);
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { createLogger, Logger, transports } from 'winston';
|
||||
|
||||
|
||||
const logger: Logger = createLogger({
|
||||
transports: [new transports.Console()],
|
||||
});
|
||||
|
@ -3,22 +3,17 @@ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
|
||||
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';
|
||||
import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
|
||||
import Dictionary from 'Common/Types/Dictionary';
|
||||
import {
|
||||
BatchLogRecordProcessor,
|
||||
} from '@opentelemetry/sdk-logs';
|
||||
import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';
|
||||
import { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-http';
|
||||
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray';
|
||||
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
||||
|
||||
|
||||
let sdk: opentelemetry.NodeSDK | null = null;
|
||||
|
||||
if (
|
||||
process.env['OTEL_EXPORTER_OTLP_ENDPOINT'] &&
|
||||
process.env['OTEL_EXPORTER_OTLP_HEADERS']
|
||||
) {
|
||||
|
||||
|
||||
const headersStrings: Array<string> =
|
||||
process.env['OTEL_EXPORTER_OTLP_HEADERS'].split(';');
|
||||
|
||||
@ -38,12 +33,11 @@ if (
|
||||
headers: headers,
|
||||
});
|
||||
|
||||
|
||||
sdk = new opentelemetry.NodeSDK({
|
||||
idGenerator: new AWSXRayIdGenerator(),
|
||||
traceExporter: new OTLPTraceExporter({
|
||||
url: otlpEndpoint + '/v1/traces',
|
||||
headers: headers
|
||||
headers: headers,
|
||||
}),
|
||||
metricReader: new PeriodicExportingMetricReader({
|
||||
exporter: new OTLPMetricExporter({
|
||||
@ -52,9 +46,7 @@ if (
|
||||
}),
|
||||
}) as any,
|
||||
logRecordProcessor: new BatchLogRecordProcessor(logExporter) as any,
|
||||
instrumentations: [
|
||||
getNodeAutoInstrumentations(),
|
||||
],
|
||||
instrumentations: [getNodeAutoInstrumentations()],
|
||||
});
|
||||
|
||||
process.on('SIGTERM', () => {
|
||||
@ -65,4 +57,3 @@ if (
|
||||
}
|
||||
|
||||
export default sdk;
|
||||
|
||||
|
@ -31,7 +31,6 @@ import ServerException from 'Common/Types/Exception/ServerException';
|
||||
import zlib from 'zlib';
|
||||
import CookieParser from 'cookie-parser';
|
||||
|
||||
|
||||
// Make sure we have stack trace for debugging.
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
|
@ -49,7 +49,8 @@ const Bar: FunctionComponent<ComponentProps> = (
|
||||
}
|
||||
|
||||
const eachCharacterWidth: number = 8;
|
||||
const showLabelOutsideBar: boolean = barWidth < props.bar.title.length * eachCharacterWidth;
|
||||
const showLabelOutsideBar: boolean =
|
||||
barWidth < props.bar.title.length * eachCharacterWidth;
|
||||
|
||||
const handleMouseEnter: MouseEventHandler = (): void => {
|
||||
setIsHovered(true);
|
||||
@ -61,9 +62,12 @@ const Bar: FunctionComponent<ComponentProps> = (
|
||||
|
||||
return (
|
||||
// rectangle div with curved corners and text inside in tailwindcss
|
||||
<div className='flex absolute' style={{
|
||||
marginLeft: `${barLeftPosition}px`
|
||||
}}>
|
||||
<div
|
||||
className="flex absolute"
|
||||
style={{
|
||||
marginLeft: `${barLeftPosition}px`,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="chart-bar h-8 pt-1 pb-1 mt-2.5 mb-2.5 rounded absolute cursor-pointer ml-1 mr-1"
|
||||
style={{
|
||||
@ -74,22 +78,31 @@ const Bar: FunctionComponent<ComponentProps> = (
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
>
|
||||
{!showLabelOutsideBar && <BarLabel
|
||||
{!showLabelOutsideBar && (
|
||||
<BarLabel
|
||||
title={props.bar.title}
|
||||
titleColor={props.bar.titleColor}
|
||||
/>}
|
||||
/>
|
||||
)}
|
||||
{isHovered && props.bar.tooltip && (
|
||||
<div className="bar-tooltip bg-white shadow rounded p-2 w-fit z-40 absolute">
|
||||
{props.bar.tooltip}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{showLabelOutsideBar && <div className='h-8 pt-1 pb-1 mt-2.5 mb-2.5' style={{
|
||||
marginLeft: `${barLeftPosition + barWidth + 10}px`
|
||||
}}><BarLabel
|
||||
{showLabelOutsideBar && (
|
||||
<div
|
||||
className="h-8 pt-1 pb-1 mt-2.5 mb-2.5"
|
||||
style={{
|
||||
marginLeft: `${barLeftPosition + barWidth + 10}px`,
|
||||
}}
|
||||
>
|
||||
<BarLabel
|
||||
title={props.bar.title}
|
||||
titleColor={props.bar.barColor}
|
||||
/></div>}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
@ -6,8 +6,6 @@ export interface ComponentProps {
|
||||
log: Log;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const LogItem: FunctionComponent<ComponentProps> = (
|
||||
props: ComponentProps
|
||||
): ReactElement => {
|
||||
@ -19,7 +17,11 @@ const LogItem: FunctionComponent<ComponentProps> = (
|
||||
|
||||
let bodyColor: string = 'text-slate-200';
|
||||
|
||||
if (props.log.severityText === LogSeverity.Warning || props.log.severityText === LogSeverity.Trace || props.log.severityText === LogSeverity.Debug) {
|
||||
if (
|
||||
props.log.severityText === LogSeverity.Warning ||
|
||||
props.log.severityText === LogSeverity.Trace ||
|
||||
props.log.severityText === LogSeverity.Debug
|
||||
) {
|
||||
bodyColor = 'text-amber-400';
|
||||
} else if (props.log.severityText === LogSeverity.Error) {
|
||||
bodyColor = 'text-rose-400';
|
||||
@ -77,7 +79,6 @@ const LogItem: FunctionComponent<ComponentProps> = (
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
<div className={`${bodyColor} courier-prime`}>
|
||||
{props.log.body?.toString()}
|
||||
</div>
|
||||
|
@ -481,21 +481,31 @@ router.post(
|
||||
log['timeUnixNano'] as number
|
||||
);
|
||||
|
||||
let logSeverityNumber: number = log['severityNumber'] as number || 0; // 0 is Unspecified by default.
|
||||
let logSeverityNumber: number =
|
||||
(log['severityNumber'] as number) || 0; // 0 is Unspecified by default.
|
||||
|
||||
if (typeof logSeverityNumber === 'string') {
|
||||
|
||||
if (logSeverityNumber === 'SEVERITY_NUMBER_TRACE') {
|
||||
logSeverityNumber = 1;
|
||||
} else if(logSeverityNumber === 'SEVERITY_NUMBER_DEBUG') {
|
||||
} else if (
|
||||
logSeverityNumber === 'SEVERITY_NUMBER_DEBUG'
|
||||
) {
|
||||
logSeverityNumber = 5;
|
||||
} else if(logSeverityNumber === 'SEVERITY_NUMBER_INFO') {
|
||||
} else if (
|
||||
logSeverityNumber === 'SEVERITY_NUMBER_INFO'
|
||||
) {
|
||||
logSeverityNumber = 9;
|
||||
} else if(logSeverityNumber === 'SEVERITY_NUMBER_WARN') {
|
||||
} else if (
|
||||
logSeverityNumber === 'SEVERITY_NUMBER_WARN'
|
||||
) {
|
||||
logSeverityNumber = 13;
|
||||
} else if(logSeverityNumber === 'SEVERITY_NUMBER_ERROR') {
|
||||
} else if (
|
||||
logSeverityNumber === 'SEVERITY_NUMBER_ERROR'
|
||||
) {
|
||||
logSeverityNumber = 17;
|
||||
} else if(logSeverityNumber === 'SEVERITY_NUMBER_FATAL') {
|
||||
} else if (
|
||||
logSeverityNumber === 'SEVERITY_NUMBER_FATAL'
|
||||
) {
|
||||
logSeverityNumber = 21;
|
||||
} else {
|
||||
logSeverityNumber = parseInt(logSeverityNumber);
|
||||
@ -506,26 +516,42 @@ router.post(
|
||||
|
||||
let logSeverity: LogSeverity = LogSeverity.Unspecified;
|
||||
|
||||
|
||||
// these numbers are from the opentelemetry/api-logs package
|
||||
if (logSeverityNumber < 0 || logSeverityNumber > 24) {
|
||||
logSeverity = LogSeverity.Unspecified;
|
||||
logSeverityNumber = 0;
|
||||
}else if (logSeverityNumber >= 1 && logSeverityNumber <= 4) {
|
||||
} else if (
|
||||
logSeverityNumber >= 1 &&
|
||||
logSeverityNumber <= 4
|
||||
) {
|
||||
logSeverity = LogSeverity.Trace;
|
||||
}else if (logSeverityNumber >= 5 && logSeverityNumber <= 8) {
|
||||
} else if (
|
||||
logSeverityNumber >= 5 &&
|
||||
logSeverityNumber <= 8
|
||||
) {
|
||||
logSeverity = LogSeverity.Debug;
|
||||
} else if (logSeverityNumber >= 9 && logSeverityNumber <= 12) {
|
||||
} else if (
|
||||
logSeverityNumber >= 9 &&
|
||||
logSeverityNumber <= 12
|
||||
) {
|
||||
logSeverity = LogSeverity.Information;
|
||||
} else if (logSeverityNumber >= 13 && logSeverityNumber <= 16) {
|
||||
} else if (
|
||||
logSeverityNumber >= 13 &&
|
||||
logSeverityNumber <= 16
|
||||
) {
|
||||
logSeverity = LogSeverity.Warning;
|
||||
} else if (logSeverityNumber >= 17 && logSeverityNumber <= 20) {
|
||||
} else if (
|
||||
logSeverityNumber >= 17 &&
|
||||
logSeverityNumber <= 20
|
||||
) {
|
||||
logSeverity = LogSeverity.Error;
|
||||
} else if (logSeverityNumber >= 21 && logSeverityNumber <= 24) {
|
||||
} else if (
|
||||
logSeverityNumber >= 21 &&
|
||||
logSeverityNumber <= 24
|
||||
) {
|
||||
logSeverity = LogSeverity.Fatal;
|
||||
}
|
||||
|
||||
|
||||
dbLog.severityText = logSeverity;
|
||||
|
||||
const logBody: JSONObject = log['body'] as JSONObject;
|
||||
|
Loading…
Reference in New Issue
Block a user