Skip to content

Commit 355ab5e

Browse files
committed
CUST-110209: remove joboe logging from SDK
1 parent 2dacba9 commit 355ab5e

File tree

3 files changed

+99
-4
lines changed

3 files changed

+99
-4
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* © SolarWinds Worldwide, LLC. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
java
19+
application
20+
id("de.undercouch.download") version "5.5.0"
21+
}
22+
23+
group = "com.solarwinds"
24+
version = "unspecified"
25+
26+
repositories {
27+
mavenCentral()
28+
}
29+
30+
dependencies {
31+
implementation("io.netty:netty-common:4.1.94.Final")
32+
implementation("io.github.appoptics:solarwinds-otel-sdk:2.5.0")
33+
testImplementation(platform("org.junit:junit-bom:5.9.1"))
34+
testImplementation("org.junit.jupiter:junit-jupiter")
35+
}
36+
37+
tasks.test {
38+
useJUnitPlatform()
39+
}
40+
41+
val swoAgentPath = project.buildDir.toString() + "/swo/solarwinds-apm-agent.jar"
42+
43+
fun getAgentPath(downloadPath: String) = if (System.getenv("AGENT_PATH") == null) downloadPath
44+
else System.getenv("AGENT_PATH")
45+
46+
application {
47+
mainClass.set("com.solarwinds.netty.NettyApp")
48+
applicationDefaultJvmArgs = listOf("-javaagent:${getAgentPath(swoAgentPath)}")
49+
}
50+
51+
tasks.register<de.undercouch.gradle.tasks.download.Download>("downloadSwoAgent") {
52+
doNotTrackState("Runs everytime because new build needs to be downloaded")
53+
src(System.getenv("AGENT_DOWNLOAD_URL"))
54+
dest(swoAgentPath)
55+
overwrite(true)
56+
}
57+
58+
tasks.named("run", JavaExec::class) {
59+
setEnvironment("SW_APM_SERVICE_KEY" to "${System.getenv("SW_APM_SERVICE_KEY")}:netty-pipeline-test-app")
60+
dependsOn("downloadSwoAgent")
61+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* © SolarWinds Worldwide, LLC. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.solarwinds.netty;
18+
19+
import io.netty.util.NetUtil;
20+
import com.solarwinds.api.ext.SolarwindsAgent
21+
22+
import java.util.concurrent.TimeUnit;
23+
24+
public class NettyApp {
25+
public static void main(String[] args) {
26+
SolarwindsAgent.setTransactionName("hello world")
27+
System.out.printf("Number of interfaces: %d%n", NetUtil.NETWORK_INTERFACES.size());
28+
try {
29+
TimeUnit.MINUTES.sleep(1);
30+
} catch (InterruptedException ignore) {
31+
32+
}
33+
System.out.printf("Shutting down%n");
34+
}
35+
}

solarwinds-otel-sdk/src/main/java/com/solarwinds/api/ext/SolarwindsAgent.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616

1717
package com.solarwinds.api.ext;
1818

19-
import com.solarwinds.joboe.logging.Logger;
20-
import com.solarwinds.joboe.logging.LoggerFactory;
2119
import com.solarwinds.opentelemetry.core.AgentState;
2220
import java.util.concurrent.TimeUnit;
21+
import java.util.logging.Logger;
2322

2423
public class SolarwindsAgent {
2524
private SolarwindsAgent() {}
2625

27-
private static final Logger logger = LoggerFactory.getLogger();
26+
private static final Logger logger = Logger.getLogger(SolarwindsAgent.class.getName());
2827

2928
private static boolean agentAttached = false;
3029

@@ -35,7 +34,7 @@ private SolarwindsAgent() {}
3534
agentAttached = true;
3635

3736
} catch (ClassNotFoundException | NoClassDefFoundError | NoSuchMethodError e) {
38-
logger.warn("The SolarWinds APM Agent is not available. The SDK will be no-op.");
37+
logger.warning("The SolarWinds APM Agent is not available. The SDK will be no-op.");
3938
}
4039
}
4140

0 commit comments

Comments
 (0)