Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add logging on ChooChooTrain #288

Merged
merged 19 commits into from
Jan 22, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: get data before first log
  • Loading branch information
IgnacioBecerra committed Jan 3, 2025
commit 9aacc2e94d8e6212ed7f1fc2f19992ffc557f70c
10 changes: 7 additions & 3 deletions src/main/core/choo-choo-train.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ export class ChooChooTrain extends Loggable {
const conductorWork = this.workQueue?.[0]
if (conductorWork) {
this.gitInfo = await this.getRepoData(conductorWork)
await this.getPackageData(conductorWork)
this.environment = new Environment({ cwd: conductorWork.cwd })

this.sendLogs(
`The ChooChooTrain ride for analyzed path ${this.analyzedPath} at commit ${this.analyzedCommit} has started`
Expand Down Expand Up @@ -299,7 +301,7 @@ export class ChooChooTrain extends Loggable {
this.analyzedPath = hashedData[CustomResourceAttributes.ANALYZED_PATH]

// getting the endpoint URL
this.getPackageData(work)
await this.getPackageData(work)
return hashedData
}

Expand All @@ -310,7 +312,7 @@ export class ChooChooTrain extends Loggable {
configValidator.validate(config)

this.projectId = config.projectId
if (this.logEndpoint === '') {
if (this.logEndpoint === undefined) {
this.logEndpoint = config.endpoint.split('/metrics')[0] + '/logs'
this.logger.debug('Log endpoint: ' + this.logEndpoint)
}
Expand Down Expand Up @@ -369,7 +371,7 @@ export class ChooChooTrain extends Loggable {
@Trace()
private async sendLogs(message: string, error?: Error | string) {
if (
this.logEndpoint === null ||
this.logEndpoint === undefined ||
this.gitInfo === undefined ||
this.projectId === undefined ||
this.environment === undefined
Expand All @@ -396,6 +398,8 @@ export class ChooChooTrain extends Loggable {
}
}

this.logger.debug('Current log payload: ', JSON.stringify(payload))

try {
const response = await fetch(this.logEndpoint ?? '', {
method: 'POST',
Expand Down
Loading