🚀 Go Distributed Tracing & Metrics Sensor for Instana
Clone or download
doertedev and pglombardo Support setting the hostname of the agent via environment variable. (#54
)

* Support setting the hostname of the agent via environment variable.

* Apply the same logic for the port
Latest commit 493edb4 Jul 25, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example Inject for response headers. Oct 10, 2017
.gitignore Add debug.test binaries Apr 12, 2017
.travis.yml Update list of tested Go versions May 4, 2018
EventAPI.md Grammar & language Jul 18, 2017
LICENSE.md initial Nov 25, 2016
README.md fix MD syntax May 4, 2018
agent.go Support setting the hostname of the agent via environment variable. (#54 Jul 25, 2018
context.go Store IDs as signed integers Apr 24, 2017
eum.go reuse http client, go fmt May 4, 2018
eum.js fix test for eum snippet Jan 18, 2018
eum_test.go Better test strategy since iterating maps is random order May 4, 2018
event.go Linter happiness & peace ☮️ Aug 3, 2017
event_internal_test.go Basic starter set of Event API tests. Jul 18, 2017
fsm.go Support setting the hostname of the agent via environment variable. (#54 Jul 25, 2018
json_span.go Improved error reporting (with tests) Aug 3, 2017
log.go Linter happiness & peace ☮️ Aug 3, 2017
meter.go Report Go version in snapshot. Sep 29, 2017
options.go Restore Options members; rename using 'default' Apr 28, 2017
propagation.go Delete pre-existing header keys Sep 24, 2017
propagation_test.go Update tests to follow recorder changes. Oct 10, 2017
recorder.go Force transmission as a goroutine Feb 27, 2018
recorder_internal_test.go Only report custom service name from tracer (if configured) Sep 27, 2017
recorder_test.go Update tests to follow recorder changes. Oct 10, 2017
sensor.go If INSTANA_DEV env var; force Debug log level Oct 9, 2017
span.go Only report custom service name from tracer (if configured) Sep 27, 2017
span_test.go Update tests to follow recorder changes. Oct 10, 2017
tracer.go Unify Span management Apr 28, 2017
tracer_options.go Switch to int64 for IDs Apr 24, 2017
tracer_test.go Update tests to follow recorder changes. Oct 10, 2017
util.go Fix error messages for linter May 19, 2017
util_internal_test.go Add 10k loop to validate id -> header -> back to id validation May 19, 2017

README.md

golang banner 2017-07-11

Instana Go Sensor

golang-sensor requires Go version 1.7 or greater.

The Instana Go sensor consists of two parts:

Build Status OpenTracing Badge

Sensor

To use sensor only without tracing ability, import the instana package and run

instana.InitSensor(opt)

in your main function. The init function takes an Options object with the following optional fields:

  • Service - global service name that will be used to identify the program in the Instana backend
  • AgentHost, AgentPort - default to localhost:42699, set the coordinates of the Instana proxy agent
  • LogLevel - one of Error, Warn, Info or Debug

Once initialized, the sensor will try to connect to the given Instana agent and in case of connection success will send metrics and snapshot information through the agent to the backend.

OpenTracing

In case you want to use the OpenTracing tracer, it will automatically initialize the sensor and thus also activate the metrics stream. To activate the global tracer, run for example

ot.InitGlobalTracer(instana.NewTracerWithOptions(&instana.Options{
	Service:  SERVICE,
	LogLevel: instana.DEBUG}))

in your main function. The tracer takes the same options that the sensor takes for initialization, described above.

The tracer is able to protocol and piggyback OpenTracing baggage, tags and logs. Only text mapping is implemented yet, binary is not supported. Also, the tracer tries to map the OpenTracing spans to the Instana model based on OpenTracing recommended tags. See simple example for details on how recommended tags are used.

The Instana tracer will remap OpenTracing HTTP headers into Instana Headers, so parallel use with some other OpenTracing model is not possible. The Instana tracer is based on the OpenTracing Go basictracer with necessary modifications to map to the Instana tracing model. Also, sampling isn't implemented yet and will be focus of future work.

Events API

The sensor, be it instantiated explicitly or implicitly through the tracer, provides a simple wrapper API to send events to Instana as described in its documentation.

To learn more, see the Events API document in this repository.

Examples

Following examples are included in the examples folder:

  • ot-simple/simple.go - Demonstrates basic usage of the tracer
  • webserver/http.go - Demonstrates how http server and client should be instrumented
  • rpc/rpc.go - Demonstrates a basic RPC service
  • event/ - Demonstrates usage of the event API