Viewing the Source Code in OverOps

Contents

Introduction

SBT / Play Framework

Ant

Maven

Eclipse

IntelliJ

Clojure

Adding Source Folders

Attaching Source Code for a Specific Event

 

Introduction

When you open an event in the dashboard, OverOps presents the decompiled application bytecode and projects the runtime variable data onto it. With standard Java, the decompilation accurately reflects the source code (excluding annotations). For non-Java languages running on the JVM (such as Scala, JRuby, Groovy, Clojure), and/or in order to display annotations, OverOps requires that you attach the original source code to the OverOps agent. This procedure can also be applied when using a code weaver (such as AspectJ) that expands your bytecode with large amounts of synthetic code.

Attaching your source code to OverOps involves a minor customization of the build steps, described below, per environment. Sample projects are available on GitHub: https://github.com/takipi/attach-source-samples.

 

SBT / Play Framework

SBT 0.13 and above / Play 2.4.1 and above
To resolve issues relating to build code running on version 0.13 and above refer to the migration article at Migration from 0.12.x

To tweak your compile mappings (for Play 2.4.1 and above):

  • Before the project definition, add the following line:
    inConfig(Compile)(mappings in packageBin ++= Defaults.sourceMappings) 

Example of build.sbt:
inConfig(Compile)(mappings in packageBin ++= Defaults.sourceMappings)
lazy val root = (project in file(".")).enablePlugins(PlayScala)

SBT 0.9 - 1.2 / Play 2.4.0 and below

To attach source code to .jar with SBT:

  • Add the following line to the build.sbt file:
    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "app" )

  • In a Maven-like project structure, replace "src" with "src/main/scala" and "src/main/java":
    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src/main/scala" )

Example of sbt.build:
name := "hello"
version := "1.0"
scalaVersion := "2.9.2"
resolvers += "twitter-repo" at "http://maven.twttr.com" libraryDependencies ++= Seq("com.twitter" % "finagle-core" ...
unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src/main/scala" )
unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "app" )

Example of build.scala:
lazy val defaultSettings =
buildSettings ++
Seq(
parallelExecution in Test := false,
fork in Test := true,
unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src/main/scala" )
)

Restart the OverOps daemon for the changes to take effect.

 

Ant

To attach source code in Ant:

  1. In the project's build.xml file, make sure the javac tag contains the following attributes: debug="true" debuglevel="source,lines,vars" Furthermore, in your jar tag add <fileset dir="src" /> to include the source files. Here's a sample Ant build.xml file
  2. Restart the OverOps daemon for changes to take effect.

 

Maven

To attach source code files in Maven:

  1. In order to package your source files add the following resources to your build tag:<resources> <resource> <directory>${project.build.sourceDirectory}</directory> </resource> <resource> <directory>${basedir}/src/main/resources</directory> </resource> </resources>Here's a sample Maven pom.xml file.
  2. Restart the OverOps daemon for changes to take effect.

 

Eclipse

To attach source code in Eclipse:

  1. From the Eclipse, right click the project and select Export -> JAR file.
  2. In the export window, select Export Java source files and resources.


    Attaching source code in Eclipse

  3. Restart the OverOps Collector for changes to take effect.

 

IntelliJ

To attach source code in IntelliJ:

  1. Open the File | Project Structure dialog.
  2. from the artifacts list, pick the Scala project .jar file.
  3. Click the green plus button and select your 'src' folder.
  4. Build the project.


    Attach source code in IntelliJ

  5. Restart the OverOps Collector for changes to take effect.

 

To create a new .jar in IntelliJ:

  1. Click the green plus and add a JAR artifact.
  2. Drag the compile output from the "Available elements" list to the JAR on the left.
  3. Add your source folder as described above.


    Creating a new .jar in IntelliJ

  4. Restart the OverOps Collector for changes to take effect.

 

Clojure

If you’re using Leiningen to manage your project, the sources are packed with your binaries. For the best OverOps experience, make sure the following options are used as part of project.clj:

:omit-sources false

:aot :all

Example project file:

(defproject guestbook "0.0.0"
  :dependencies []
  :min-lein-version "2.0.0"
  :source-paths ["src/clj"]
  :resource-paths ["resources"]
  :main helloworld.main
  ;; Making sure your original .clj files are present near the binaries so that OverOps can find and use them when showing snapshots in the webapp.
  :omit-sources false
  :profiles {:uberjar {
     ;; This makes your Clojure app compile ahead of time which helps OverOps understand which bytecode is running.
     :aot :all
     :uberjar-name "helloworld.jar"
     }
   }
 )

 

Attaching Source Folders

SaaS Users

Another method for viewing OverOps on your source code is attaching your source code directly on the machine with OverOps. This is a great method for Scala, for example. To do this, simply place a directory with your source code on the machine on which OverOps runs, and add the following startup argument to your JVM: -Dtakipi.sources.path=/your/source/dir/here For example:java -Dtakipi.sources.path=/opt/my-app/src -jar myApp.jar You may specify multiple directories, by separating the paths using ';' (Windows), or ':' (Linux / macOS):java -Dtakipi.sources.path=/opt/my-app/src:/opt/another-app/src/main/scala -jar myApp.jar

Restart the OverOps Collector for the changes to take effect.


Hybrid Users

  1. On the storage machine:

The sources folder is going to be relative to the storage main folder opt/takipi-storage/storageSources should be deployed with a version under a specific folder /opt/takipi-storage/storage/sources/v1/app1Any jar file should be exploded to source files/folders, as we can only detect source files (ending with .java/.clj/.cljs etc...) in the storage server.

2. On the agent machine:

Start the agent with the new remote sources path java -agentlib:TakipiAgent -Dtakipi.remote.sources.path="sources/v1/app1" -jar app.jarYou can add multiple folders with ":" separator.

 

Attaching Source Code for a Specific Event

OverOps enables you to load the source code file to a specific event, in case you decided not to attach it to the application.

To attach the source code to a specific event:

  1. From the OverOps dashboard, open the event.
  2. From the Error Analysis page, in the bottom left corner, click Load Source Code.



  3. Click Select file and browse for the source code file.
  4. When finished, click Done.

The source code is available for the event it was attached to only. 

Have more questions? Submit a request