Source Code in OverOps - Release 4.14.2 and above

Follow

Contents

Introduction

Integrating the Source Code Git Repository

Attaching Source Code Folders

Attaching Source Code for a Specific Event

Including Source Code in Binaries

 

Introduction

When you open an event in the Dashboard, OverOps displays the decompiled application bytecode and projects the runtime variable data onto it. With standard Java, the decompilation reflects the running source code (excluding original variable names, comments or annotations).

In order to display the missing data such as original variable names, comments or annotations,  OverOps requires that you attach the original source code. These methods are also necessary to display source code for non-Java languages running on the JVM (such as Scala, JRuby, Groovy, Clojure).

This procedure is necessary when using a code weaver (such as AspectJ) that expands your bytecode with large amounts of synthetic code.

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

There are four ways to display the source code in OverOps:

  • Integrating the source code Git repository
  • Attaching the source code folder to either the Collector (SaaS mode) or the Storage Server (Hybrid mode)
  • Attaching source code for a specific event
  • Including source code in binaries.

Integrating the Source Code Git Repository

This method automatically integrates the source code in OverOps by configuring access to the relevant Git repository.

To integrate the source code Git repository:

  1. From the collector.properties file, configure access to the Git repository:
    gitUser=<USERNAME>
    gitPassword=<PASSWORD>
  2. In the build process, add the following attributes to each relevant Jar's MANIFEST.MF file:
    • The URL to the Git Repository:
      Takipi-Git-Repo-Url: <GIT_REPO_URL>
      Example: https://github.com/alik-takipi/public-misc.git>
    • The Commit within the code: 
      Takipi-Git-Commit: <COMMIT_ID | FULL_BRANCH_NAME | FULL_TAG_NAME>
    • The Prefix of the subfolder within the repository:
      Takipi-Git-Prefix: <JAR_SUBFOLDER_IN_REPO>

Attaching Source Code Folders

SaaS Mode

For SaaS users, you can also view the source code by attaching it directly to the host running OverOps.

To attach the source code to the host running OverOps:

  1. Copy the source code directory to the host running OverOps, and add the following argument to the JVM:
    -Dtakipi.sources.path=/your/source/dir/here 
    For example: 
    java -Dtakipi.sources.path=/opt/my-app/src -jar myApp.jar 
    Specify multiple directories, by separating their paths using ';' (Windows),
    or ':' (Linux/macOS):

    java -Dtakipi.sources.path=/opt/my-app/src:/opt/another-app/src/main/scala -jar myApp.jar
  2. For the changes to take effect, restart the OverOps Collector.


Hybrid Mode

In Hybrid mode, the source code can be added to the Storage Server.

To attach the source code to the Storage Server:

  1. In the Storage Server, copy the source code folder under the main storage folder, in a version-specific folder: 
    /opt/takipi-storage/storage/sources/<VERSION>/<APPLICATION>
    Any Jar file should be extracted to source files/folders, as only source files (ending with .java/.clj/.cljs etc...) can be detected by the Storage Server.
  2. Start the Agent with the new remote sources path:
    java -agentlib:TakipiAgent -Dtakipi.remote.sources.path="sources/<VERSION>/<APPLICATION>" -jar app.jar
    Example:
    java -agentlib:TakipiAgent -Dtakipi.remote.sources.path="sources/v1/app1" -jar app.jar
    You can add multiple folders with ":" separator.

Attaching Source Code for a Specific Event

If you decide not to attach the source code file to the application, you can load it to a specific event only.

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.

Including Source Code in Binaries

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:

  1. Add the following line to the build.sbt file:
    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "app" )
  2. In a Maven-like project structure, replace "src" with "src/main/scala" and "src/main/java":
    unmanagedResourceDirectories in Compile <+= baseDirectory( _ / "src/main/scala" )
  3. For changes to take effect, restart the OverOps Collector.

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" )
)

Ant

To attach source code in Ant:

  1. In the project's build.xml file, verify that the javac tag contains the following attributes: debug="true" debuglevel="source,lines,vars"
  2. In the Jar tag, add <fileset dir="src" /> to include the source files.
    For sample Ant build.xml file, click here.
  3. For changes to take effect, restart the OverOps Collector.

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. For changes to take effect, restart the OverOps Collector.

Eclipse

To attach source code in Eclipse:

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

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

IntelliJ

To attach source code in IntelliJ:

  1. From File, click Project Structure.
  2. From the artifacts list, pick the Scala project JAR file.
  3. Click and select Directory Content.
  4. From the Directory Content, choose the relevant src folder.
  5. Check the Build on make checkbox.
  6. Click Apply to build the project.

  7. For changes to take effect, restart the OverOps Collector.

To create a new JAR in IntelliJ:

  1. From Artifacts, click the green plus and select a JAR artifact.
  2. Drag the compile output from the Available Elements list to the proj.jar.
  3. Add the source folder as described above.

  4. For changes to take effect, restart the OverOps Collector.
     

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"
     }
   }
 )

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.