@@ -13,7 +13,7 @@ const tracer = trace.getTracer('paymentservice');
13
13
const meter = metrics . getMeter ( 'paymentservice' ) ;
14
14
const transactionsCounter = meter . createCounter ( 'app.payment.transactions' ) ;
15
15
16
- const LOYALTY_LEVEL = [ 'platinum' , 'silver' , 'bronze' ] ;
16
+ const LOYALTY_LEVEL = [ 'platinum' , 'gold' , ' silver', 'bronze' ] ;
17
17
18
18
/** Return random element from given array */
19
19
function random ( arr ) {
@@ -51,10 +51,12 @@ module.exports.charge = async request => {
51
51
const card = cardValidator ( number ) ;
52
52
const { card_type : cardType , valid } = card . getCardDetails ( ) ;
53
53
54
+ const loyalty_level = random ( LOYALTY_LEVEL ) ;
55
+
54
56
span . setAttributes ( {
55
57
'app.payment.card_type' : cardType ,
56
58
'app.payment.card_valid' : valid ,
57
- 'app.loyalty.level' : random ( LOYALTY_LEVEL )
59
+ 'app.loyalty.level' : loyalty_level
58
60
} ) ;
59
61
60
62
if ( ! valid ) {
@@ -78,7 +80,7 @@ module.exports.charge = async request => {
78
80
}
79
81
80
82
const { units, nanos, currencyCode } = request . amount ;
81
- logger . info ( { transactionId, cardType, lastFourDigits, amount : { units, nanos, currencyCode } } , 'Transaction complete.' ) ;
83
+ logger . info ( { transactionId, cardType, lastFourDigits, amount : { units, nanos, currencyCode } , loyalty_level } , 'Transaction complete.' ) ;
82
84
transactionsCounter . add ( 1 , { 'app.payment.currency' : currencyCode } ) ;
83
85
span . end ( ) ;
84
86
0 commit comments