File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/main/java/com/orange/lo/sample/lo2iothub Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 19
19
import org .springframework .boot .SpringApplication ;
20
20
import org .springframework .boot .autoconfigure .SpringBootApplication ;
21
21
import org .springframework .context .annotation .Bean ;
22
+
23
+ import software .amazon .awssdk .auth .credentials .ProfileCredentialsProvider ;
22
24
import software .amazon .awssdk .services .cloudwatch .CloudWatchAsyncClient ;
23
25
24
26
import java .lang .invoke .MethodHandles ;
25
27
26
28
@ SpringBootApplication
27
29
public class ConnectorApplication {
28
30
31
+ private static final String SERVICE_PROFILE_NAME = "service-profile" ;
29
32
private static final Logger LOG = LoggerFactory .getLogger (MethodHandles .lookup ().lookupClass ());
30
33
private final MetricsProperties metricsProperties ;
31
34
@@ -40,7 +43,12 @@ public static void main(String[] args) {
40
43
@ Bean
41
44
@ Qualifier ("counters" )
42
45
public MeterRegistry meterRegistry () {
43
- CloudWatchMeterRegistry cloudWatchMeterRegistry = new CloudWatchMeterRegistry (cloudWatchConfig (), Clock .SYSTEM , CloudWatchAsyncClient .create ());
46
+ CloudWatchAsyncClient cloudWatchAsyncClient = CloudWatchAsyncClient .builder ()
47
+ .credentialsProvider (ProfileCredentialsProvider .create (SERVICE_PROFILE_NAME ))
48
+ .build ();
49
+
50
+ CloudWatchMeterRegistry cloudWatchMeterRegistry = new CloudWatchMeterRegistry (cloudWatchConfig (), Clock .SYSTEM , cloudWatchAsyncClient );
51
+
44
52
cloudWatchMeterRegistry .config ()
45
53
.meterFilter (MeterFilter .deny (id -> !id .getName ().startsWith ("message" )))
46
54
.commonTags (metricsProperties .getDimensionName (), metricsProperties .getDimensionValue ());
You can’t perform that action at this time.
0 commit comments