Skip to content

Commit

Permalink
CUST-110209: remove joboe logging from SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
cleverchuk committed Aug 20, 2024
1 parent 2dacba9 commit 355ab5e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 4 deletions.
61 changes: 61 additions & 0 deletions smoke-tests/SDK-test-no-agent/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* © SolarWinds Worldwide, LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
java
application
id("de.undercouch.download") version "5.5.0"
}

group = "com.solarwinds"
version = "unspecified"

repositories {
mavenCentral()
}

dependencies {
implementation("io.netty:netty-common:4.1.94.Final")
implementation("io.github.appoptics:solarwinds-otel-sdk:2.5.0")
testImplementation(platform("org.junit:junit-bom:5.9.1"))
testImplementation("org.junit.jupiter:junit-jupiter")
}

tasks.test {
useJUnitPlatform()
}

val swoAgentPath = project.buildDir.toString() + "/swo/solarwinds-apm-agent.jar"

fun getAgentPath(downloadPath: String) = if (System.getenv("AGENT_PATH") == null) downloadPath
else System.getenv("AGENT_PATH")

application {
mainClass.set("com.solarwinds.netty.NettyApp")
applicationDefaultJvmArgs = listOf("-javaagent:${getAgentPath(swoAgentPath)}")
}

tasks.register<de.undercouch.gradle.tasks.download.Download>("downloadSwoAgent") {
doNotTrackState("Runs everytime because new build needs to be downloaded")
src(System.getenv("AGENT_DOWNLOAD_URL"))
dest(swoAgentPath)
overwrite(true)
}

tasks.named("run", JavaExec::class) {
setEnvironment("SW_APM_SERVICE_KEY" to "${System.getenv("SW_APM_SERVICE_KEY")}:netty-pipeline-test-app")
dependsOn("downloadSwoAgent")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* © SolarWinds Worldwide, LLC. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.solarwinds.netty;

import io.netty.util.NetUtil;
import com.solarwinds.api.ext.SolarwindsAgent

import java.util.concurrent.TimeUnit;

public class NettyApp {
public static void main(String[] args) {
SolarwindsAgent.setTransactionName("hello world")
System.out.printf("Number of interfaces: %d%n", NetUtil.NETWORK_INTERFACES.size());
try {
TimeUnit.MINUTES.sleep(1);
} catch (InterruptedException ignore) {

}
System.out.printf("Shutting down%n");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@

package com.solarwinds.api.ext;

import com.solarwinds.joboe.logging.Logger;
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.opentelemetry.core.AgentState;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;

public class SolarwindsAgent {
private SolarwindsAgent() {}

private static final Logger logger = LoggerFactory.getLogger();
private static final Logger logger = Logger.getLogger(SolarwindsAgent.class.getName());

private static boolean agentAttached = false;

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

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

Expand Down

0 comments on commit 355ab5e

Please sign in to comment.