Distributed Tracing

This topic describes how to leverage Distributed Tracing in your GigaSpaces cluster to identify latency issues.

Overview

Distributed tracing is quickly becoming a must-have component in the tools that organizations use to monitor their complex, microservice-based architectures. This helps engineers to pinpoint errors and identify performance bottlenecks.

GigaSpaces monitoring, part of the GigaOps Stack, includes Zipkin, a distributed tracing system that gathers timing data to enable troubleshooting latency issues in the system. This enables more effective performance tuning.

OpenTracing is a vendor-agnostic API for tracing and allows users to instrument their own services or libraries for distributed tracing.

For more information, view https://opentracing.io/docs/overview/

Tracing with GigaSpaces

Proxy-Side Tracing

GigaSpaces allows its users to trace their code by using OpenTracing spans in the proxy side.

In order to turn tracing on, you must configure a Tracer and register it with the GlobalTracer.registerIfAbsent method provided by the OpenTracing library. An example of such a Tracer is ZipkinTracer that reports the traces to a Zipkin server.

Every synchronous method in the GigaSpaces API will add a span to the active span if it exists. When the span is finished it is reported to the tracing endpoint (e.g. Zipkin).

The following example assumes that a Tracer and GigaSpaces proxy are defined. It creates a new span in the user’s code and calls the readMultiple method that adds a new span to the lifecycle of the flow:

// define Tracer and GigaSpaces proxy
 GlobalTracer.registerIfAbsent(tracer);
 io.opentracing.Span span = tracer.buildSpan("FirstSpan").start();
 gigaSpaces.readMultiple(new Person());
 span.finish();

 

Zipkin Built-In tracer

GigaSpaces provides a built-in bean com.gigaspaces.tracing.ZipkinTracerBean that can be used to send the traces to Zipkin as the tracing endpoint. This bean will register a GlobalTracer that can be used by the user’s code. Same GlobalTracer will be used in the GigaSpaces proxy for the synchronous methods.

@Bean
 public ZipkinTracerBean tracerBean() {
     return new ZipkinTracerBean("GatewayService")
         .setZipkinUrl("http://zipkin.company.com")
         .setStartActive(true);
 }

This bean is part of the xap-reporter module. To use it you need to add it to your processing unitClosed This is the unit of packaging and deployment in the GigaSpaces Data Grid, and is essentially the main GigaSpaces service. The Processing Unit (PU) itself is typically deployed onto the Service Grid. When a Processing Unit is deployed, a Processing Unit instance is the actual runtime entity. jar file with its dependencies.


<dependency>
    <groupId>org.gigaspaces</groupId>
    <artifactId>xap-reporter</artifactId>
    <version>15.2.0</version>
</dependency>
 

The screenshot below shows a “trace” of data sampled by Zipkin of multiple microservices running on a GigaSpaces distributed cluster:

 

 

 

Additional Resources

Microservices example with OpenTracing enabled