@@ -14,15 +14,16 @@ var defaults = {
14
14
}
15
15
16
16
class TencentCloudClient {
17
- constructor ( credentials = { } , service = { } ) {
17
+ constructor ( credentials = { } , service = { } , options = { } ) {
18
18
this . credentials = credentials
19
19
this . service = service
20
+ this . options = options
20
21
}
21
22
22
23
async cloudApiGenerateQueryString ( data ) {
23
24
var param = assign (
24
25
{
25
- Region : defaults . Region ,
26
+ Region : this . options . region || defaults . Region ,
26
27
SecretId : this . credentials . SecretId ,
27
28
Timestamp : Math . round ( Date . now ( ) / 1000 ) ,
28
29
Nonce : Math . round ( Math . random ( ) * 65535 ) ,
@@ -618,6 +619,7 @@ class SlsMonitor {
618
619
}
619
620
}
620
621
if ( requestHandlers . length == 0 ) {
622
+ console . log ( 'getCustomMetrics' , JSON . stringify ( responses ) )
621
623
this . aggrCustomDatas ( responses , period , metricAttributeHash )
622
624
return responses
623
625
}
@@ -627,15 +629,22 @@ class SlsMonitor {
627
629
628
630
results = await getMetricsResponse ( requestHandlers )
629
631
responses = responses . concat ( results )
632
+ console . log ( 'getCustomMetrics' , JSON . stringify ( responses ) )
630
633
this . aggrCustomDatas ( responses , period , metricAttributeHash )
631
634
return responses
632
635
}
633
636
634
637
async getScfMetrics ( region , rangeTime , period , funcName , ns , version ) {
635
- const client = new TencentCloudClient ( this . credentials , {
636
- host : 'monitor.tencentcloudapi.com' ,
637
- path : '/'
638
- } )
638
+ const client = new TencentCloudClient (
639
+ this . credentials ,
640
+ {
641
+ host : 'monitor.tencentcloudapi.com' ,
642
+ path : '/'
643
+ } ,
644
+ {
645
+ region : region
646
+ }
647
+ )
639
648
const req = {
640
649
Action : 'GetMonitorData' ,
641
650
Version : '2018-07-24'
@@ -686,11 +695,8 @@ class SlsMonitor {
686
695
return new Promise ( ( resolve , reject ) => {
687
696
Promise . all ( requestHandlers )
688
697
. then ( ( results ) => {
698
+ console . log ( 'getScfMetrics' , JSON . stringify ( results ) )
689
699
this . aggrDurationP ( results , durationPeriod , period )
690
-
691
- // if (aggrFlag)
692
- // this.aggregationByDay(results)
693
-
694
700
resolve ( results )
695
701
} )
696
702
. catch ( ( error ) => {
0 commit comments