This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
abstract out reporting and associate with meta txns
- Loading branch information
Steve Klebanoff
committed
Aug 3, 2020
1 parent
3af429d
commit f543b70
Showing
6 changed files
with
85 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { QuoteReport } from '@0x/asset-swapper'; | ||
import _ = require('lodash'); | ||
|
||
import { NUMBER_SOURCES_PER_LOG_LINE } from '../constants'; | ||
import { logger } from '../logger'; | ||
|
||
interface QuoteReportSubmissionByTaker { | ||
quoteReport: QuoteReport; | ||
submissionBy: 'taker'; | ||
uniqueIdString: string; | ||
} | ||
interface QuoteReportSubmissionByMetaTxn { | ||
quoteReport: QuoteReport; | ||
submissionBy: 'metaTxn'; | ||
zeroExTransactionHash: string; | ||
} | ||
type LogQuoteReportOptions = QuoteReportSubmissionByTaker | QuoteReportSubmissionByMetaTxn; | ||
|
||
export const quoteReportUtils = { | ||
logQuoteReport(logOpts: LogQuoteReportOptions): void { | ||
const qr = logOpts.quoteReport; | ||
|
||
let logBase: { [key: string]: string | boolean } = { | ||
firmQuoteReport: true, | ||
submissionBy: logOpts.submissionBy, | ||
}; | ||
if (logOpts.submissionBy === 'metaTxn') { | ||
logBase = { ...logBase, zeroExTransactionHash: logOpts.zeroExTransactionHash }; | ||
} else if (logOpts.submissionBy === 'taker') { | ||
logBase = { ...logBase, uniqueIdString: logOpts.uniqueIdString }; | ||
} | ||
|
||
// Deliver in chunks since Kibana can't handle logs large requests | ||
const sourcesConsideredChunks = _.chunk(qr.sourcesConsidered, NUMBER_SOURCES_PER_LOG_LINE); | ||
sourcesConsideredChunks.forEach((chunk, i) => { | ||
logger.info({ | ||
...logBase, | ||
sourcesConsidered: chunk, | ||
sourcesConsideredChunkIndex: i, | ||
sourcesConsideredChunkLength: sourcesConsideredChunks.length, | ||
}); | ||
}); | ||
const sourcesDeliveredChunks = _.chunk(qr.sourcesDelivered, NUMBER_SOURCES_PER_LOG_LINE); | ||
sourcesDeliveredChunks.forEach((chunk, i) => { | ||
logger.info({ | ||
...logBase, | ||
sourcesDelivered: chunk, | ||
sourcesDeliveredChunkIndex: i, | ||
sourcesDeliveredChunkLength: sourcesDeliveredChunks.length, | ||
}); | ||
}); | ||
}, | ||
}; |
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