Skip to content

Deployment on Hosts


Install DataKit Agent

Before performing link data analysis for systems and applications, you need to deploy Guance DataKit collector on each target host to collect necessary tracing data.

Enable DDTrace Collector

DDTrace is used to receive, process, and analyze Tracing protocol data. Run the following command to enable the DDTrace collector. For other third-party tracing collector configurations, refer to Integration.

cp /usr/local/datakit/conf.d/ddtrace/ddtrace.conf.sample /usr/local/datakit/conf.d/ddtrace/ddtrace.conf

After configuration is complete, restart DataKit:

datakit service -R

Select Language

Java

Install dependencies:

wget -O dd-java-agent.jar 'https://static.guance.com/dd-image/dd-java-agent.jar'

Run the application:

You can run your Java code through various methods, such as IDE, Maven, Gradle, or directly via the java -jar command. The following starts the application using the java command:

java \ 
    -javaagent:/path/to/dd-java-agent.jar \ 
    -Ddd.logs.injection=true \ 
    -Ddd.agent.host=<YOUR-DATAKIT-HOST> \ 
    -Ddd.trace.agent.port=9529 \ 
    -jar path/to/your/app.jar

Parameter configuration:

  1. service.name: Service name;
  2. env: Environment information of the application service;
  3. version: Version number;
  4. Set sampling rate: After enabling, it can reduce the actual amount of generated data; the range is from 0.0(0%) ~ 1.0(100%);
  5. Collect Profiling data: After enabling, you can see more runtime information about the application;
  6. Enable JVM metrics collection: Requires enabling the statsd collector simultaneously.

For more parameter configurations, refer to here.

Python

Install dependencies:

pip install ddtrace

Run the application:

You can run your Java code through various methods, such as IDE, Maven, Gradle, or directly via the java -jar command. The following starts the application using the java command:

DD_LOGS_INJECTION=true \ 
DD_AGENT_HOST=localhost \ 
DD_AGENT_PORT=9529 \ 
ddtrace-run python my_app.py

Parameter configuration:

  1. service.name: Service name;
  2. env: Environment information of the application service;
  3. version: Version number;
  4. Set sampling rate: After enabling, it can reduce the actual amount of generated data; the range is from 0.0(0%) ~ 1.0(100%);
  5. Collect Profiling data: After enabling, you can see more runtime information about the application;
  6. Enable Python metrics collection: Requires enabling the statsd collector simultaneously.

For more parameter configurations, refer to here.

Golang

Install dependencies:

go get gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer

Run the application:

You can run your Java code through various methods, such as IDE, Maven, Gradle, or directly via the java -jar command. The following starts the application using the java command:

package main 

import ( 
   "io/ioutil" 
   "os" 
   "time" 
   httptrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/net/http" 
   "gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer" 
) 

func main() { 
  tracer.Start( 
  ) 
  defer tracer.Stop() 
  // Create a traced mux router
  mux := httptrace.NewServeMux()
  // Continue using the router as you normally would.
  mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
    time.Sleep(time.Second)
    w.Write([]byte("Hello World!"))
  })
  if err := http.ListenAndServe(":18080", mux); err != nil {
    log.Fatal(err)
  }
}

Parameter configuration:

  1. service.name: Service name;
  2. env: Environment information of the application service;
  3. version: Version number;
  4. Set sampling rate: After enabling, it can reduce the actual amount of generated data; the range is from 0.0(0%) ~ 1.0(100%);
  5. Collect Profiling data: After enabling, you can see more runtime information about the application.

For more parameter configurations, refer to here.

Node.JS

C++

PHP

Feedback

Is this page helpful? ×