Skip to content

Commit 5f3a637

Browse files
fix/removed runtime scrapper
1 parent 2b79c61 commit 5f3a637

6 files changed

Lines changed: 25 additions & 146 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
"devDependencies": {
2020
"@types/jest": "^29.2.0",
21-
"@types/node": "10.17.0",
21+
"@types/node": "20.3.1",
2222
"@types/react": "^16.9.49",
2323
"@types/react-dom": "^16.9.8",
2424
"@types/rimraf": "^3.0.2",

packages/node-core/src/types/http.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export enum RequestStatus {
2525
export enum CAPTURE_ENDPOINT {
2626
LOG = "/api/capture/log",
2727
INCIDENT = "/api/capture/incident",
28-
RUNTIME = "/api/capture/runtime",
2928
METRICS = "/api/capture/metrics",
3029
TRACING = "/api/capture/traces"
3130
}

packages/node/src/client.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { INodeClient, CoreClient, TraceoOptions, Dictionary } from "@traceo-sdk/node-core";
22
import { Logger } from "./logger";
33
import { MetricsRunner } from "./metrics";
4-
import { Scrapper } from "./scrapper";
54

65
export class Client extends CoreClient implements INodeClient {
76
public headers: Dictionary<any>;
@@ -20,11 +19,6 @@ export class Client extends CoreClient implements INodeClient {
2019
}
2120

2221
public initSDK(): void {
23-
const scrapper = new Scrapper();
24-
scrapper.collect();
25-
26-
console.log("options: ", this.options);
27-
2822
if (this.options.collectMetrics) {
2923
const metrics = new MetricsRunner();
3024
metrics.register();

packages/node/src/logger.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class Logger {
1111
this.logsQueue = [];
1212

1313
const client = getGlobalTraceo();
14-
14+
1515
const scrapLogsInterval = client.options.exportIntervalMillis;
1616
if (scrapLogsInterval && scrapLogsInterval >= DEFAULT_EXPORT_INTERVAL) {
1717
this.INTERVAL = scrapLogsInterval;
@@ -21,7 +21,7 @@ export class Logger {
2121
}
2222

2323
private register() {
24-
setInterval(() => this.sendLogs(), this.INTERVAL * 1000);
24+
setInterval(() => this.sendLogs(), this.INTERVAL);
2525
}
2626

2727
public log(...args: any[]): void {
@@ -58,13 +58,23 @@ export class Logger {
5858
level,
5959
message,
6060
timestamp,
61-
unix: Math.floor(Date.now() / 1000),
61+
unix: this.getUnix,
6262
resources: this.resources
6363
};
6464

6565
this.logsQueue.push(requestPayload);
6666
}
6767

68+
private get getUnix(): number {
69+
const currentDate = new Date();
70+
71+
const unixTimestamp = Math.floor(currentDate.getTime() / 1000);
72+
const milliseconds = currentDate.getMilliseconds();
73+
const unixWithMilliseconds = unixTimestamp * 1000 + milliseconds;
74+
75+
return unixWithMilliseconds;
76+
}
77+
6878
private async sendLogs() {
6979
if (this.logsQueue.length > 0) {
7080
transport.request({
@@ -84,18 +94,16 @@ export class Logger {
8494
}
8595

8696
private get timestamp(): string {
87-
const localeStringOptions = {
88-
year: "numeric",
89-
hour: "numeric",
90-
minute: "numeric",
91-
second: "numeric",
92-
day: "2-digit",
93-
month: "2-digit"
94-
};
95-
return new Date(Date.now()).toLocaleString(
96-
undefined,
97-
localeStringOptions as Intl.DateTimeFormatOptions
98-
);
97+
const date = new Date();
98+
const year = date.getFullYear().toString().padStart(4, '0');
99+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
100+
const day = date.getDate().toString().padStart(2, '0');
101+
const hours = date.getHours().toString().padStart(2, '0');
102+
const minutes = date.getMinutes().toString().padStart(2, '0');
103+
const seconds = date.getSeconds().toString().padStart(2, '0');
104+
const milliseconds = date.getMilliseconds().toString().padStart(3, '0');
105+
106+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}:${milliseconds}`;
99107
}
100108

101109
private get resources(): { [key: string]: any } {

packages/node/src/scrapper.ts

Lines changed: 0 additions & 123 deletions
This file was deleted.

packages/opentelemetry-node/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
},
2626
"dependencies": {
2727
"@opentelemetry/api": "^1.4.1",
28+
"@opentelemetry/api-logs": "^0.39.1",
2829
"@opentelemetry/exporter-metrics-otlp-http": "^0.38.0",
2930
"@opentelemetry/exporter-trace-otlp-http": "^0.39.1",
3031
"@traceo-sdk/node-core": "0.32.2",

0 commit comments

Comments
 (0)