Skip to main content
Version: 0.10.x

Java Interceptor

Installation

To install Lunar Interceptor, first obtain lunarInterceptor.jar:

wget -O lunarInterceptor.jar https://s01.oss.sonatype.org/content/repositories/releases/dev/lunar/interceptor/lunar-interceptor/0.1.1/lunar-interceptor-0.1.1.jar

Configuration

The only required configuration is the LUNAR_PROXY_HOST environment variable. This variable should be set to the host or IP of Lunar Proxy, including the port it is listening on.

For example:

export LUNAR_PROXY_HOST="localhost:8000"
note

This environment variable sets the host and port for Lunar Proxy. Set this to localhost:8000 if you're running Lunar Proxy in a local Docker container. The value assigned to LUNAR_PROXY_HOST should only include the hostname and port, without the HTTP prefix. For example, use localhost:8000 and not http://localhost:8000.

For more details and other configuration options, refer to our Configuration Guide

[Optional] Identifying Your Consumer by the x-lunar-consumer-tag Header

Add the x-lunar-consumer-tag header to your requests with a value indicating the originating application or service. This header will be removed before the request is forwarded to third-party providers.

Usage

Enable the instrumentation agent by using the -javaagent flag with the JVM.

export JAVA_TOOL_OPTIONS="-javaagent:PATH/TO/lunarInterceptor.jar"

Or

java -javaagent:PATH/TO/lunarInterceptor.jar -jar PATH/TO/YOURS.jar

Run Your App and Validate Proxy/Interceptor Linkage

Run your app and consume API traffic. Then, use the Discover command to validate that the requests were passed through Lunar Proxy, and that your installed interceptor is correctly listed.

kubectl exec <lunar-proxy-pod-name> -- discover
CTRL + M