Java agent
Traceable’s Java tracing agent or Java agent is based on OpenTelemetery and enhances the Spans within a Trace with security-focused attributes. Traceable’s agent can capture all the traffic that flows through your Java application, including request and response headers and the request and response body. Traceable’s Java agent uses an OTLP exporter.
Before you begin
The following prerequisites are required for installing Traceable’s Java agent:
The Java agent requires Java 8 or above.
Traceable Platform Agent - Make sure that the Traceable platform agent’s address is available to the applications being instrumented.
Supported frameworks
Library/Framework
Versions
1.6+
2.0+
Micronaut (basic support via Netty)
1.0+
4.0+
3.0+
2.3, 3.0, 5.0
5.0+
3.0+
2.3+
1.4+
Note
Traceable also supports any framework that uses one of the supported frameworks as an underlying framework.
Setup
Complete the following steps to attach or load Traceable’s Java agent and do a static attach. The Java application is started with a Java agent in the static attach deployment method. You can choose one of the following three methods to attach the Java agent statically:
Download using curl
Download and untar the Java agent by entering the following command:
Run your application JAR with the traceable-agent from the command line:
Download from Maven Central and attach using Gradle
If you want to attach the Traceable agent to the runtask of a Gradle project leveraging the Application Plugin, complete the following steps:
Define a custom Gradle configuration for
javaagentDeclare the Traceable Java agent as a dependency using the custom configuration to download it from Maven Central
Set the -
javaagentflag as the first element of thejvmArgslist for theruntask. Use the custom configuration you defined to dynamically retrieve the path of the Java agent JAR on your system.gradle run will now run your application with the Traceable Java agent attached.
ActionScript
Download from Maven Central and attach using Maven
If you want to attach the Traceable agent to the exec task of a Maven project leveraging the Exec Maven Plugin, complete the following steps:
Use the Maven Dependency Plugin to download the agent from Maven Central and copy it to your project’s build directory
Add an
<argument>to the Exec Maven Plugin configuration to set the -javaagentflagmvn compile exec:execwill now run your application with the Traceable Java agent attachedActionScript
Configure
You can configure the Java agent using one of the following three methods:
Method 1 – Configure a YAML file – Configure a YAML file with all the configurations
Method 2 – Provide configuration values as an environment variable – Provide the configuration as environment variables. This option overrides the configurations defined in the YAML file.
Method 3 – Provide configuration values as Java system properties – Use Java’s
-Dproperty=valuemethod to set the configuration. This overrides the configurations set using the environment variables.
Method 1 – Configure a YAML file
You can use the following sample YAML file, for example, example-config.yaml to configure Traceable’s Java agent. If you do not provide the configuration file, the Java agent takes the inbuilt default values, which you can see in the output command output on the console. Run the above command separately for each Java application you want to use with Traceable’s Java agent. The following is a sample YAML file. For more configuration options, see Configuration variables.
Load the Java agent.
After you have completed the configuration file, run the following command to instrument your Java application with Traceable’s Java agent:
Method 2 – Provide configuration values as an environment variable
You can configure the Java agent by providing the configuration as an environment variable to the JJava command. When you provide configuration through an environment variable, it overwrites the configuration values set using Method 1. The following is an example of providing the configuration as an environment variable. For more environment variables, see Configuration variables.
Method 3 – Provide configuration values as Java system properties
You can also use Java’s -Dproperty=value method to set the configuration values. When you set the value using this method, it overwrites the values set using both Method 1 and 2. Following is an example of using Java’s -D flag. For more system properties, see Configuration variables.
Configuration variables
The following table lists all the available variables:
service_name
HT_SERVICE_NAME
ht.service.name
-
The name of the service with which you wish to identify the service in the Traceable dashboard.
propagation_formats
HT_PROPAGATION_FORMATS
ht.propagation.formats
TRACECONTEXT
Defines the propagation format. The default is TRACECONTEXT. The options are TRACECONTEXT and B3.
reporting.secure
HT_REPORTING_SOURCE
ht.reporting.secure
false
When set to true a secure connection is established to send spans to the Traceable Platform Agent.
reporting.endpoint
HT_REPORTING_ENDPOINT
ht.reporting.endpoint
http://localhost:4317
URL of Traceable Platform Agent where the spans should be exported to.
http://traceable-agent:4317
reporting.trace_reporter_type
HT_REPORTING_TRACE_REPORTER_TYPE
ht.reporting.trace.reporter.type
OTLP
Trace Reporter type to be used for exporting spans.
Accepted values are: OTLP and ZIPKIN
reporting.cert_file
HT_REPORTING_CERT_FILE
ht.reporting.cert.file
““
The certificate file path used while setting up Traceable Agent for HTTPS communication with Traceable Platform Agent.
data_capture.http_headers.request
HT_DATA_CAPTURE_HTTP_HEADERS_REQUEST
ht.data.capture.http.headers.request
true
Turn on or off capturing of request headers in HTTP.
data_capture.http_headers.response
HT_DATA_CAPTURE_HTTP_HEADERS_RESPONSE
ht.data.capture.http.headers.response
true
Turn on or off capturing of response headers in HTTP.
data_capture.http_body.request
HT_DATA_CAPTURE_HTTP_BODY_REQUEST
ht.data.capture.http.body.request
true
Turn on or off capturing of the request body in HTTP.
data_capture.http_body.response
HT_DATA_CAPTURE_HTTP_BODY_RESPONSE
ht.data.capture.http.body.response
true
Turn on or off capturing of response body in HTTP.
data_capture.rpc_metadata.request
HT_DATA_CAPTURE_RPC_METADATA_REQUEST
ht.data.capture.rpc.metadata.request
true
Turn on or off capturing of request metadata in RPC.
data_capture.rpc_metadata.response
HT_DATA_CAPTURE_RPC_METADATA_RESPONSE
ht.data.capture.rpc.metadata.response
true
Turn on or off capturing of response metadata in RPC.
data_capture.rpc_body.request
HT_DATA_CAPTURE_RPC_BODY_REQUEST
ht.data.capture.rpc.body.request
true
Turn on or off capturing of the request body in RPC.
data_capture.rpc_body.response
HT_DATA_CAPTURE_RPC_BODY_RESPONSE
ht.data.capture.rpc.body.response
true
Turn on or off capturing of response body in RPC.
remote.enabled
TA_REMOTE_CONFIG_ENABLED
ta.remote.config.enabled
true
Enable fetching of remote configurations from Traceable agent. Remote configurations consist of blocking, sampling, and API naming configurations.
remote.endpoint
TA_REMOTE_CONFIG_ENDPOINT
ta.remote.config.endpoint
true
URL of Traceable Platform agent where the Remote config should be fetched from.
traceable-agent:5441
remote.poll_period_seconds
TA_REMOTE_CONFIG_POLL_PERIOD_SECONDS
ta.remote.config.poll.period.seconds
30
The time in seconds to poll the remote config service to fetch the latest rules.
remote.cert_file
TA_REMOTE_CONFIG_CERT_FILE
ta.remote.config.cert_file
““
The certificate file path used while setting up Traceable Agent for HTTPS communication with Traceable Platform Agent.
remote.grpc_max_call_recv_msg_size
TA_REMOTE_CONFIG_ENABLED
ta.remote.config.grpc.max.call.recv.msg.size
32 * 1024 * 1024
The size limit in bytes for the response from Traceable Platform Agent.
remote.use_secure_connection
TA_REMOTE_CONFIG_USE_SECURE_CONNECTION
ta.remote.config.use_secure_connection
false
You can use this flag to fetch certificates from the default truststore of the operating system instead of providing the file above.
blocking.enabled
TA_BLOCKING_CONFIG_ENABLED
ta.blocking.config.enabled
true
Enable blocking with the Tracing Agent.
blocking.evaluate_body
TA_BLOCKING_CONFIG_EVALUATE_BODY
ta.blocking.config.evalutate_body
true
Process request and response bodies for matching the blocking criteria.
blocking.skip_internal_request
TA_BLOCKING_CONFIG_SKIP_INTERNAL_REQUEST
ta.blocking.config.skip.internal.request
true
Skip requests coming from internal (private) IP addresses.
blocking.max_recursion_depth
TA_BLOCKING_CONFIG_MAX_RECURSION_DEPTH
ta.blocking.config.max.recursion.depth
20
The maximum level of recursions allowed while processing a nested rule.
blocking.modsecurity.enabled
TA_BLOCKING_CONFIG_MODSECURITY_ENABLED
ta.blocking.config.modsecurity.enabled
true
Enable data evaluation by ModSecurity engine.
blocking.region.enabled
TA_BLOCKING_CONFIG_REGION_ENABLED
ta.blocking.config.region.blocking.enabled
true
Enable region-based blocking.
sampling.enabled
TA_SAMPLING_ENABLED
ta.sampling.enabled
true
Enable agent-side sampling.
api_discovery.enabled
TA_API_DISCOVERY_ENABLED
ta.api.discovery.enabled
true
Enable agent-side API discovery.
javaagent.import_jks_certs
TA_JAVAAGENT_IMPORT_JKS_CERTS
ta.javaagent.import.jks.certs
false
Use certificates provided in the Java Trust Store to authenticate HTTPS connections to the Traceable Platform agent.
If the certificates are added to a custom trust store, make sure that the Java application points to this Java truststore, -Djavax.net.ssl.trustStore= <path/to/truststore>
-javax.net.ssl.trustStorePassword=<truststore-password>
blocking.response_status_code
TA_BLOCKING_CONFIG_RESPONSE_STATUS_CODE
ta.blocking.config.response.status.code
403
Response error code when a request is blocked. You can configure a value that you wish.
blocking.response_message
TA_BLOCKING_CONFIG_RESPONSE_MESSAGE
ta.blocking.config.response.message
Access Forbidden
Defines the response message when a request is blocked.
logging.log_mode
TA_LOGGING_MODE
ta.logging.mode
LOG_MODE_STDOUT
Defines the mode to specify where to log. The values can be:
LOG_MODE_NONELOG_MODE_STDOUTLOG_MODE_FILE
logging.log_level
TA_LOOGING_LEVEL
ta.logging.level
LOG_LEVEL_INFO
Defines the logging level. The values can be:
LOG_LEVEL_TRACELOG_LEVEL_DEBUGLOG_LEVEL_INFOLOG_LEVEL_WARNLOG_LEVEL_ERRORLOG_LEVEL_CRITICAL
logging.log_file.max_files
TA_LOGGING_LOG_FILE_MAX_FILES
ta.logging.log.file.max.files
3
Defines the maximum number used for logging. Each size will have a maximum size specified by value in logging.log_file.max_file_size configuration.
logging.log_file.max_file_size
TA_LOGGING_LOG_FILE_MAX_FILE_SIZE
ta.logging.log.file.max.file.size
10485760 bytes
Defines the maximum size of the log files in bytes.
logging.log_file.file_path
TA_LOGGING_LOG_FILE_FILE_PATH
ta.logging.log.file.file.path
/var/traceable/log/libtraceable-javaagent.log
Defines the path where the log file would be created.
metrics_config.enabled
TA_METRICS_ENABLED
ta.metrics.enabled
false
Using this variable, you can enable global metrics.
metrics_config.logging.enabled
TA_METRICS_LOGGING_ENABLED
ta.metrics.logging.enabled
false
Using this variable, you can enable logging for global metrics.
metrics_config.logging.frequency
TA_METRICS_LOGGING_FREQUENCY
ta.metrics.logging.frequency
1m
Defines the frequency for logging global metrics, for example, 60m, 3600s, 1h, etc.
metrics_config.endpoint_config.enabled
TA_METRICS_ENDPOINT_ENABLED
ta.metrics.endpoint.enabled
false
Using this variable, you can enable endpoint-specific metrics.
metrics_config.endpoint_config.max_endpoints
TA_METRICS_ENDPOINT_MAX_ENDPOINTS
ta.metrics.endpoint.max.endpoints
100
Configure the maximum number of endpoints you wish to track for endpoint metrics.
metrics_config.endpoint_config.logging.enabled
TA_METRICS_ENDPOINT_LOGGING_ENABLED
ta.metrics.endpoint.logging.enabled
false
Using this variable, you can enable or disable logging for specific endpoints.
metrics_config.endpoint_config.logging.frequency
TA_METRICS_ENDPOINT_LOGGING_FREQUENCY
ta.metrics.endpoint.logging.frequency
30m
Defines the frequency for logging endpoint-specific metrics, for example, 30m, 3600s, 1h, etc.
Verify deployment
To verify the deployment of the Java agent, log into your Traceable Dashboard and click on Services. If the deployment was successful, you will see your service listed under the Name column.

Disable instrumentation
You can turn off instrumentation by running the following command:
The following instrumentation names disable only Hypertrace instrumentation, not the core OpenTelemetery:
ht – All Hypertrace instrumentationservlet-ht – Servlet, Spark Webokhttp-ht- Okhttpgrpc-ht – Okhttp
The Hypertrace instrumentation also uses the core OpenTelemetry instrumentation names. For example, -Dotel.instrumentation.servlet.enabled=false disables all the servlet instrumentation, including core OpenTelemetry and Hypertrace.
Uninstall Java agent
To uninstall Traceable’s Java agent, restart your application without the javaagent argument or any of Traceable’s system properties.
Last updated
Was this helpful?