Based on the language of your application, please find the corresponding languages to begin language integration.
|Python + Django|
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
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
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
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
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:
First, set up and run the Mindsight Agent (the binary download is easy and recommended).
For the purpose of this example, we will assume your agent is running at http://localhost:8000
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:
- URL to your running Mindsight Agent
"My Project"-The name of your project in your Mindsight account that tracks this application
- The Python modules that you want to have monitored by Mindsight
- Each element of this array is a prefix, so ["my"] will watch those 2, plus any others under my.
- Name of the environment the application is running in
- This parameter is optional
- You can name your environments however you like
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
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'
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.
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
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:
- Deployment environment your program is running in. Change this if you have multiple environments you want to measure independently.
- Number of measurements to cache before sending data to the Mindsight Agent.
- Amount of time (seconds) to wait for a response from the Mindsight Agent when sending measurements. An error will be logged in case of communication failure with the agent.
- Probability that a request will be intercepted and analyzed by Mindsight.
- Simulates the behavior of a sampling profiler that interrupts the application every 10ms.
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:
- Comma-separated list of the packages you want to analyze
- i.e. If your application is in
com.example.todo, this variable can simply be set to
- The name of your project in your Mindsight account (how we distinguish between different applications in one account)
- URL to the Mindsight Agent
- Comma-separated function names (fully qualified with package) of "entry points" such as main functions in wait loops that should be excluded from the analysis
- Can be omitted if your application has no such functions
-javaagent flag also has the following arguments:
- Path to the jar containing the Mindsight Java client
- Must be set to
- Must be set to
- sets the data collection interval to every N ms