qfix: Rework span creation (#9613)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-07-29 23:32:16 +07:00
committed by GitHub
parent 5d991da341
commit 88351f639f
38 changed files with 386 additions and 298 deletions
@@ -271,7 +271,7 @@ export abstract class IssueSyncManagerBase {
): Promise<DocumentUpdate<DocSyncInfo>> {
let needUpdate = false
if (!this.client.getHierarchy().hasMixin(existing, github.mixin.GithubIssue)) {
await this.ctx.withLog(
await this.ctx.with(
'create mixin issue: GithubIssue',
{},
async () => {
@@ -288,7 +288,8 @@ export abstract class IssueSyncManagerBase {
)
await this.notifyConnected(container, info, existing, issueExternal)
},
{ identifier: existing.identifier, url: issueExternal.url }
{ identifier: existing.identifier, url: issueExternal.url },
{ log: true }
)
// Re iterate to have existing value with mixin inside.
needUpdate = true
+28 -16
View File
@@ -339,24 +339,31 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
return { needSync: githubSyncVersion }
}
const description = await this.ctx.withLog('query collaborative description', {}, async () => {
const collabId = makeDocCollabId(existing, 'description')
return await this.collaborator.getMarkup(collabId, (existing as Issue).description)
})
const description = await this.ctx.with(
'query collaborative description',
{},
async () => {
const collabId = makeDocCollabId(existing, 'description')
return await this.collaborator.getMarkup(collabId, (existing as Issue).description)
},
{},
{ log: true }
)
this.ctx.info('create github issue', {
title: (existing as Issue).title,
number: (existing as Issue).number,
workspace: this.provider.getWorkspaceId()
})
const createdIssueData = await this.ctx.withLog(
const createdIssueData = await this.ctx.with(
'create github issue',
{},
async () => {
this.createPromise = this.createGithubIssue(container, { ...(existing as Issue), description }, repository)
return await this.createPromise
},
{ id: (existing as Issue).identifier, workspace: this.provider.getWorkspaceId() }
{ id: (existing as Issue).identifier, workspace: this.provider.getWorkspaceId() },
{ log: true }
)
if (createdIssueData === undefined) {
this.ctx.error('Error create issue', { url: info.url })
@@ -476,7 +483,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
// No repository, it probable deleted
return { needSync: githubSyncVersion }
}
await this.ctx.withLog(
await this.ctx.with(
'create platform issue',
{},
async () => {
@@ -499,7 +506,8 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
!markdownCompatible
)
},
{ url: issueExternal.url }
{ url: issueExternal.url },
{ log: true }
)
// We need reiterate to update all sync data.
return {
@@ -518,17 +526,18 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
}
} else {
try {
const description = await this.ctx.withLog(
const description = await this.ctx.with(
'query collaborative description',
{},
async () => {
const collabId = makeDocCollabId(existing, 'description')
return await this.collaborator.getMarkup(collabId, (existing as Issue).description)
},
{ url: issueExternal.url }
{ url: issueExternal.url },
{ log: true }
)
const updateResult = await this.ctx.withLog(
const updateResult = await this.ctx.with(
'diff update',
{},
async () =>
@@ -541,7 +550,8 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
account,
accountGH
),
{ url: issueExternal.url }
{ url: issueExternal.url },
{ log: true }
)
return {
...updateResult,
@@ -620,7 +630,7 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
if (hasFieldStateChanges || body !== undefined) {
if (body !== undefined && !isLocked) {
await this.ctx.withLog(
await this.ctx.with(
'==> updateIssue',
{},
async () => {
@@ -656,11 +666,12 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
}
}
},
{ url: issueExternal.url, id: existing._id }
{ url: issueExternal.url, id: existing._id },
{ log: true }
)
issueData.description = await this.provider.getMarkupSafe(container.container, body, this.stripGuestLink)
} else if (hasFieldStateChanges) {
await this.ctx.withLog(
await this.ctx.with(
'==> updateIssue',
{},
async () => {
@@ -693,7 +704,8 @@ export class IssueSyncManager extends IssueSyncManagerBase implements DocSyncMan
}
}
},
{ url: issueExternal.url }
{ url: issueExternal.url },
{ log: true }
)
}
return true
@@ -415,7 +415,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
if (existing === undefined) {
try {
await this.ctx.withLog(
await this.ctx.with(
'retrieve pull request patch',
{},
() =>
@@ -431,7 +431,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
lastModified,
accountGH
),
{ url: pullRequestExternal.url }
{ url: pullRequestExternal.url },
{ log: true }
)
const { markdownCompatible, markdown } = await this.provider.checkMarkdownConversion(
container.container,
@@ -441,7 +442,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
let op = this.client.apply()
let createdPullRequest: GithubPullRequest | undefined
await this.ctx.withLog(
await this.ctx.with(
'create pull request in platform',
{},
async () => {
@@ -461,7 +462,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
!markdownCompatible
)
},
{ url: pullRequestExternal.url }
{ url: pullRequestExternal.url },
{ log: true }
)
await op.commit()
@@ -499,7 +501,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
} else {
try {
if (info.updatePatch === true) {
await this.ctx.withLog(
await this.ctx.with(
'update pull request patch',
{},
() =>
@@ -515,21 +517,23 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
lastModified,
accountGH
),
{ url: pullRequestExternal.url }
{ url: pullRequestExternal.url },
{ log: true }
)
}
const description = await this.ctx.withLog(
const description = await this.ctx.with(
'query collaborative pull request description',
{},
async () => {
const collabId = makeDocCollabId(existing, 'description')
return await this.collaborator.getMarkup(collabId, (existing as GithubPullRequest).description)
},
{ url: pullRequestExternal.url }
{ url: pullRequestExternal.url },
{ log: true }
)
const update = await this.ctx.withLog(
const update = await this.ctx.with(
'perform pull request diff update',
{},
() =>
@@ -542,7 +546,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
account,
accountGH
),
{ url: pullRequestExternal.url }
{ url: pullRequestExternal.url },
{ log: true }
)
return {
...update,
@@ -950,7 +955,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
if (hasFieldsUpdate || body !== undefined) {
if (body !== undefined && !isLocked) {
await this.ctx.withLog(
await this.ctx.with(
'==> updatePullRequest',
{},
async () => {
@@ -980,19 +985,23 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
)
}
},
{ url: issueExternal.url }
{ url: issueExternal.url },
{ log: true }
)
issueData.description = await this.provider.getMarkupSafe(container.container, body, this.stripGuestLink)
} else if (hasFieldsUpdate) {
await this.ctx.withLog('==> updatePullRequest:', {}, async () => {
this.ctx.info('update-fields', {
url: issueExternal.url,
...issueUpdate,
workspace: this.provider.getWorkspaceId()
})
if (isGHWriteAllowed()) {
await okit?.graphql(
`
await this.ctx.with(
'==> updatePullRequest:',
{},
async () => {
this.ctx.info('update-fields', {
url: issueExternal.url,
...issueUpdate,
workspace: this.provider.getWorkspaceId()
})
if (isGHWriteAllowed()) {
await okit?.graphql(
`
mutation updatePullRequest($issue: ID!) {
updatePullRequest(input: {
pullRequestId: $issue,
@@ -1005,10 +1014,13 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
}
}
}`,
{ issue: issueExternal.id }
)
}
})
{ issue: issueExternal.id }
)
}
},
{ issue: issueExternal.id },
{ log: true }
)
}
return true
}
@@ -1266,7 +1278,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
}
const idsp = idsPart.map((it) => `"${it}"`).join(', ')
try {
const response: any = await this.ctx.withLog(
const response: any = await this.ctx.with(
'fetch pull request updates',
{},
async () =>
@@ -1283,7 +1295,8 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
prj: prj.name,
repo: repo.name,
ids: idsp
}
},
{ log: true }
)
const issues: PullRequestExternalData[] = response.nodes