Using Stackdriver Trace with Zipkin

This tutorial uses a Zipkin server to receive traces from Zipkin clients and forward those traces to Stackdriver Trace for analysis.

The Zipkin server is useful for two groups of people: developers who want to use Stackdriver Trace whose applications aren’t written in a language or framework that the official libraries yet support, and owners of applications that are already instrumented with Zipkin who either don’t want to run their own trace backend or want access to Stackdriver Trace’s advanced analysis tools.

This tutorial provides instructions for three different scenarios:

Using a container image to set up your server

A container image of the Stackdriver Trace Zipkin Collector is available on GitHub. This repository contains the Docker build definition and layers GCP support on the base Zipkin Docker image.

You can run this on your container host of choice.

To pull the image:

docker pull

You must also configure your Zipkin tracers.

Using a JAR on Google Compute Engine to set up your server

To configure the collector on Google Compute Engine, acquire the .jar file from Maven and run it on a new VM.

Create or select a project and enable billing

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Select or create a GCP project.

    Go to the Manage resources page

  3. Make sure that billing is enabled for your project.

    Learn how to enable billing

Create a Compute Engine instance

When creating your instance, we recommend the default Debian GNU/Linux image.

When prompted, select the Compute Engine Default Service Account. Custom service accounts will also work if they have been granted a project editor role.

  1. In the GCP Console, go to the VM Instances page.

    Go to the VM Instances page

  2. Click Create instance.
  3. Click Create to create the instance.

Run the script

Run the following script. If you're using a Google-provided Linux image, you can configure this as a startup script directly in the Cloud Console. This will automatically fetch the JAR from Maven.

set -e
set -v

# Talk to the metadata server to get the project id
PROJECT_ID=$(curl -s "" -H "Metadata-Flavor: Google")

apt-get update
apt-get install -yq openjdk-8-jre-headless

wget -O collector.jar ''

PROJECT_ID=$PROJECT_ID java -jar collector.jar

Configure the firewall

If the collector will be receiving telemetry from tracers hosted outside of Google Cloud Platform, configure your project's firewall to accept TCP traffic on port 9411.

Configure Zipkin tracers

Follow the instructions in the common Configure Zipkin tracers section.

Running your server outside of Google Cloud Platform

If you would like to build and run the collector outside of Google Cloud, such as on a VM on Amazon Elastic Cloud Compute or a physical server running on-premises:

Create or select a project

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Select or create a GCP project.

    Go to the Manage resources page

A billing account is not required, as the collector will not be running on Google resources.

Create a service account

To allow your service to authenticate to the Stackdriver Trace API:

  1. Create a service account.
    1. Ensure that the new service account has been granted a project editor role so that it can write data to the Trace API.
    2. Select Furnish a new private key and choose JSON.
    3. Save the JSON credentials file to a directory on the machine that will be running the collector service.

Build the code

  1. Download the latest code from the master branch of the Stackdriver Trace Zipkin Collector project on GitHub. This can be done in one of two ways:
  2. Build the code: mvn package
  3. Configure credentials by setting the GOOGLE_APPLICATION_CREDENTIALS and PROJECT_ID environment variables by running the following script within the repository's working directory. Replace the placeholder values with your own specific values:
    export GOOGLE_APPLICATION_CREDENTIALS="/path/to/credentials.json" PROJECT_ID="my_project_id"
  4. Run the generated JAR file: java -jar collector/target/collector-*.jar
    1. If desired, you can configure this jar to run upon system startup.

Configure your firewall

Configure your network configuration to allow TCP traffic on port 9411 to pass to the machine running the Zipkin collector.

If you'll be submitting traces from applications hosted outside of the firewall, note that Zipkin tracer to collector traffic is not encrypted or authenticated. Connections between the Stackdriver Trace Zipkin Collector and the Stackdriver Trace API are encrypted and authenticated, as are connections sourced from the Stackdriver Trace instrumentation libraries.

Configure Zipkin tracers

Follow the instructions in the common Configure Zipkin tracers section.

How to Configure Zipkin tracers

No matter how you host the Stackdriver Trace Zipkin Collector, you'll need to configure your Zipkin tracers to send data to it.

The collector can be referenced by its internal IP address, external IP address (if it will be receiving traces from applications hosted outside of Google Cloud Platform), or hostname. Each Zipkin tracer is configured differently - for example, to point a Brave tracer at a collector with the IP address, the following lines must be added to your Java codebase:

Reporter reporter = AsyncReporter.builder(OkHttpSender.create("")).build();
Brave brave = Brave.Builder("example").reporter(reporter).build()

Frequently asked questions

Q: What are the limitations?

This release has two known limitations:

  1. Zipkin tracers must support the correct Zipkin time and duration semantics.

  2. Zipkin tracers and the Stackdriver Trace instrumentation libraries can't append spans to the same traces, meaning that traces that are captured in one library won't contain spans for services instrumented in the other type of library. For example:

    Requests made to the Node.js web application will be traced with the Zipkin library and sent to Stackdriver Trace. However, these traces will not contain spans generated within the API application or for the RPC calls that it makes to the Database. This is because Zipkin and Stackdriver Trace use different formats for propagating trace context between services.

    For this reason we recommend that projects wanting to use Stackdriver Trace either exclusively use Zipkin-compatible tracers along with the Zipkin Collector, or use instrumentation libraries that work natively with Stackdriver Trace (like the official Node.js, Java, or Go libraries).

Q: Will this work as a full Zipkin server?

No, as the initial release only supports write operations.

Q: Can I use Stackdriver Trace to analyze my AWS, on-premises, or hybrid applications or is it strictly for services running on Google Cloud Platform?

Several projects already do this today! Stackdriver Trace will analyze all data submitted through its API, regardless of where the instrumented service is hosted, meaning that traces and spans collected from the Stackdriver Trace instrumentation libraries or through the Zipkin Collector can be used anywhere.

Was this page helpful? Let us know how we did:

Send feedback about...

Stackdriver Trace Documentation