Skip to content

Commit

Permalink
Merge pull request #29 from checkly/jan/prepare-demo
Browse files Browse the repository at this point in the history
Jan/prepare demo
  • Loading branch information
jan-osch authored Jan 15, 2025
2 parents 7be91d2 + b493cf2 commit ea9cd95
Show file tree
Hide file tree
Showing 13 changed files with 239 additions and 177 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- "5432:5432"
- "5438:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

Expand Down
14 changes: 14 additions & 0 deletions prisma/migrations/20250115142547_add_raw_release/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- CreateTable
CREATE TABLE "RawRelease" (
"id" TEXT NOT NULL,
"body" JSONB NOT NULL,
"releaseId" TEXT NOT NULL,

CONSTRAINT "RawRelease_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "RawRelease_releaseId_key" ON "RawRelease"("releaseId");

-- AddForeignKey
ALTER TABLE "RawRelease" ADD CONSTRAINT "RawRelease_releaseId_fkey" FOREIGN KEY ("releaseId") REFERENCES "Release"("id") ON DELETE CASCADE ON UPDATE CASCADE;
2 changes: 1 addition & 1 deletion prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
# It should be added in your version-control system (e.g., Git)
provider = "postgresql"
11 changes: 10 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ model Alert {
}

model Release {
id String @id @default(cuid())
id String @id @default(cuid())
name String
org String
repo String
Expand All @@ -35,6 +35,7 @@ model Release {
publishedAt DateTime
authors String[]
summary String
rawRelease RawRelease?
}

enum Source {
Expand All @@ -54,3 +55,11 @@ model AlertContext {
alert Alert @relation(fields: [alertId], references: [id], onDelete: Cascade)
}

model RawRelease {
id String @id @default(cuid())
body Json
releaseId String @unique
release Release @relation(fields: [releaseId], references: [id], onDelete: Cascade)
}
12 changes: 9 additions & 3 deletions src/aggregator/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const generateContextAnalysisSummary = async (
const summary = await generateText({
model: getOpenaiSDKClient()("gpt-4o"),
temperature: 1,
prompt: `The following check has failed: ${checkContext}
prompt: `The following check has changed its state: ${checkContext}
Anaylze the following context and generate a concise summary of the current situation.
Expand All @@ -64,6 +64,8 @@ CONSTITUTION:
- Focus on providing actionable information that can help reduce MTTR
- The user is a experienced devops engineer. Don't overcomplicate it, focus on the context and provide actionable insights. They know what they are doing, don't worry about the details.
- Don't include the check configuration or run details, focus on logs, changes and the current state of the system.
-
OUTPUT FORMAT INSTRUCTIONS:
${slackFormatInstructions}
Expand All @@ -76,8 +78,12 @@ ${stringify(
{ indent: 2 }
).slice(0, 200000)}
Check-results amd checkly configuration details are already provided in the UI. Focus on the root cause analyisis and potential mitigations. Help the user to resolve the issue.
Generate a condensed summary of your root cause analysis of the current situation. Focus on the essentials, provide a concise overview and actionable insights. Provide reasoning and the source of the information. Max. 150 words. Include links to relevant context if applicable.
Check-results amd checkly configuration details are already provided in the UI. Focus on the root cause analysis and potential mitigations. Help the user to resolve the issue.
Generate a condensed summary of your root cause analysis of the current situation.
Focus on the essentials, provide a concise overview and actionable insights.
Provide reasoning and the source of the information. Max. 100 words. Include links to relevant context if applicable.
Be concise, insightful and actionable, skip the fluff, no yapping.
If a recent release is the most likely root cause, provide a link to the release diff.
*Summary:* `,
maxTokens: 500,
Expand Down
8 changes: 4 additions & 4 deletions src/aggregator/checkly-aggregator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ describe("ChecklyService", () => {
GROUP_NAME: "",
ALERT_TITLE: "GET /books has failed",
ALERT_TYPE: "ALERT_FAILURE",
CHECK_RESULT_ID: "b5036112-5843-42bc-9991-9f368a43e46b",
CHECK_RESULT_ID: "fff2fdb6-1cee-4cd8-97a7-5a6a2c87df3d",
RESPONSE_TIME: 36,
API_CHECK_RESPONSE_STATUS_CODE: 500,
API_CHECK_RESPONSE_STATUS_TEXT: "Internal Server Error",
RUN_LOCATION: "Ireland",
RESULT_LINK:
"https://app.checklyhq.com/checks/c289cb3b-8d20-4c93-9c95-38956abca933/results/api/b5036112-5843-42bc-9991-9f368a43e46b",
"https://app.checklyhq.com/checks/c289cb3b-8d20-4c93-9c95-38956abca933/results/api/fff2fdb6-1cee-4cd8-97a7-5a6a2c87df3d",
SSL_DAYS_REMAINING: "",
SSL_CHECK_DOMAIN: "",
STARTED_AT: "2024-11-29T15:34:21.900Z",
STARTED_AT: "2025-01-15T15:34:21.900Z",
TAGS: "website,api,srebot",
$RANDOM_NUMBER: 1547,
$UUID: "380b94c2-2c56-4f1d-904a-a6122d96722a",
moment: "November 29, 2024",
moment: "January 15, 2025",
},
{ enableImplicitConversion: true }
)
Expand Down
2 changes: 1 addition & 1 deletion src/aggregator/github-aggregator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const githubAggregator = {

const { object: relevantReleaseIds } = await generateObject({
model: getOpenaiSDKClient()("gpt-4o"),
prompt: `Based on the following releases, which ones are most relevant to the check failure? Analyze the check script, result and releases to determine which releases are most relevant. Provide a list of release ids that are most relevant to the check.
prompt: `Based on the following releases, which ones are most relevant to the check state change? Analyze the check script, result and releases to determine which releases are most relevant. Provide a list of release ids that are most relevant to the check.
Releases:
${stringify(
Expand Down
1 change: 0 additions & 1 deletion src/checkly/alertDTO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export class WebhookAlertDto {
if (!value) {
return [];
}
console.log('jsonarray:' + value);
// If the value is a valid stringified JSON array, parse it
const parsed = typeof value === 'string' ? JSON.parse(value) : value;

Expand Down
2 changes: 1 addition & 1 deletion src/github/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class GithubAgent {
model: this.model,
prompt: `The following diff describes the changes between ${previousRelease} and ${release}. Summarize the changes so that another developer quickly understands what has changes: ${JSON.stringify(
diff
)}. Do not describe the outer context as the developer is already aware. Do not yap. Format titles using *Title*, code using \`code\`. Do not use any other formatting rules.`,
)}. Do not describe the outer context as the developer is already aware. Do not yap. Format titles using *Title*, code using \`code\`. Do not use any other formatting rules. Focus on potential impact of the change and the reason for the change.`,
});

return { diff, summary: text };
Expand Down
1 change: 0 additions & 1 deletion src/github/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class GitHubAPI {
async checkRateLimit() {
try {
const response = await this.octokit.rest.rateLimit.get();
console.log(response.data);

if (response.data.resources.core.remaining === 0) {
throw new Error("Rate limit exceeded");
Expand Down
Loading

0 comments on commit ea9cd95

Please sign in to comment.