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 annotations attribute to job spans #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion dist/github.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118977,12 +118977,22 @@ async function traceWorkflowRunJobs({ provider, workflowRunJobs, }) {
core.info(`Job ${job.id} was skipped, not tracing.`);
}
else {
const annotationsResponse = await octokit.rest.checks.listAnnotations({
owner: github_1.context.repo.owner,
repo: github_1.context.repo.repo,
check_run_id: job.id,
});
core.debug(`JobAnnotations Count: ${annotationsResponse.data.length}`);
// We only care about failure annotations generated by github files,
// excluding excluding annotations from other tools like rspec failures
const annotations = annotationsResponse.data.filter((a) => a.annotation_level === "failure" && a.path === ".github");
await traceWorkflowRunJob({
parentSpan: rootSpan,
parentContext: api_1.ROOT_CONTEXT,
trace: api_1.trace,
tracer,
job,
jobAnnotations: annotations,
workflowArtifacts: workflowRunJobs.workflowRunArtifacts,
});
}
Expand All @@ -118994,7 +119004,7 @@ async function traceWorkflowRunJobs({ provider, workflowRunJobs, }) {
return rootSpan.spanContext();
}
exports.traceWorkflowRunJobs = traceWorkflowRunJobs;
async function traceWorkflowRunJob({ parentContext, trace, parentSpan, tracer, job, workflowArtifacts, }) {
async function traceWorkflowRunJob({ parentContext, trace, parentSpan, tracer, job, jobAnnotations, workflowArtifacts, }) {
core.debug(`Trace Job ${job.id}`);
if (!job.completed_at) {
console.warn(`Job ${job.id} is not completed yet`);
Expand All @@ -119004,6 +119014,9 @@ async function traceWorkflowRunJob({ parentContext, trace, parentSpan, tracer, j
const ctx = trace.setSpan(parentContext, parentSpan);
const startTime = new Date(job.started_at);
const completedTime = new Date(job.completed_at);
const annotationMessages = jobAnnotations
.map((a) => a.message)
.join(";");
const span = tracer.startSpan(job.name, {
attributes: {
"github.job.id": job.id,
Expand All @@ -119018,6 +119031,7 @@ async function traceWorkflowRunJob({ parentContext, trace, parentSpan, tracer, j
"github.job.started_at": job.started_at || undefined,
"github.job.completed_at": job.completed_at || undefined,
"github.conclusion": job.conclusion || undefined,
"github.job.annotations": annotationMessages,
error: job.conclusion === "failure",
},
startTime,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion dist/tracing/job.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading