• 16 May 2022
  • 2 Minutes to read


Traceable’s Go module is based on OpenTelemetery and enhances the spans within a Trace with security-focused attributes. Traceable’s module can capture all the traffic that flows through your application including request and response headers along with the body of the request and response.


Supported Frameworks

Net HTTP net/httpNet Http net/http
GRPC Server google.golang.org/grpcGRPC Client google.golang.org/grpc
Gorilla Mux github.com/gorilla/muxSQL database/sql

Download and configure

# go get -u github.com/hypertrace/goagent

Configure Go module

You can configure Traceable’s Go module with a few lines as shown below. Following is a snippet with only a few configurations in the main.go file.

// loads the config from the config file tbd.json and env vars
cfg := config.Load()

// overrides statically the service name
cfg.ServiceName = config.String("myservice")
cfg.DataCapture.HTTPHeaders.Request = config.Bool(true)

 You can define the configuration variables in a JSON or YAML file, for example, config.yml. Alternatively, you can use environment variables to define the configuration variables or in the code as shown above. In the above snippet:

  • myservice  is the name of the service with which you would want it to be identified on Traceable’s Dashboard 
  • DataCapture.HTTPHeaders.Request is set to true. This captures the HTTP request headers. 

You can overwrite the location of the configuration JSON or YAML file by providing the path in the environment variable HT_CONFIG_FILE. The path of the configuration file can also be set in the code as shown in the snippet below:

// loads the config from the specified file and env vars
cfg := config.LoadFromFile("path/to/config.yml")

 The following table lists the environment variables. The environment variable can also be used to overwrite the default values. For example, you can set the environment variable to HT_DATA_CAPTURE_HTTP_HEADERS_RESPONSE=false to overwrite the value set in the configuration file or through the code. To check the entire list of environment variables, refer to the Github link.

Environment variableDescription
HT_SERVICE_NAMEIdentifies the service or process on Traceable’s dashboard.
HT_REPORTING_ADDRESSThe address of the collector where traces are reported, for example, api.traceable.ai
HT_REPORTING_SECUREWhen true, connect to endpoints over TLS.
HT_REPORTING_TOKENYour token to access Traceable API. You can generate this token from Traceable’s onboarding page or reach out to Traceable’s support team for generating the token.
HT_REPORTING_OPA_ADDRESSThe address OPA host to fetch the blocking rules, for example, http://opa.traceable.ai:8181/
HT_REPORTING_OPA_POLL_PERIOD_SECONDSThe poll period in seconds to query the OPA service.
HT_DATA_CAPTURE_HTTP_BODY_REQUESTWhen set to true, capture the body of the HTTP request
HT_DATA_CAPTURE_HTTP_BODY_RESPONSEWhen set to true, captures the body of the HTTP response
HT_DATA_CAPTURE_HTTP_HEADERS_REQUESTWhen set to true, captures the header of the HTTP request
HT_DATA_CAPTURE_HTTP_HEADERS_RESPONSEWhen set to true, captures the header of the HTTP response
HT_DATA_CAPTURE_RPC_METADATA_REQUESTWhen set to true, captures the RPC metadata of the request
HT_DATA_CAPTURE_RPC_METADATA_RESPONSEWhen set to true, captures the RPC metadata of the response
HT_DATA_CAPTURE_RPC_BODY_REQUESTWhen set to true, captures the RPC body of the request
HT_DATA_CAPTURE_RPC_BODY_RESPONSEWhen set to true, captures the RPC body of the response

Sample YAML file

Following is a sample YAML file to configure the various values like collector and OPA address. You can configure based on your environment’s requirement.

serviceName: REPLACE_ME
  endpoint: http://REPLACE_ME:9411/api/v2/spans 
  secure: true
  endpoint: http://REPLACE_ME:8181/
  pollPeriodSeconds: 30
    request: true
    response: true
    request: true
    response: true
    request: true
    response: true
    request: true
    response: true

 The configuration default values are defined in the defaults.go file.

Verify deployment

To verify the deployment of the Go agent, log into your Traceable Dashboard and click on Services. If the deployment was successful, you will see your service listed under the Name column.

Was this article helpful?

What's Next