Get Started With Seagence

Getting started with Seagence is very easy.

  1. Create a Seagence account
  2. Connect your application

That’s it. When defects occur Seagence will alert.

Pattern

Create a Seagence account

Seagence works with Java 8 and above, Tomcat/Wildfly/Undertow/Jetty/Weblogic and any servlet container.

Click “START FREE TRIAL” button at the top right corner

  1. Register on app.seagence.com.
  2. Login with new root user name/password (Note down root user name which you will need at a later step).
  3. After successful login, go to Settings tab, click “Download SGAgent” to download SGAgent.zip.
  4. In the same Settings tab, click “API Token” and copy displayed API Token.
  5. Follow instructions below.

Connect your Application

Step1: Unzip downloaded SGAgent.zip file to find SGAgent.jar. Copy the SGAgent.jar file into a directory of your choice.

Step2: Create an empty properties file sgagent.properties in the same directory where SGAgent.jar is copied. Then copy the below properties into the file.

machineName=[Assign a name to machine/node where your application is running]
applicationName=[Name of the application being monitored]
userName=[Root user name you provided at the time of registration]
seagenceWebURL=https://app.seagence.com/SeagenceWeb
containerName=[Tomcat | Weblogic | Jetty | Undertow | use Undertow for Wildfly as well | AnyServletContainer for any other servlet container
]

apiToken=[API Token copied from Settings tab -> API Token]

Contents of a sample sgagent.properties file are below.

machineName=foonode
applicationName=foo-app
userName=foouser
seagenceWebURL=https://app.seagence.com/SeagenceWeb
containerName=Tomcat
apiToken=wvLI-jTUv-Atlh-ASPb-zDLe

Step3: Attach SGAgent to your application

Use below JVM options to attach SGAgent.jar to your application.

Add this to JAVA_OPTS.
-javaagent:path-to-SGAgent.jar=”propertyfile=path-to-sgagent.properties”

For Example: -javaagent:C:/seagence/SGAgent.jar=”propertyfile=C:/seagence/sgagent.properties”

For Docker Image

If you are using Docker image, add below instructions to your dockerfile after Step2 above. Below instructions are for Tomcat, so if you are using another application server, refer to your vendor’s documentation.

RUN mkdir -p /usr/local/tomcat/seagence
ADD /SGAgent.jar /usr/local/tomcat/seagence/SGAgent.jar
ADD /sgagent.properties /usr/local/tomcat/seagence/sgagent.properties
ENV JAVA_OPTS="$JAVA_OPTS -javaagent:/usr/local/tomcat/seagence/SGAgent.jar=propertyfile=/usr/local/tomcat/seagence/sgagent.properties"

With that setup completes. Bring your application up and start using. SGAgent will post collected monitoring data to SeagenceWeb in the background.

Pattern

Get a feeling of how Seagence works

Having SGAgent attached, let’s see how Seagence works. Know that Seagence is not just an error tracking/monitoring tool. Seagence’s main feature is defect and root cause detection in realtime. While Seagence’s error tracking capabilities can be found on SeagenceWeb portal (Seagence automatically records all exceptions and errors thrown by your application, you don’t need to post them) here we will demonstrate Seagence’s main feature i.e. detecting defects in realtime. For this we will do a small exercise in Dev environment. Select a simple GET (or POST) operation in your application that invokes some business function. Something like one that fetches data from DB or any other simple GET operation (select a simple operation because you will need to invoke this operation a 100 times for Seagence to collect enough data. In production you will have huge number of users using the application, so data collection is not a problem in production).

Introduce a defect

The best way to get the hang of how Seagence works is by introducing a defect in the selected GET operation and see how Seagence detects it. We introduce the defect in dev environment only and will remove it after the exercise. To do that add below code either in your Controller class or any other class (before business rules/logic starts executing when the GET operation is invoked) as shown below.

Note: For the sake of argument can it be said that you introduced this defect unknowingly while fixing another defect. And when Seagence finds it, can it also be said that Seagece found an unknown defect?

Define a static field variable

     public static int counter = 0;

and then add these below lines at the start of the method body of Controller class or other class where business logic starts executing.

     counter++;
     if(counter == 10 || counter == 20 || counter == 30 || counter == 40 || counter == 50 || counter == 60 || counter == 70 || counter == 80 || counter == 90 || counter == 100) {
          throw new NullPointerException();
     }

There is no rocket science here, we are just telling the selected GET operation to fail 10 times (Seagence’s Think Time). Now invoke the operation few more than 100 times and we know that few of those invocations will fail.

 
Detecting the defect

Now that Seagence collected enough data it is time to create the baseline. Seagence automatically creates incremental baseline at regular interval. Instead of waiting that long, you create the baseline by login into SeagenceWeb, go to Baseline tab and click “Create Baseline”. At this time you will receive alert for failed invocations (one alert per failure cluster, with a count of failures. A cluster is a group of similar invocations), so now check your inbox. Also check Clusters tab on SeagenceWeb for more debug information.

Alert not received? Check if enough data is collected. Click “View Data” link in Baseline tab which will list amount of data collected per endpoint. Is the data size greater than 100 for our GET operation? If not invoke the operation few more times, create Baseline again and see that alert is sent for failed invocations.

You will find more debug information on SeagenceWeb, under Clusters tab.

Still have not received alert? You might need some help, please post your question to info@seagence.com.

 

Now let's dive little deeper

The earlier defect we introduced either results in HTTP 500 error status or uncaught exception. Other monitoring solutions can also detect such failures. However Seagence can also detect much difficult defects, for example the ones caused by swallowed or caught exceptions or ones disguised in 200 response codes. Now we will swallow the exception and see how Seagence detects it. To keep things simple let’s start afresh. Go to Settings tab on SeagenceWeb and delete all data by clicking “Delete Data” and restart your application. Application restart is necessary because when you “Delete Data”, some contextual information is also lost.

If you swallow the exception like below

   try {
     counter++;
     if(counter == 10 || counter == 30 || counter == 40 || counter == 50 || counter == 60 || counter == 70 || counter == 80 || counter == 90) {
          throw new NullPointerException();
     }
   } catch(Exception exc){}

it will have no impact on your operation and the invocation will continue successfully. So allow the exception to make some impact on the business functionality by jumping few instructions so that it fails and then swallow it like below. A swallowed exception leaves no trace in the log hence debugging a defect due to swallowed exception is much difficult.

   try {
     counter++;
     if(counter == 10 || counter == 30 || counter == 40 || counter == 50 || counter == 60 || counter == 70 || counter == 80 || counter == 90) {
          throw new NullPointerException();
     }
     ...
     ...
     ...
   } catch(Exception exc){}

Now invoke the GET operation 100 times like earlier and see that Seagence finds defects caused by swallowed exceptions as well including root cause. For technical support please post your questions to info@seagence.com.

Note: Do not forget to remove the defect introduced.

Pattern

Say no to setting alert rules, thresholds and configuring exceptions

All this while notice that you have not input any knowledge or error configurations in Seagence like

1) Alert rule settings
2) Threshold settings
3) A suspicious exception configuration

Irrespective of any of this input, Seagence finds all failures and defects including defects due to swallowed exceptions, gracefully handled exceptions etc., with root cause in real time as they occur in production.