Language Integration

Based on the language of your application, please find the corresponding languages to begin language integration.

Language
Go
Python
Python + Django
Java

Go Client

This utility can be plugged into your go application to collect vital data about your code's behavior so that Mindsight can help you write better code more safely, without significantly impacting your application performance.

Step 1. Go Installation Package

You can install this package the standard way you install Go packages in your environment:

go get github.com/MindsightCo/go-mindsight-collector

Step 2. Go Configuration Setup

Before you get started, make sure you set up the Mindsight Agent, which is required to send diagnostic data to Mindsight's backend for further analysis.

Let's assume for the example below that your agent will be listening at http://localhost:8000.

To start collecting data from your application, do the following your application (main is probably where you want to do this):

import (
  "context"
  "github.com/MindsightCo/go-mindsight-collector"
)

... // in a function, such as main:
ctx := context.Background()
err := collector.StartMindsightCollector(ctx,
    collector.OptionProject("My-project"),
    collector.OptionEnvironment("production"),
    collector.OptionAgentURL("http://localhost:8000/samples/"),
    collector.OptionWatchPackage("github.com/you/your-package"),
    collector.OptionWatchPackage("github.com/you/other-package"))

The hotpaths for the packages specified via OptionWatchPackage will be measured periodically and reported to the Mindsight backend via the Mindsight Agent.

Step 3. Optional Fine Tuning Configuration

Sampling Frequency Control You can control how frequently samples are sent to the Agent via collector.OptionCacheDepth().

Vendor Packages By default, vendored packages within the set of watched packages are not sampled. If you would like to include vendored packages in the data, set collector.OptionIncludeVendor().

Cancellation Request Feel free to provide your own context according to your needs. The collector will halt if the context receives a cancellation request [i.e. it respects ctx.Done()].

Python Client

Unobstrusively detects the most common running stacks in your Python program, for use with the Mindsight product.

This utility can be plugged in to your Python application to collect vital data about your code's behavior so that Mindsight can help you write better code more safely.

Exceptions & Notes

This utility is not designed to work with web frameworks that utilize multithreading like Django and Flask. If you are using one of those frameworks, use the appropriate data collector: Mindsight Django Collector

Step 1. Installation

To install this utility for use in your program:

pip install mindsight-sampler

Step 2. Python Configuration

Before proceeding, make sure you have setup your Mindsight account. Contact us if you need help.

To use this utility to observe your program and send data to Mindsight:

Initialize the sampler in your code:

import  sampler
sampler.start("http://localhost:8000", "My Project", ["my.module", "my.other_module"], environment="production") 

Let's explain each parameter:

Python + Django Client

This utility can be plugged in to your Django application to collect vital data about your code's behavior so that Mindsight can help you write better code more safely.

Step 1. Installation

The latest production-ready version of this utility is distributed via PyPI and can be installed as follows:

pip install mindsight-django-hotpath

Step 2. Configuration

This utility runs as a Django middleware in your application. To configure it add the following to your settings.py file:

import  mindsight_django
# rest of your configuration
# Mindsight collector config
# URL where you are running the Mindsight Agent
MINDSIGHT_AGENT_URL = 'http://localhost:8000'
# Name of your project as configured in Mindsight
MINDSIGHT_PROJECT = 'my-project-name'

The MINDSIGHT_AGENT_URL setting is the URL of the Mindsight Agent, which is required to send diagnostic data to Mindsight's backend for further analysis. If this setting is omitted, Mindsight's middleware will be disabled by the Django runtime.

The MINDSIGHT_PROJECT setting is the name of your project you've configured in the Mindsight service. If this setting is omitted, Mindsight's middleware will be disabled by the Django runtime.

Finally, register Mindsight as a Django middleware in your settings.py file:

MIDDLEWARE = [
  # ... other middlewares
  'mindsight_django.Middleware',  # should be the last middleware
]

To ensure the highest quality data to better analyze your application with, the Mindsight middleware should be the last one to run.

Step 3. Fine Tuning Configuration

The Mindsight middleware has additional configuration options to fine-tune its behavior. The defaults should be desirable for most applications, but they can be tweaked if needed:

Options

Java Client

Before getting started, please ensure you have set up the Mindsight Agent.

Step 1. Download Latest Release

The Mindsight Java client is packaged and released as a single jar file. The latest version can be downloaded from its release page.

Step 2. Run Application With Java Agent

The Mindsight Java Client uses the -javaagent feature of the JVM to automatically instrument your application and inspect your run time. Below is an example of how you might invoke your application on the command line:

MINDSIGHT_AGENT=http://localhost:8000 MINDSIGHT_PROJECT=Todo MINDSIGHT_MODULES=com.example java -javaagent:target/mindsight-client-1.0.1-all.jar=reporter=io.mindsight.client.JavaClient,sampleInterval=100 -cp target/mindsight-client-1.0.1-all.jar:target/TodoDemo-0.0.1-SNAPSHOT.war -jar target/TodoDemo-0.0.1-SNAPSHOT.war

Explanation of Options

Several environment variables are needed to configure the Mindsight Java Client:

Finally, the -javaagent flag also has the following arguments: