Let to the caller to choose how to handle the call to a method
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
const EVENT_VERSION = '1';
|
||||
const MAX_LENGTH = 100;
|
||||
|
||||
function pubSubMetrics ({ enabled, metricsBackend }) {
|
||||
function pubSubMetrics ({ enabled, metricsBackend, logger }) {
|
||||
if (!enabled) {
|
||||
return function pubSubMetricsDisabledMiddleware (req, res, next) {
|
||||
next();
|
||||
@@ -15,7 +15,9 @@ function pubSubMetrics ({ enabled, metricsBackend }) {
|
||||
const { event, attributes } = getEventData(req, res);
|
||||
|
||||
if (event) {
|
||||
metricsBackend.send(event, attributes);
|
||||
metricsBackend.send(event, attributes)
|
||||
.then(() => logger.debug(`PubSubTracker: event '${event}' published succesfully`))
|
||||
.catch((error) => logger.error(`ERROR: pubsub middleware failed to publish event '${event}': ${error.message}`));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user