Skip to content
Merged
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
5 changes: 4 additions & 1 deletion agent/src/main/java/com/appland/appmap/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import com.appland.appmap.util.Logger;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.tinylog.TaggedLogger;
Expand Down Expand Up @@ -66,8 +67,10 @@ public static void premain(String agentArgs, Instrumentation inst) {
"To disable the automatic creation of this log file, set the system property {} to 'true'",
Properties.DISABLE_LOG_FILE_KEY);
}
String implementationVersion = Agent.class.getPackage().getImplementationVersion();
Logger.printUserMessage("AppMap agent version %s starting\n", implementationVersion);
logger.info("Agent version {}, current time mills: {}",
Agent.class.getPackage().getImplementationVersion(), start);
implementationVersion, start);
logger.info("config: {}", AppMapConfig.get());
logger.info("System properties: {}", System.getProperties());
logger.debug(new Exception(), "whereAmI");
Expand Down
3 changes: 3 additions & 0 deletions agent/src/main/java/com/appland/appmap/config/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
public class Properties {
public static final String APPMAP_OUTPUT_DIRECTORY_KEY = "appmap.output.directory";
public static final String DISABLE_LOG_FILE_KEY = "appmap.disableLogFile";

public static final Boolean Silent = resolveProperty("appmap.silent", false);

public static final Boolean DisableLogFile = resolveProperty(DISABLE_LOG_FILE_KEY, true);
public static final Boolean Debug = resolveProperty("appmap.debug", false);
public static final Boolean DebugHooks = Debug || (System.getProperty("appmap.debug.hooks") != null);
Expand Down
2 changes: 2 additions & 0 deletions agent/src/main/java/com/appland/appmap/record/Recording.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.List;
import java.util.function.Function;

import com.appland.appmap.util.Logger;
import org.tinylog.TaggedLogger;

import com.appland.appmap.config.AppMapConfig;
Expand Down Expand Up @@ -94,6 +95,7 @@ public Path moveTo(Path targetPath) {
throw new RuntimeException(String.join(", ", errors));
}

Logger.printUserMessage("AppMap recording saved to %s\n", targetPath.toAbsolutePath());
return targetPath;
}

Expand Down
12 changes: 12 additions & 0 deletions agent/src/main/java/com/appland/appmap/util/Logger.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.appland.appmap.util;

import com.appland.appmap.config.AppMapConfig;
import com.appland.appmap.config.Properties;

public class Logger {
private static final org.tinylog.TaggedLogger logger = AppMapConfig.getLogger(null);
Expand All @@ -25,4 +26,15 @@ public static void error(Throwable t) {
println(t);
}

/**
* Print a message on stderr unless the silent flag is set.
* @param format
* @param args
*/
public static void printUserMessage(String format, Object... args) {
if (!Properties.Silent) {
System.err.printf(format, args);
}
}

}
2 changes: 1 addition & 1 deletion agent/test/classloading/classloading.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ setup_file() {
}

@test "Proxy" {
run \
run --separate-stderr \
./gradlew ${BATS_VERSION+-q} -PappmapJar="$AGENT_JAR" run --args "TestProxy"
assert_success
assert_json_eq ".events[0].defined_class" "com.appland.appmap.test.fixture.helloworld.HelloWorld"
Expand Down
1 change: 1 addition & 0 deletions agent/test/helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _tests_helper() {
if type -t bats_load_library &>/dev/null; then
bats_load_library bats-support
bats_load_library bats-assert
bats_require_minimum_version 1.5.0
fi
}

Expand Down
8 changes: 4 additions & 4 deletions agent/test/http_client/httpclient/httpclient.bats
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ setup_file() {
}

@test "request without query" {
run ./gradlew -q -PmainClass=httpclient.HttpClientTest run ${DEBUG} --args "${WS_URL}/vets"
run --separate-stderr ./gradlew -q -PmainClass=httpclient.HttpClientTest run ${DEBUG} --args "${WS_URL}/vets"

assert_json_eq '.events[1].http_client_request.request_method' "GET"
assert_json_eq '.events[1].http_client_request.url' "${WS_URL}/vets"
Expand All @@ -20,7 +20,7 @@ setup_file() {
}

@test "request with query" {
run ./gradlew -q -PmainClass=httpclient.HttpClientTest run ${DEBUG} --args "${WS_URL}/owners?lastName=davis"
run --separate-stderr ./gradlew -q -PmainClass=httpclient.HttpClientTest run ${DEBUG} --args "${WS_URL}/owners?lastName=davis"

assert_json_eq '.events[1].http_client_request.url' "${WS_URL}/owners"
assert_json_eq '.events[1].message | length' 1
Expand All @@ -30,14 +30,14 @@ setup_file() {
}

@test "request without Content-Type" {
run ./gradlew -q -PmainClass=httpclient.HttpClientTest run ${DEBUG} --args "${WS_URL}/no-content"
run --separate-stderr ./gradlew -q -PmainClass=httpclient.HttpClientTest run ${DEBUG} --args "${WS_URL}/no-content"

assert_json_eq '.events[1].http_client_request.url' "${WS_URL}/no-content"
assert_json_eq '.events[2].http_client_response.status' "200"
}

@test "request with HttpHost" {
run ./gradlew -q -PmainClass=httpclient.HttpHostTest run ${DEBUG} --args "${WS_HOST} ${WS_PORT} /owners?lastName=davis"
run --separate-stderr ./gradlew -q -PmainClass=httpclient.HttpHostTest run ${DEBUG} --args "${WS_HOST} ${WS_PORT} /owners?lastName=davis"

assert_json_eq '.events[1].http_client_request.url' "${WS_URL}/owners"
assert_json_eq '.events[1].message | length' 1
Expand Down
4 changes: 2 additions & 2 deletions agent/test/petclinic/petclinic-tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ run_petclinic_test() {

@test "NoAppMap on method disables test recording" {
run_petclinic_test "JUnit5Tests#testAnnotatedMethodNotRecorded"
assert_output 'passing annotated test, not recorded'
assert_output --partial 'passing annotated test, not recorded'

run test \! -f ./tmp/appmap/junit/org_springframework_samples_petclinic_JUnit5Tests_testAnnotatedMethodNotRecorded.appmap.json
assert_success
}

@test "NoAppMap on class disables test recording" {
run_petclinic_test "JUnit5Tests\$TestClass#testAnnotatedClassNotRecorded"
assert_output "passing annotated class, not recorded"
assert_output --partial "passing annotated class, not recorded"

run test \! -f ./tmp/appmap/junit/org_springframework_samples_petclinic_JUnit5Tests_testAnnotatedMethodNotRecorded.appmap.json
assert_success
Expand Down