Skip to content

Commit 00414f6

Browse files
committed
use constants for attribute references
1 parent 782c70e commit 00414f6

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

instrumentation/resources/library/src/main/java/io/opentelemetry/instrumentation/resources/ProcessResource.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
public final class ProcessResource {
2424

2525
// copied from ProcessIncubatingAttributes
26-
private static final AttributeKey<List<String>> PROCESS_COMMAND_ARGS =
26+
static final AttributeKey<List<String>> PROCESS_COMMAND_ARGS =
2727
AttributeKey.stringArrayKey("process.command_args");
28-
private static final AttributeKey<String> PROCESS_COMMAND_LINE =
28+
static final AttributeKey<String> PROCESS_COMMAND_LINE =
2929
AttributeKey.stringKey("process.command_line");
30-
private static final AttributeKey<String> PROCESS_EXECUTABLE_PATH =
30+
static final AttributeKey<String> PROCESS_EXECUTABLE_PATH =
3131
AttributeKey.stringKey("process.executable.path");
32-
private static final AttributeKey<Long> PROCESS_PID = AttributeKey.longKey("process.pid");
32+
static final AttributeKey<Long> PROCESS_PID = AttributeKey.longKey("process.pid");
3333

3434
// Note: This pattern doesn't support file paths with spaces in them.
3535
// Important: This is statically used in buildResource, so must be declared/initialized first.

instrumentation/resources/library/src/testSecurityManager/java/io/opentelemetry/instrumentation/resources/SecurityManagerResourceTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import static org.assertj.core.api.Assertions.assertThat;
99

10-
import io.opentelemetry.api.common.AttributeKey;
1110
import io.opentelemetry.api.common.Attributes;
1211
import io.opentelemetry.sdk.resources.Resource;
1312
import org.junit.jupiter.api.Test;
@@ -26,7 +25,7 @@ class SecurityManagerResourceTest {
2625
@Test
2726
void hostResourceTestEmpty() {
2827
Attributes attributes = HostResource.buildResource().getAttributes();
29-
assertThat(attributes.asMap()).containsOnlyKeys(AttributeKey.stringKey("host.name"));
28+
assertThat(attributes.asMap()).containsOnlyKeys(HostResource.HOST_NAME);
3029
}
3130

3231
@Test
@@ -37,7 +36,7 @@ void osResourceEmpty() {
3736
@Test
3837
void processResourceEmpty() {
3938
Attributes attributes = ProcessResource.buildResource().getAttributes();
40-
assertThat(attributes.asMap()).containsOnlyKeys(AttributeKey.longKey("process.pid"));
39+
assertThat(attributes.asMap()).containsOnlyKeys(ProcessResource.PROCESS_PID);
4140
}
4241

4342
@Test

0 commit comments

Comments
 (0)