-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(telemetry): use
makeSlogSenderFromModule
- Loading branch information
1 parent
64d0171
commit 2892da9
Showing
8 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// @ts-check | ||
import path from 'path'; | ||
|
||
export const DEFAULT_SLOG_SENDER_MODULE = | ||
'@agoric/telemetry/src/flight-recorder.js'; | ||
|
||
export const makeSlogSenderFromModule = async ( | ||
slogSenderModule = DEFAULT_SLOG_SENDER_MODULE, | ||
makerOpts = {}, | ||
) => { | ||
if (!slogSenderModule) { | ||
return undefined; | ||
} | ||
|
||
if (slogSenderModule.startsWith('.')) { | ||
// Resolve relative to the current working directory. | ||
slogSenderModule = path.resolve(slogSenderModule); | ||
} | ||
|
||
console.warn(`Loading makeSlogSender from ${slogSenderModule}`); | ||
const { makeSlogSender: maker } = await import(slogSenderModule); | ||
if (typeof maker !== 'function') { | ||
throw Error(`${slogSenderModule} did not export a makeSlogSender function`); | ||
} | ||
return maker(makerOpts); | ||
}; |