Skip to content

Commit

Permalink
Log service and hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
HDegroote committed Jul 28, 2024
1 parent a0d7e42 commit d32a31d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class PrometheusDhtBridge extends ReadyResource {

this.aliases.set(alias, entry)
// TODO: just emit entry?
this.emit('set-alias', { alias, publicKey: targetPubKey, scrapeClient: entry.scrapeClient })
this.emit('set-alias', { alias, entry })
const updated = true

if (write === true) {
Expand Down
8 changes: 6 additions & 2 deletions run.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ async function main () {
}

function setupLogging (bridge, logger) {
bridge.on('set-alias', ({ alias, publicKey, scrapeClient }) => {
logger.info(`Registered alias: ${alias} -> ${idEnc.normalize(publicKey)}`)
bridge.on('set-alias', ({ alias, entry }) => {
const scrapeClient = entry.scrapeClient
const publicKey = scrapeClient.targetKey
const { service, hostname } = entry

logger.info(`Registered alias: ${alias} -> ${idEnc.normalize(publicKey)} (${service} on host ${hostname})`)

scrapeClient.on('connection-open', ({ uid, targetKey, peerInfo }) => {
logger.info(`Scraper for ${alias}->${idEnc.normalize(targetKey)} opened connection from ${idEnc.normalize(peerInfo.publicKey)} (uid: ${uid})`)
Expand Down

0 comments on commit d32a31d

Please sign in to comment.