opentracing

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2019 License: BSD-3-Clause Imports: 13 Imported by: 1

README

This listener adds OpenTracing instrumentation at Flogo engine level and tracers implementations (Zipkin over HTTP or Kafka, Jaeger) to send traces generated by flows and activities to corresponding collectors.

For an introduction of concepts, read the OpenTracing documentation.

Installation

Minimum required version of Flogo: 0.9.0

Flogo Web

This listener is not available yet with the Flogo Web UI.

Flogo CLI
Install the listener

The listener must be installed once for an application. Basically it's just a matter of adding the right package import in the imports.go file. This is performed seamlessly with the Flogo CLI.

In the directory of a Flogo project (with a flogo.json file), run:

flogo install github.com/square-it/flogo-opentracing-listener@v0.0.2
Build and run

Finally, build the application:

flogo build -e

The binary is ready to be run in ./bin directory.

Usage

To use this listener once it is installed, no modification of source code is required. Instead, it is only required to define an application-level configuration and to run a collector.

Configuration

Currently, all flows of an application have the same OpenTracing configuration set using environment variables.

For instance, to enable collection of traces by a Zipkin collector over HTTP transport:

export FLOGO_OPENTRACING_IMPLEMENTATION=zipkin
export FLOGO_OPENTRACING_TRANSPORT=http
export FLOGO_OPENTRACING_ENDPOINTS=http://127.0.0.1:9411/api/v1/spans

Replace 127.0.0.1 by the actual IP of the Zipkin collector.

Environment variables reference
Environment variable Possible values Description
FLOGO_OPENTRACING_IMPLEMENTATION zipkin, jaeger Choose which implementation of OpenTracing tracer to use.
Zipkin and Jaeger are available
FLOGO_OPENTRACING_TRANSPORT http, kafka(for zipkin only) http is supported by both Zipkin and Jaeger
kafka is only supported by Zipkin
FLOGO_OPENTRACING_ENDPOINTS http://127.0.0.1:9411/api/v1/spans
(zipkin over HTTP)
10.1.0.1:29092,10.1.0.2:29092,10.1.0.3:29092
(zipkin over Kafka)
A comma-separated list of endpoints
Collectors

This listener can send traces to the following collectors:

For test purposes, here are quick methods to get collectors up and running locally, using Docker.

Zipkin
HTTP transport

To start a single-node instance of a Zipkin server with HTTP transport, run:

docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin
Kafka transport

For Kafka transport, start a single-node instance of a Kafka server with its Zookeeper:

mkdir -p /tmp/kafka
cd /tmp/kafka
curl -fsSL https://raw.githubusercontent.com/confluentinc/cp-docker-images/5.0.0-post/examples/kafka-single-node/docker-compose.yml -o docker-compose.yml
# uncomment if using Docker Machine
# sed -i "s|localhost:|$(docker-machine ip $(docker-machine active)):|" docker-compose.yml
docker-compose up -d

Then start a single-node instance of a Zipkin server with Kafka transport by running:

docker run --name zipkin -d -p 9411:9411 -e KAFKA_BOOTSTRAP_SERVERS=127.0.0.1:29092 openzipkin/zipkin

If using Docker Machine, run instead:

docker run --name zipkin -d -p 9411:9411 -e KAFKA_BOOTSTRAP_SERVERS=$(docker-machine ip $(docker-machine active)):29092 openzipkin/zipkin
Jaeger
HTTP transport

To start a single-node instance of a Jaeger server with HTTP transport, run:

docker run -d --name jaeger \
  -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
  -p 5775:5775/udp \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 14268:14268 \
  -p 9411:9411 \
  jaegertracing/all-in-one

Documentation

Index

Constants

View Source
const (
	EnvVarsPrefix        = "FLOGO_OPENTRACING_"
	EnvVarImplementation = EnvVarsPrefix + "IMPLEMENTATION"
	EnvVarTransport      = EnvVarsPrefix + "TRANSPORT"
	EnvVarEndpoints      = EnvVarsPrefix + "ENDPOINTS"
)

Variables

This section is empty.

Functions

func InitTracer

func InitTracer(serviceName string, openTracingConfig *Config) (*opentracing.Tracer, error)

Types

type Config

type Config struct {
	Implementation string   `json:"implementation"`
	Transport      string   `json:"transport"`
	Endpoints      []string `json:"endpoints"`
}

type OpenTracingListener

type OpenTracingListener struct {
	// contains filtered or unexported fields
}

func (*OpenTracingListener) HandleEvent

func (otl *OpenTracingListener) HandleEvent(evt *event.Context) error

func (*OpenTracingListener) Name

func (otl *OpenTracingListener) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL