File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
main/java/software/amazon/cloudwatchlogs/emf/environment
test/java/software/amazon/cloudwatchlogs/emf/environment Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,15 @@ public String getName() {
45
45
46
46
@ Override
47
47
public String getLogGroupName () {
48
- return config .getLogGroupName ().orElse (getName () + "-metrics" );
48
+ if (config .getLogGroupName ().isPresent ()) {
49
+ return config .getLogGroupName ().get ();
50
+ } else {
51
+ String serviceName = getName ();
52
+ // for ECS services, replace "repo:tag" format with "repo-tag" to satisfy
53
+ // log group regex
54
+ serviceName = serviceName .replaceAll (":" , "-" );
55
+ return serviceName + "-metrics" ;
56
+ }
49
57
}
50
58
51
59
public String getLogStreamName () {
Original file line number Diff line number Diff line change @@ -150,6 +150,14 @@ public void testGetLogGroupNameReturnNonEmpty() {
150
150
assertEquals (environment .getLogGroupName (), Constants .UNKNOWN + "-metrics" );
151
151
}
152
152
153
+ @ Test
154
+ public void testGetLogGroupNameReplaceColon () {
155
+ String serviceName = "testRepo:testTag" ;
156
+ when (config .getServiceName ()).thenReturn (Optional .of (serviceName ));
157
+
158
+ assertEquals (environment .getLogGroupName (), "testRepo-testTag-metrics" );
159
+ }
160
+
153
161
@ Test
154
162
public void testConfigureContext () throws UnknownHostException {
155
163
PowerMockito .mockStatic (SystemWrapper .class );
You can’t perform that action at this time.
0 commit comments