@@ -39,8 +39,10 @@ type TcmMetricRepositoryImpl struct {
3939 credential common.CredentialIface
4040 monitorClient * monitor.Client
4141 monitorClientInGuangzhou * monitor.Client
42+ monitorClientInSinapore * monitor.Client
4243 limiter * rate.Limiter // 限速
4344 ctx context.Context
45+ IsInternational bool
4446
4547 queryMetricBatchSize int
4648
@@ -133,7 +135,9 @@ func (repo *TcmMetricRepositoryImpl) GetSamples(s *TcmSeries, st int64, et int64
133135 }
134136
135137 response := & v20180724.GetMonitorDataResponse {}
136- if util .IsStrInList (config .QcloudNamespace , s .Metric .Meta .ProductName ) {
138+ if repo .IsInternational && s .Metric .Meta .ProductName == "QAAP" {
139+ response , err = repo .monitorClientInSinapore .GetMonitorData (request )
140+ } else if util .IsStrInList (config .QcloudNamespace , s .Metric .Meta .ProductName ) {
137141 response , err = repo .monitorClientInGuangzhou .GetMonitorData (request )
138142 } else {
139143 response , err = repo .monitorClient .GetMonitorData (request )
@@ -185,7 +189,9 @@ func (repo *TcmMetricRepositoryImpl) listSampleByBatch(
185189 request := repo .buildGetMonitorDataRequest (m , seriesList , st , et )
186190
187191 response := & v20180724.GetMonitorDataResponse {}
188- if util .IsStrInList (config .QcloudNamespace , m .Meta .ProductName ) {
192+ if repo .IsInternational && m .Meta .ProductName == "QAAP" {
193+ response , err = repo .monitorClientInSinapore .GetMonitorData (request )
194+ } else if util .IsStrInList (config .QcloudNamespace , m .Meta .ProductName ) {
189195 response , err = repo .monitorClientInGuangzhou .GetMonitorData (request )
190196 } else {
191197 response , err = repo .monitorClient .GetMonitorData (request )
@@ -282,13 +288,21 @@ func NewTcmMetricRepository(cred common.CredentialIface, conf *config.TencentCon
282288 if err != nil {
283289 return
284290 }
291+ var monitorClientInSingapore * monitor.Client
292+ if conf .IsInternational {
293+ if monitorClientInSingapore , err = client .NewMonitorClient (cred , conf , "ap-singapore" ); err != nil {
294+ return
295+ }
296+ }
285297
286298 repo = & TcmMetricRepositoryImpl {
287299 credential : cred ,
288300 monitorClient : monitorClient ,
289301 monitorClientInGuangzhou : monitorClientInGuangzhou ,
302+ monitorClientInSinapore : monitorClientInSingapore ,
290303 limiter : rate .NewLimiter (rate .Limit (conf .RateLimit ), 1 ),
291304 ctx : context .Background (),
305+ IsInternational : conf .IsInternational ,
292306 queryMetricBatchSize : conf .MetricQueryBatchSize ,
293307 logger : logger ,
294308 }
0 commit comments