Skip to content

Commit 560015d

Browse files
Copilottrask
andcommitted
Add static imports for Level constants to follow style guide
Co-authored-by: trask <[email protected]>
1 parent 9284308 commit 560015d

File tree

6 files changed

+26
-22
lines changed

6 files changed

+26
-22
lines changed

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/BeanstalkResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.SERVICE_INSTANCE_ID;
1313
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.SERVICE_NAMESPACE;
1414
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_VERSION;
15+
import static java.util.logging.Level.WARNING;
1516

1617
import com.fasterxml.jackson.core.JsonFactory;
1718
import com.fasterxml.jackson.core.JsonParser;
@@ -22,7 +23,6 @@
2223
import io.opentelemetry.semconv.SchemaUrls;
2324
import java.io.File;
2425
import java.io.IOException;
25-
import java.util.logging.Level;
2626
import java.util.logging.Logger;
2727

2828
/**
@@ -65,7 +65,7 @@ static Resource buildResource(String configPath) {
6565
parser.nextToken();
6666

6767
if (!parser.isExpectedStartObjectToken()) {
68-
logger.log(Level.WARNING, "Invalid Beanstalk config: ", configPath);
68+
logger.log(WARNING, "Invalid Beanstalk config: ", configPath);
6969
return Resource.create(attrBuilders.build(), SchemaUrls.V1_25_0);
7070
}
7171

@@ -87,7 +87,7 @@ static Resource buildResource(String configPath) {
8787
}
8888
}
8989
} catch (IOException e) {
90-
logger.log(Level.WARNING, "Could not parse Beanstalk config.", e);
90+
logger.log(WARNING, "Could not parse Beanstalk config.", e);
9191
return Resource.empty();
9292
}
9393

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/DockerHelper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55

66
package io.opentelemetry.contrib.aws.resource;
77

8+
import static java.util.logging.Level.WARNING;
9+
810
import java.io.BufferedReader;
911
import java.io.FileNotFoundException;
1012
import java.io.FileReader;
1113
import java.io.IOException;
12-
import java.util.logging.Level;
1314
import java.util.logging.Logger;
1415

1516
class DockerHelper {
@@ -44,9 +45,9 @@ public String getContainerId() {
4445
}
4546
}
4647
} catch (FileNotFoundException e) {
47-
logger.log(Level.WARNING, "Failed to read container id, cgroup file does not exist.");
48+
logger.log(WARNING, "Failed to read container id, cgroup file does not exist.");
4849
} catch (IOException e) {
49-
logger.log(Level.WARNING, "Unable to read container id: " + e.getMessage());
50+
logger.log(WARNING, "Unable to read container id: " + e.getMessage());
5051
}
5152

5253
return "";

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/Ec2Resource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_IMAGE_ID;
1616
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_NAME;
1717
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.HOST_TYPE;
18+
import static java.util.logging.Level.WARNING;
1819

1920
import com.fasterxml.jackson.core.JsonFactory;
2021
import com.fasterxml.jackson.core.JsonParser;
@@ -28,7 +29,6 @@
2829
import java.net.URL;
2930
import java.util.HashMap;
3031
import java.util.Map;
31-
import java.util.logging.Level;
3232
import java.util.logging.Logger;
3333

3434
/**
@@ -125,7 +125,7 @@ static Resource buildResource(String endpoint) {
125125
}
126126
}
127127
} catch (IOException e) {
128-
logger.log(Level.WARNING, "Could not parse identity document, resource not filled.", e);
128+
logger.log(WARNING, "Could not parse identity document, resource not filled.", e);
129129
return Resource.empty();
130130
}
131131

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/EcsResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudProviderIncubatingValues.AWS;
2929
import static java.util.Collections.emptyMap;
3030
import static java.util.Collections.singletonList;
31+
import static java.util.logging.Level.WARNING;
3132

3233
import com.fasterxml.jackson.core.JsonFactory;
3334
import com.fasterxml.jackson.core.JsonParser;
@@ -40,7 +41,6 @@
4041
import java.util.Locale;
4142
import java.util.Map;
4243
import java.util.Optional;
43-
import java.util.logging.Level;
4444
import java.util.logging.Logger;
4545
import java.util.regex.Matcher;
4646
import java.util.regex.Pattern;
@@ -114,7 +114,7 @@ static void fetchMetadata(
114114
attrBuilders.put(AWS_LOG_STREAM_ARNS, singletonList(logStreamArn));
115115
});
116116
} catch (IOException e) {
117-
logger.log(Level.WARNING, "Can't get ECS metadata", e);
117+
logger.log(WARNING, "Can't get ECS metadata", e);
118118
}
119119
}
120120

@@ -157,7 +157,7 @@ static void parseResponse(
157157
JsonParser parser, AttributesBuilder attrBuilders, LogArnBuilder logArnBuilder)
158158
throws IOException {
159159
if (!parser.isExpectedStartObjectToken()) {
160-
logger.log(Level.WARNING, "Couldn't parse ECS metadata, invalid JSON");
160+
logger.log(WARNING, "Couldn't parse ECS metadata, invalid JSON");
161161
return;
162162
}
163163

@@ -340,7 +340,7 @@ static DockerImage parse(@Nullable String image) {
340340
}
341341
Matcher matcher = imagePattern.matcher(image);
342342
if (!matcher.matches()) {
343-
logger.log(Level.WARNING, "Couldn't parse image '" + image + "'");
343+
logger.log(WARNING, "Couldn't parse image '" + image + "'");
344344
return null;
345345
}
346346
String repository = matcher.group("repository");

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/EksResource.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudPlatformIncubatingValues.AWS_EKS;
1212
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.CloudProviderIncubatingValues.AWS;
1313
import static io.opentelemetry.contrib.aws.resource.IncubatingAttributes.K8S_CLUSTER_NAME;
14+
import static java.util.logging.Level.FINE;
15+
import static java.util.logging.Level.WARNING;
1416

1517
import com.fasterxml.jackson.core.JsonFactory;
1618
import com.fasterxml.jackson.core.JsonParser;
@@ -26,7 +28,6 @@
2628
import java.nio.file.Paths;
2729
import java.util.HashMap;
2830
import java.util.Map;
29-
import java.util.logging.Level;
3031
import java.util.logging.Logger;
3132

3233
/**
@@ -91,7 +92,7 @@ static Resource buildResource(
9192
private static boolean isEks(
9293
String k8sTokenPath, String k8sKeystorePath, SimpleHttpClient httpClient) {
9394
if (!isK8s(k8sTokenPath, k8sKeystorePath)) {
94-
logger.log(Level.FINE, "Not running on k8s.");
95+
logger.log(FINE, "Not running on k8s.");
9596
return false;
9697
}
9798

@@ -145,7 +146,7 @@ private static String getClusterName(SimpleHttpClient httpClient) {
145146
}
146147
}
147148
} catch (IOException e) {
148-
logger.log(Level.WARNING, "Can't get cluster name on EKS.", e);
149+
logger.log(WARNING, "Can't get cluster name on EKS.", e);
149150
}
150151
return "";
151152
}
@@ -156,7 +157,7 @@ private static String getK8sCredHeader() {
156157
new String(Files.readAllBytes(Paths.get(K8S_TOKEN_PATH)), StandardCharsets.UTF_8);
157158
return "Bearer " + content;
158159
} catch (IOException e) {
159-
logger.log(Level.WARNING, "Unable to load K8s client token.", e);
160+
logger.log(WARNING, "Unable to load K8s client token.", e);
160161
}
161162
return "";
162163
}

aws-resources/src/main/java/io/opentelemetry/contrib/aws/resource/SimpleHttpClient.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
package io.opentelemetry.contrib.aws.resource;
77

8+
import static java.util.logging.Level.FINE;
9+
import static java.util.logging.Level.WARNING;
10+
811
import java.io.FileInputStream;
912
import java.io.IOException;
1013
import java.security.KeyStore;
@@ -13,7 +16,6 @@
1316
import java.time.Duration;
1417
import java.util.Collection;
1518
import java.util.Map;
16-
import java.util.logging.Level;
1719
import java.util.logging.Logger;
1820
import javax.annotation.Nullable;
1921
import javax.net.ssl.SSLContext;
@@ -72,7 +74,7 @@ public String fetchString(
7274
int responseCode = response.code();
7375
if (responseCode != 200) {
7476
logger.log(
75-
Level.FINE,
77+
FINE,
7678
"Error response from "
7779
+ urlStr
7880
+ " code ("
@@ -84,7 +86,7 @@ public String fetchString(
8486
ResponseBody body = response.body();
8587
return body != null ? body.string() : "";
8688
} catch (IOException e) {
87-
logger.log(Level.FINE, "SimpleHttpClient fetch string failed.", e);
89+
logger.log(FINE, "SimpleHttpClient fetch string failed.", e);
8890
}
8991

9092
return "";
@@ -101,7 +103,7 @@ private static X509TrustManager buildTrustManager(@Nullable KeyStore keyStore) {
101103
tmf.init(keyStore);
102104
return (X509TrustManager) tmf.getTrustManagers()[0];
103105
} catch (Exception e) {
104-
logger.log(Level.WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
106+
logger.log(WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
105107
return null;
106108
}
107109
}
@@ -117,7 +119,7 @@ private static SSLSocketFactory buildSslSocketFactory(@Nullable TrustManager tru
117119
return context.getSocketFactory();
118120

119121
} catch (Exception e) {
120-
logger.log(Level.WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
122+
logger.log(WARNING, "Build SslSocketFactory for K8s restful client exception.", e);
121123
}
122124
return null;
123125
}
@@ -138,7 +140,7 @@ private static KeyStore getKeystoreForTrustedCert(String certPath) {
138140
}
139141
return trustStore;
140142
} catch (Exception e) {
141-
logger.log(Level.WARNING, "Cannot load KeyStore from " + certPath);
143+
logger.log(WARNING, "Cannot load KeyStore from " + certPath);
142144
return null;
143145
}
144146
}

0 commit comments

Comments
 (0)