Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-26615 Service Instance #70

Merged
merged 2 commits into from
Jan 21, 2023
Merged

NH-26615 Service Instance #70

merged 2 commits into from
Jan 21, 2023

Conversation

Lin-Lin_swi
Copy link
Mannequin

@Lin-Lin_swi Lin-Lin_swi mannequin commented Jan 9, 2023

Jira

https://swicloud.atlassian.net/browse/NH-26615
See also https://github.com/librato/joboe/pull/1572

Changes

Test

In a Linux container and the test collector configured to console.STATUS.printHostId: true, seeing the expected HostID (including uuid) and __Init message:

2023-01-13 23:12:18,739 INFO [ConsoleWriter] - STATUS Finished preprocessing 1 messages
HostId [hostname=c3e925ad327f, ec2InstanceId=, ec2AvailabilityZone=, dockerContainerId=, herokuDynoId=, azureInstanceId=, macAddresses=[], hostType=PERSISTENT, uamsClientId=, uuid=f620e874-ff3d-4f33-825d-cc4b12b2d005] javatest : {"__Init":true,"process.runtime.version":"1.8.0_352-b08","os.type":"linux","process.pid":13,"telemetry.sdk.name":"opentelemetry","telemetry.sdk.language":"java","process.runtime.name":"OpenJDK Runtime Environment","APM.Version":"0.14.2","os.description":"Linux 5.15.49-linuxkit","process.executable.path":"/opt/java/openjdk:bin:java","host.arch":"aarch64","process.command_line":"/opt/java/openjdk:bin:java -Djava.io.tmpdir=/tmp/jetty -javaagent:/opt/solarwinds-apm/solarwinds-apm-agent.jar","host.name":"c3e925ad327f","telemetry.sdk.version":"1.12.0","process.runtime.description":"Temurin OpenJDK 64-Bit Server VM 25.352-b08","telemetry.auto.version":"0.14.2"}
2023-01-13 23:12:18,748 INFO [ConsoleWriter] - STATUS Finished sending messages numbers=1

__Init message pretty-printed:

{
    "__Init": true,
    "process.runtime.version": "1.8.0_352-b08",
    "os.type": "linux",
    "process.pid": 13,
    "Layer": null,
    "telemetry.sdk.name": "opentelemetry",
    "telemetry.sdk.language": "java",
    "process.runtime.name": "OpenJDK Runtime Environment",
    "APM.Version": "0.14.2",
    "os.description": "Linux 5.15.49-linuxkit",
    "process.executable.path": "/opt/java/openjdk:bin:java",
    "host.arch": "aarch64",
    "process.command_line": "/opt/java/openjdk:bin:java -Djava.io.tmpdir=/tmp/jetty -javaagent:/opt/solarwinds-apm/solar
winds-apm-agent.jar",
    "host.name": "c3e925ad327f",
    "telemetry.sdk.version": "1.12.0",
    "process.runtime.description": "Temurin OpenJDK 64-Bit Server VM 25.352-b08",
    "telemetry.auto.version": "0.14.2"
}

Another run in a Linux container, when the env var OTEL_JAVA_DISABLED_RESOURCE_PROVIDERS=io.opentelemetry.sdk.extension.resources.ProcessResourceProvider,io.opentelemetry.sdk.extension.resources.ProcessRuntimeResourceProvider is used to disable Process and ProcessRuntime Resources in the agent, seeing new HostID.uuid and the required __Init message attributes are still set:

2023-01-13 23:20:12,864 INFO [ConsoleWriter] - STATUS Finished preprocessing 1 messages
HostId [hostname=1f253810184d, ec2InstanceId=, ec2AvailabilityZone=, dockerContainerId=, herokuDynoId=, azureInstanceId=, macAddresses=[], hostType=PERSISTENT, uamsClientId=, uuid=4f95cf90-a106-4311-9488-3c3e0817fe5c] javatest : {"__Init":true,"process.runtime.version":"1.8.0_352-b08","os.type":"linux","telemetry.sdk.name":"opentelemetry","telemetry.sdk.language":"java","process.runtime.name":"OpenJDK Runtime Environment","APM.Version":"0.14.2","os.description":"Linux 5.15.49-linuxkit","host.arch":"aarch64","host.name":"1f253810184d","telemetry.sdk.version":"1.12.0","process.runtime.description":"Temurin OpenJDK 64-Bit Server VM 25.352-b08","telemetry.auto.version":"0.14.2"}
2023-01-13 23:20:12,872 INFO [ConsoleWriter] - STATUS Finished sending messages numbers=1

__Init message pretty-printed:

{
    "__Init": true,
    "process.runtime.version": "1.8.0_352-b08",
    "os.type": "linux",
    "Layer": null,
    "telemetry.sdk.name": "opentelemetry",
    "telemetry.sdk.language": "java",
    "process.runtime.name": "OpenJDK Runtime Environment",
    "APM.Version": "0.14.2",
    "os.description": "Linux 5.15.49-linuxkit",
    "host.arch": "aarch64",
    "host.name": "1f253810184d",
    "telemetry.sdk.version": "1.12.0",
    "process.runtime.description": "Temurin OpenJDK 64-Bit Server VM 25.352-b08",
    "telemetry.auto.version": "0.14.2"
}

Another run in a Linux container, where the service key is passed in the command line as a Java system property (and otel debugging is enabled), e.g. -Dsw.apm.service.key=top-secret:foo and -Dotel.javaagent.debug=true, seeing service key masked:

Instrumented application log:

[otel.javaagent 2023-01-13 23:35:48:754 +0000] [SolarwindsAPM-post-startup-tasks-1] DEBUG com.appoptics.opentelemetry.extensions.initialize.Initializer - Resource attributes {host.arch="aarch64", host.name="fd2719b73337", os.description="Linux 5.15.49-linuxkit", os.type="linux", process.command_line="/opt/java/openjdk:bin:java -Djava.io.tmpdir=/tmp/jetty -javaagent:/opt/solarwinds-apm/solarwinds-apm-agent.jar -Dsw.apm.service.key=**** -Dotel.javaagent.debug=true", process.executable.path="/opt/java/openjdk:bin:java", process.pid=13, process.runtime.description="Temurin OpenJDK 64-Bit Server VM 25.352-b08", process.runtime.name="OpenJDK Runtime Environment", process.runtime.version="1.8.0_352-b08", service.name="unknown_service:java", telemetry.auto.version="0.14.2", telemetry.sdk.language="java", telemetry.sdk.name="opentelemetry", telemetry.sdk.version="1.12.0"}

__Init message pretty-printed:

{
    "__Init": true,
    "process.runtime.version": "1.8.0_352-b08",
    "os.type": "linux",
    "process.pid": 13,
    "Layer": null,
    "telemetry.sdk.name": "opentelemetry",
    "telemetry.sdk.language": "java",
    "process.runtime.name": "OpenJDK Runtime Environment",
    "APM.Version": "0.14.2",
    "os.description": "Linux 5.15.49-linuxkit",
    "process.executable.path": "/opt/java/openjdk:bin:java",
    "host.arch": "aarch64",
    "process.command_line": "/opt/java/openjdk:bin:java -Djava.io.tmpdir=/tmp/jetty -javaagent:/opt/solarwinds-apm/solarwinds-apm-agent.jar -Dsw.apm.service.key=**** -Dotel.javaagent.debug=true",
    "host.name": "fd2719b73337",
    "telemetry.sdk.version": "1.12.0",
    "process.runtime.description": "Temurin OpenJDK 64-Bit Server VM 25.352-b08",
    "telemetry.auto.version": "0.14.2"
}

On a Windows EC2 instance with metadata disabled (to simulate on-prem host) and the test collector configured to console.STATUS.printHostId: true, seeing the expected HostID (including uuid) and __Init message:

2023-01-14 00:03:42,024 INFO [ConsoleWriter] - STATUS Finished preprocessing 1 messages
HostId [hostname=EC2AMAZ-IOH4MF4, ec2InstanceId=, ec2AvailabilityZone=, dockerContainerId=, herokuDynoId=, azureInstanceId=, macAddresses=[12:8E:6F:95:8F:EB], hostType=PERSISTENT, uamsClientId=7d339695-3feb-4bad-bd9c-a93cd5c85388, uuid=d875fca2-f963-4ed1-8b4a-1e15689d5b1c] javatest : {"__Init":true,"process.runtime.version":"13+33","os.type":"windows","process.pid":5280,"telemetry.sdk.name":"opentelemetry","telemetry.sdk.language":"java","process.runtime.name":"OpenJDK Runtime Environment","APM.Version":"0.14.2","os.description":"Windows Server 2019 10.0","process.executable.path":"C:\\openjdk-13\\jdk-13;bin;java.exe","host.arch":"amd64","process.command_line":"C:\\openjdk-13\\jdk-13;bin;java.exe --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -Djava.util.logging.config.file=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0\\conf\\logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -javaagent:C:\\Program Files\\SolarWinds\\APM\\java\\solarwinds-apm-agent.jar -Dsw.apm.trustedpath=C:\\Program Files\\java-collector\\server-grpc.pem -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -Dcatalina.base=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0 -Dcatalina.home=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0 -Djava.io.tmpdir=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0\\temp","host.name":"EC2AMAZ-IOH4MF4","telemetry.sdk.version":"1.12.0","process.runtime.description":"Oracle Corporation OpenJDK 64-Bit Server VM 13+33","telemetry.auto.version":"0.14.2"}
2023-01-14 00:03:42,028 INFO [ConsoleWriter] - STATUS Finished sending messages numbers=1

__Init message pretty-printed:

{
  "__Init": true,
  "process.runtime.version": "13+33",
  "os.type": "windows",
  "process.pid": 5280,
  "telemetry.sdk.name": "opentelemetry",
  "telemetry.sdk.language": "java",
  "process.runtime.name": "OpenJDK Runtime Environment",
  "APM.Version": "0.14.2",
  "os.description": "Windows Server 2019 10.0",
  "process.executable.path": "C:\\openjdk-13\\jdk-13;bin;java.exe",
  "host.arch": "amd64",
  "process.command_line": "C:\\openjdk-13\\jdk-13;bin;java.exe --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED -Djava.util.logging.config.file=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0\\conf\\logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -javaagent:C:\\Program Files\\SolarWinds\\APM\\java\\solarwinds-apm-agent.jar -Dsw.apm.trustedpath=C:\\Program Files\\java-collector\\server-grpc.pem -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -Dcatalina.base=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0 -Dcatalina.home=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0 -Djava.io.tmpdir=c:\\Program Files\\Apache Software Foundation\\Tomcat 9.0\\temp",
  "host.name": "EC2AMAZ-IOH4MF4",
  "telemetry.sdk.version": "1.12.0",
  "process.runtime.description": "Oracle Corporation OpenJDK 64-Bit Server VM 13+33",
  "telemetry.auto.version": "0.14.2"
}

@Lin-Lin_swi Lin-Lin_swi mannequin requested a review from ghost January 14, 2023 00:39
@@ -59,7 +72,6 @@ public static void initialize() throws InvalidConfigException {
//future = executeStartupTasks(); //Cannot call this here, see https://github.com/appoptics/opentelemetry-custom-distro/issues/7
Copy link
Mannequin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this line be removed completely? Or if good to keep for future, is there a way this method can be called with AutoConfiguredOpenTelemetrySdk otelSDK to match sig update?

Copy link
Mannequin Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that comment seems very much leftover from exploratory stage so I've removed it.

Copy link
Mannequin

@tammy-baylis_swi tammy-baylis_swi mannequin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall lgtm! Just added one comment.

Thank you for posting the detailed example messages that match the updated spec! Great use of OTel Java's resource attributes and afterAgent to get those defaults.

Copy link
Mannequin

@Xuan-Cao_swi Xuan-Cao_swi mannequin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

initMessage.put(TELEMETRY_SDK_LANGUAGE.getKey(), "java");
}
try {
if (!initMessage.containsKey(PROCESS_RUNTIME_DESCRIPTION.getKey())) {
Copy link
Mannequin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code checked to make sure the system property returned in System.getProperty wasn't null (eg java.version). Should the uses of System.getProperty continue to do that?

Copy link
Mannequin Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Certain system properties are always available so I've added defaults for ones that are not: java.runtime.name, java.runtime.version

Copy link
Mannequin

@malin-olafson_swi malin-olafson_swi mannequin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good, just had one minor comment.

@Lin-Lin_swi Lin-Lin_swi mannequin dismissed stale reviews from ghost via 736c152 January 18, 2023 23:23
Copy link
Mannequin

@tammy-baylis_swi tammy-baylis_swi mannequin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! Thanks for the revisions!

Copy link
Mannequin

@malin-olafson_swi malin-olafson_swi mannequin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@Lin-Lin_swi Lin-Lin_swi mannequin merged commit 81c6d2f into main Jan 21, 2023
@Lin-Lin_swi Lin-Lin_swi mannequin deleted the NH-26615-service-instance branch January 21, 2023 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants