feat(discovery): add spanKind metadata to discovery platform spans

Attach spanKind on discovery.list, mesh, publish, and join spans so
dev-log filters and diagnostics align with contacts/DM span conventions.
discovery.join now records activeChannelId when a channel is selected.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Raven Scott
2026-05-24 10:32:43 -04:00
co-authored by Cursor
parent 489117acf6
commit 434d895f1b
+15 -4
View File
@@ -7897,6 +7897,7 @@ class PearcordPlatform extends EventEmitter {
if (!this.discovery) throw new Error('discovery unavailable')
const beforeListed = this.discovery.isGuildPublicListing(guildId)
const span = this.log.time('discovery.publish', {
spanKind: 'discovery.publish',
guildId,
listed: !!listed,
beforeListed
@@ -7917,6 +7918,7 @@ class PearcordPlatform extends EventEmitter {
}
this.emit('discovery')
span.end({
spanKind: 'discovery.publish',
guildId,
listed: !!listed,
hasInvite: !!inviteCode,
@@ -7937,11 +7939,17 @@ class PearcordPlatform extends EventEmitter {
async joinPublicDiscovery (inviteCode) {
if (!inviteCode) throw new Error('invite code required')
const span = this.log.time('discovery.join', {
spanKind: 'discovery.join',
inviteLen: String(inviteCode).length
})
try {
const guild = await this.joinInvite(inviteCode)
span.end({ guildId: guild?.id || null, joined: !!guild })
span.end({
spanKind: 'discovery.join',
guildId: guild?.id || null,
joined: !!guild,
activeChannelId: this.activeChannelId || null
})
return guild
} catch (err) {
this.log.error('discovery.join error', {
@@ -12804,8 +12812,9 @@ class PearcordPlatform extends EventEmitter {
const filteredCount = this.discovery
? this.discovery.filterPublicListings(publicListings, filter).length
: publicListings.length
const listSpan = this.log.time('discovery.list', {})
const listSpan = this.log.time('discovery.list', { spanKind: 'discovery.list' })
listSpan.end({
spanKind: 'discovery.list',
count: publicListings.length,
filterTag: filter?.tag || null,
meshLive: (this.discovery?.peers?.size || 0) > 0,
@@ -12819,13 +12828,14 @@ class PearcordPlatform extends EventEmitter {
} else {
try {
if (!light) {
const listSpan = this.log.time('discovery.list', {})
const listSpan = this.log.time('discovery.list', { spanKind: 'discovery.list' })
publicListings = await this.discovery.listPublicListings()
const filter = this._discoveryFilter
const filteredCount = this.discovery
? this.discovery.filterPublicListings(publicListings, filter).length
: publicListings.length
listSpan.end({
spanKind: 'discovery.list',
count: publicListings.length,
filterTag: filter?.tag || null,
meshLive: (this.discovery?.peers?.size || 0) > 0,
@@ -12871,10 +12881,11 @@ class PearcordPlatform extends EventEmitter {
this._cachedDiscoveryStats = discoveryStats
this._cachedDiscoveryStatsAt = now
} else {
const meshSpan = this.log.time('discovery.mesh', {})
const meshSpan = this.log.time('discovery.mesh', { spanKind: 'discovery.mesh' })
const hadCachedStats = !!this._cachedDiscoveryStats
discoveryStats = await this.discovery.refreshStats()
meshSpan.end({
spanKind: 'discovery.mesh',
peers: discoveryStats?.peers ?? 0,
listings: discoveryStats?.listings ?? publicListings.length,
meshLive: !!discoveryStats?.meshLive,