Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/scripts/shading-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
code=0
for path in $(jar -tf agent/build/libs/solarwinds-apm-agent.jar | grep -E -v '^((com/solarwinds|inst|io/open|META))')
do
PACKAGE=$(echo "$path" | awk -F/ '{print $2}')
if [ -n "$PACKAGE" ] && [ "$PACKAGE" != "annotation" ]; then
echo "Package ($path) is not shaded"
code=1
fi
done

if [[ code -ne 0 ]]; then
exit $code
fi

lambda=0
for path in $(jar -tf agent-lambda/build/libs/solarwinds-apm-agent-lambda.jar | grep -E -v '^((com/solarwinds|inst|io/open|META))')
do
PACKAGE=$(echo "$path" | awk -F/ '{print $2}')
if [ -n "$PACKAGE" ] && [ "$PACKAGE" != "annotation" ]; then
echo "Package ($path) is not shaded"
lambda=1
fi
done
exit $lambda
23 changes: 1 addition & 22 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,7 @@ jobs:
run: ./gradlew test

- name: Check shading
run: |
code=0
for path in $(jar -tf agent/build/libs/solarwinds-apm-agent.jar | grep -E -v '^((com/solarwinds|inst|io/open|META))')
do
PACKAGE=$(echo "$path" | awk -F/ '{print $2}')
if [ -n "$PACKAGE" ] && [ "$PACKAGE" != "annotation" ]; then
echo "Package ($path) is not shaded"
code=1
fi
done
exit $code

lambda=0
for path in $(jar -tf agent-lambda/build/libs/solarwinds-apm-agent-lambda.jar | grep -E -v '^((com/solarwinds|inst|io/open|META))')
do
PACKAGE=$(echo "$path" | awk -F/ '{print $2}')
if [ -n "$PACKAGE" ] && [ "$PACKAGE" != "annotation" ]; then
echo "Package ($path) is not shaded"
lambda=1
fi
done
exit $lambda
run: ./.github/scripts/shading-check.sh

smoke-test-linux:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions agent-lambda/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ dependencies {
javaagentLibs(project(":instrumentation"))

bootstrapLibs(project(":bootstrap"))
bootstrapLibs("com.solarwinds.joboe:config")
bootstrapLibs(project(":libs:config"))
bootstrapLibs("org.json:json")
bootstrapLibs("com.solarwinds.joboe:sampling")
bootstrapLibs("com.solarwinds.joboe:logging")
bootstrapLibs(project(":libs:sampling"))
bootstrapLibs(project(":libs:logging"))

upstreamAgent("io.opentelemetry.javaagent:opentelemetry-javaagent")
}
Expand Down
8 changes: 6 additions & 2 deletions agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ dependencies {
javaagentLibs(project(":instrumentation"))

bootstrapLibs(project(":bootstrap"))
bootstrapLibs("com.solarwinds.joboe:core")
bootstrapLibs("com.solarwinds.joboe:metrics")
bootstrapLibs(project(":libs:core"))

bootstrapLibs(project(":libs:config"))
bootstrapLibs(project(":libs:sampling"))
bootstrapLibs(project(":libs:logging"))

bootstrapLibs("org.json:json")
upstreamAgent("io.opentelemetry.javaagent:opentelemetry-javaagent")
}

Expand Down
6 changes: 3 additions & 3 deletions bootstrap/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ plugins {
}

dependencies {
compileOnly("com.solarwinds.joboe:config")
compileOnly("com.solarwinds.joboe:logging")
compileOnly("com.solarwinds.joboe:sampling")
compileOnly(project(":libs:config"))
compileOnly(project(":libs:logging"))
compileOnly(project(":libs:sampling"))

compileOnly("io.opentelemetry:opentelemetry-api")
compileOnly("io.opentelemetry.semconv:opentelemetry-semconv")
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ repositories {
dependencies {
implementation(gradleApi())
implementation("com.diffplug.spotless:spotless-plugin-gradle:8.2.1")
implementation("io.freefair.gradle:lombok-plugin:8.13")

implementation("io.opentelemetry.instrumentation:gradle-plugins:2.25.0-alpha")
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.3.1")
implementation("com.github.gmazzo.buildconfig:com.github.gmazzo.buildconfig.gradle.plugin:6.0.7")
implementation("com.github.spotbugs:com.github.spotbugs.gradle.plugin:6.4.8")
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ dependencies {
compileOnly("net.bytebuddy:byte-buddy")

// Used by byte-buddy but not brought in as a transitive dependency.
compileOnly("com.google.code.findbugs:annotations")
compileOnly("com.google.auto.service:auto-service")
annotationProcessor("com.google.auto.service:auto-service")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import com.solarwinds.instrumentation.gradle.SolarwindsJavaExtension
plugins {
java
checkstyle
id("io.freefair.lombok")
id("solarwinds.spotless-conventions")
id("com.github.spotbugs")
}

repositories {
Expand Down Expand Up @@ -93,8 +95,7 @@ dependencies {
testImplementation("io.opentelemetry.semconv:opentelemetry-semconv")
testImplementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")

testImplementation("com.solarwinds.joboe:core")
testImplementation("com.solarwinds.joboe:metrics")
testImplementation(project(":libs:core"))
testImplementation("org.junit-pioneer:junit-pioneer")

testImplementation("org.junit.jupiter:junit-jupiter-params")
Expand All @@ -117,11 +118,7 @@ tasks {
"-Xlint:all",
// disable annotation ownership warnings
"-Xlint:-processing",
"-Werror",
// FIXME: Refactor generic service provider interfaces (e.g., ConfigParser) to avoid rawtypes warnings
// Disable AutoService verify check to prevent rawtypes warnings for generic service provider interfaces
// The @SuppressWarnings("rawtypes") annotation is not recognized in certain Gradle 9 compilation contexts
"-Averify=false"
"-Werror"
)
)

Expand All @@ -146,4 +143,8 @@ tasks {

checkstyle {
configFile = file("$rootDir/checkstyle.xml")
}

spotbugs {
excludeFilter.set(file("$rootDir/spotbugs-exclude.xml"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,22 @@ tasks.withType<ShadowJar>().configureEach {
relocate("com.github.benmanes", "com.solarwinds.joboe.shaded.caffeine")
relocate("org.checkerframework", "com.solarwinds.joboe.shaded.checkerframework")
relocate("org.json", "com.solarwinds.joboe.shaded.org.json")

relocate("com.solarwinds.trace", "com.solarwinds.joboe.shaded.trace")
relocate("android.annotation", "com.solarwinds.joboe.shaded.android.annotation")
relocate("javax.annotation", "com.solarwinds.joboe.shaded.javax.annotation")

relocate("cloud", "com.solarwinds.joboe.shaded.cloud")
relocate("google", "com.solarwinds.joboe.shaded.google2")
relocate("com.google", "com.solarwinds.joboe.shaded.google")

relocate("javax.xml", "com.solarwinds.joboe.shaded.javax.xml")
relocate("io.grpc", "com.solarwinds.joboe.shaded.io.grpc")
relocate("io.netty", "com.solarwinds.joboe.shaded.io.netty")

relocate("io.perfmark", "com.solarwinds.joboe.shaded.io.perfmark")
relocate("javax.activation", "com.solarwinds.joboe.shaded.javax.activation")
relocate("org.jspecify", "com.solarwinds.joboe.shaded.org.jspecify")

relocate("org.codehaus.mojo", "com.solarwinds.joboe.shaded.org.codehaus.mojo")
}
21 changes: 15 additions & 6 deletions custom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ plugins {
dependencies {
compileOnly(project(":bootstrap"))
compileOnly(project(":libs:shared"))
compileOnly("com.solarwinds.joboe:core")
compileOnly(project(":libs:core"))

compileOnly("org.projectlombok:lombok")
compileOnly("com.solarwinds.joboe:metrics")
annotationProcessor("org.projectlombok:lombok")
compileOnly(project(":libs:config"))
compileOnly(project(":libs:sampling"))
compileOnly(project(":libs:logging"))

compileOnly("com.google.auto.service:auto-service")
annotationProcessor("com.google.auto.service:auto-service")
Expand All @@ -43,15 +43,24 @@ dependencies {
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-incubator")
compileOnly("io.opentelemetry:opentelemetry-exporter-otlp")

compileOnly("com.google.code.gson:gson")
implementation("org.json:json")

testImplementation(project(":libs:config"))
testImplementation(project(":libs:sampling"))
testImplementation(project(":libs:shared"))
testImplementation("org.json:json")
testImplementation("com.solarwinds.joboe:core")
testImplementation(project(":libs:core"))

testImplementation("io.opentelemetry:opentelemetry-api-incubator")
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-incubator")
testImplementation("io.opentelemetry:opentelemetry-exporter-otlp")
}

tasks.named<JavaCompile>("compileJava") {
// Disable AutoService verify check to prevent rawtypes warnings for generic service provider interfaces
options.compilerArgs.add("-Averify=false")
}

tasks.withType(Checkstyle::class).configureEach {
exclude("**/BuildConfig.java")
exclude("**/transaction/**")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.solarwinds.joboe.core.util.HostInfoUtils;
import com.solarwinds.joboe.logging.Logger;
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.joboe.metrics.SystemMonitorController;
import com.solarwinds.joboe.sampling.SettingsManager;
import com.solarwinds.opentelemetry.core.AgentState;
import com.solarwinds.opentelemetry.extensions.config.HttpSettingsFetcher;
Expand Down Expand Up @@ -150,8 +149,6 @@ private void registerShutdownTasks() {
new Thread("SolarwindsAPM-shutdown-hook") {
@Override
public void run() {
SystemMonitorController
.stop(); // stop system monitors, this might flush extra messages to reporters
if (ReporterProvider.getEventReporter() != null) {
ReporterProvider.getEventReporter()
.close(); // close event reporter properly to give it chance to send out pending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
import com.solarwinds.joboe.logging.Logger;
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.joboe.sampling.Metadata;
import com.solarwinds.joboe.shaded.javax.annotation.Nonnull;
import com.solarwinds.opentelemetry.core.Util;
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.SpanContext;
import io.opentelemetry.context.Context;
import io.opentelemetry.sdk.trace.ReadWriteSpan;
import io.opentelemetry.sdk.trace.ReadableSpan;
import io.opentelemetry.sdk.trace.internal.ExtendedSpanProcessor;
import javax.annotation.Nonnull;

/** Span process to perform code profiling */
public class SolarwindsProfilingSpanProcessor implements ExtendedSpanProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

package com.solarwinds.opentelemetry.extensions.config;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.solarwinds.joboe.config.ConfigManager;
import com.solarwinds.joboe.config.ConfigProperty;
import com.solarwinds.joboe.config.ProxyConfig;
import com.solarwinds.joboe.logging.Logger;
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.joboe.sampling.Settings;
import com.solarwinds.joboe.shaded.google.gson.Gson;
import com.solarwinds.joboe.shaded.google.gson.GsonBuilder;
import io.opentelemetry.api.internal.InstrumentationUtil;
import java.io.BufferedReader;
import java.io.IOException;
Expand All @@ -32,6 +32,7 @@
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicReference;

public class HttpSettingsReaderDelegate {
Expand All @@ -56,7 +57,8 @@ public Settings fetchSettings(String url, String authorizationHeader) {
responseCode, errorResponse));
} else {
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
new BufferedReader(
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
settings.set(JsonSettingWrapper.wrap(gson.fromJson(reader, JsonSetting.class)));
}
}
Expand All @@ -79,14 +81,15 @@ public Settings fetchSettings(String url, String authorizationHeader) {
private String getErrorMessage(HttpURLConnection connection) {
String errorResponse;
try (BufferedReader errorReader =
new BufferedReader(new InputStreamReader(connection.getErrorStream()))) {
new BufferedReader(
new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
StringBuilder errorBuilder = new StringBuilder();
String line;
while ((line = errorReader.readLine()) != null) {
errorBuilder.append(line);
}
errorResponse = errorBuilder.toString();
} catch (Exception e) {
} catch (IOException e) {
errorResponse = "Unable to read error response";
}
return errorResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

public final class ConfigurationFileWatcher {
private final Path directory;
Expand All @@ -39,7 +40,7 @@ public final class ConfigurationFileWatcher {

private final long watchPeriod;

private static ConfigurationFileWatcher INSTANCE;
private static final AtomicReference<ConfigurationFileWatcher> INSTANCE = new AtomicReference<>();

private ScheduledFuture<?> scheduledWatch;

Expand All @@ -62,13 +63,15 @@ public static void restartWatch(
WatchService watchService,
ScheduledExecutorService scheduledExecutorService,
Runnable fileChangeListener) {
if (INSTANCE != null) {
INSTANCE.cancelWatch();
}
INSTANCE =
ConfigurationFileWatcher next =
new ConfigurationFileWatcher(
directory, watchPeriod, watchService, scheduledExecutorService, fileChangeListener);
INSTANCE.startWatch();

ConfigurationFileWatcher previous = INSTANCE.getAndSet(next);
if (previous != null) {
previous.cancelWatch();
}
next.startWatch();
}

private void watch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import com.solarwinds.joboe.core.profiler.ProfilerSetting;
import com.solarwinds.joboe.logging.Logger;
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.joboe.shaded.org.json.JSONArray;
import com.solarwinds.joboe.shaded.org.json.JSONException;
import com.solarwinds.joboe.shaded.org.json.JSONObject;
import java.util.HashSet;
import java.util.Set;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ProfilerSettingParser implements ConfigParser<String, ProfilerSetting> {
private static final Logger logger = LoggerFactory.getLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.solarwinds.joboe.config.JavaRuntimeVersionChecker;
import com.solarwinds.joboe.logging.Logger;
import com.solarwinds.joboe.logging.LoggerFactory;
import com.solarwinds.joboe.shaded.javax.annotation.Nonnull;
import com.solarwinds.opentelemetry.extensions.MetricExporterCustomizer;
import com.solarwinds.opentelemetry.extensions.ResourceCustomizer;
import com.solarwinds.opentelemetry.extensions.SolarwindsPropertiesSupplier;
Expand All @@ -31,6 +30,7 @@
import com.solarwinds.opentelemetry.extensions.config.SpanExporterCustomizer;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizer;
import io.opentelemetry.sdk.autoconfigure.spi.AutoConfigurationCustomizerProvider;
import javax.annotation.Nonnull;

/**
* An implementation of {@link AutoConfigurationCustomizer} which serves as the bootstrap for our
Expand Down
Loading
Loading