SDK Integration
Kotlin SDK Setup Guide
Attach the InSitu JVM agent to your Kotlin application without changing application code.
InSitu supports Kotlin/JVM applications through the same agent used for
Java
. Attach the agent at startup to capture variables, stack frames, metrics, and logs without adding an initializer or annotations.
Technical prerequisites
Runtime:
Kotlin/JVM on Java 17 or later. This guide does not apply to Kotlin/JS or Kotlin/Native.
Metadata:
The Git commit SHA used to build your deployed application.
Debug information:
Preserve source filenames, line numbers, and local variable metadata in your compiled classes so probes can resolve
.kt
source locations and capture locals.
Installation
Download the agent JAR. Replace
<LATEST_VERSION>
with a version from
Maven Central
:
curl
-L
-o
InSitu-agent.jar
"https://repo1.maven.org/maven2/co/InSitu/InSitu-agent/<LATEST_VERSION>/InSitu-agent-<LATEST_VERSION>.jar"
You do not need a separate Kotlin SDK dependency. Adding the JAR as an application dependency alone does not activate the agent; you must pass
-javaagent
to the application JVM.
Initialization walkthrough
1
Set environment variables
Export these variables before starting your application. Replace the service ID with the UUID from your InSitu dashboard:
export
GIT_COMMIT
=
$(
git
rev-parse
HEAD
)
export
InSitu_SERVICE_ID
=
"<service-uuid-from-dashboard>"
export
InSitu_ENVIRONMENT
=
production
export
InSitu_BROKER_URL
=
https
://
logger
.
app
.
InSitu
.
co
Use
git rev-parse HEAD
for local runs. In CI/CD, set
GIT_COMMIT
to the commit used to build the deployed artifact. The agent does not start if it is missing or set to
unknown
.
2
Attach the agent
Choose how you start your application. These examples assume the downloaded JAR is in your project root and the environment variables above are set.
Executable JAR
Spring Boot (Gradle)
Spring Boot (Maven)
java
-javaagent:./InSitu-agent.jar
-jar
build/libs/app.jar
Replace
build/libs/app.jar
with your executable application JAR.
Add the agent to your
bootRun
task:
build.gradle.kts
tasks.
named
<
org
.
springframework
.
boot
.
gradle
.
tasks
.
run
.
BootRun
>(
"bootRun"
) {
jvmArgs
(
"-javaagent:
${
rootDir
}
/InSitu-agent.jar"
)
}
./gradlew
bootRun
mvn
spring-boot:run
\
-Dspring-boot.run.jvmArguments=
"-javaagent:$(
pwd
)/InSitu-agent.jar"
Keep your existing Kotlin
main
function unchanged. The agent starts before your application.
Docker deployment
Copy the downloaded agent and your built application into the image. Adjust the application JAR path to match your build output:
Dockerfile
FROM
eclipse-temurin:21-jre
WORKDIR
/app
ARG
GIT_COMMIT
ENV
GIT_COMMIT=${GIT_COMMIT}
COPY
InSitu-agent.jar /app/InSitu-agent.jar
COPY
build/libs/app.jar /app/app.jar
ENTRYPOINT
[
"java"
,
"-javaagent:/app/InSitu-agent.jar"
,
"-jar"
,
"/app/app.jar"
]
Build and run locally with the environment variables from the initialization step:
docker
build
--build-arg
GIT_COMMIT=
$(
git
rev-parse
HEAD
)
-t
app:latest
.
docker
run
--rm
\
-e
InSitu_SERVICE_ID
\
-e
InSitu_ENVIRONMENT
\
-e
InSitu_BROKER_URL
\
app:latest
Configuration and environment variables
Kotlin uses the same environment variables and defaults as Java. See the
complete environment variable reference
for performance limits, capture depth, redaction, logging, and trace ID hooks.
To disable the agent at startup, set
InSitu_DISABLED=YES
.
Java SDK Setup Guide
Previous
Python SDK Setup Guide
Next
⌘
I
Powered by
This documentation is built and hosted on Mintlify, a developer documentation platform
Terms of Service
On this page
Back to top
Technical prerequisites
Installation
Initialization walkthrough
Docker deployment
Configuration and environment variables