Using Honeycomb For Logging And Event Tracking With CloudBees CodeShip Pro

3 minute read

About Honeycomb

Honeycomb lets you collect and track data and events for debugging and trend analysis. During your continuous deployment workflow with CloudBees CodeShip Pro, you can use Honeycomb to log information related to your deployments or tests.

By using Honeycomb you can more easily track, troubleshoot and debug your applications.

Their documentation does a great job of providing more information, in addition to the setup instructions below.

CloudBees CodeShip Pro

Setting Your Team Write Key

You will need to add your Honeycomb Team Write Key to your encrypted environment variables that you encrypt and include in your codeship-services.yml file.

Sending Events And Markers

Next, you will need to add your Honeycomb API calls to a new script, placed in your repository, that you will call from your codeship-steps.yml file. For example:

curl https://api.honeycomb.io/1/batch/Dataset%20Name -X POST \ -H "YOUR TEAM: YOUR_WRITE_KEY" \ -d '[ { "time":"2017-02-09T02:00:00Z", "data":{"key1":"val1","key2":"val2"} }, { "data":{"key3":"val3"} } ]'

Once you have put an API call similar to the one above in a script in your repository, you will call that script from a new step in your codeship-steps.yml file. For instance:

- name: honeycomb service: app command: honeycomb.sh

If you want to limit this step only to certain branches, for instance on deployments, you can use the tag option. For instance:

- name: honeycomb service: app tag: master command: honeycomb.sh

Using Honeymarker

Honeycomb also provides Honeymarker to make it even easier to use markets within your specific datasets.

Installing Honeymarker

To use Honeymarker, you will need to install the tool into one of the services defined via your codeship-services.yml file.

In the Dockerfile for the service you are building, or in the Dockerfile for a new Honeymarker service, you will need to add:

RUN go get github.com/honeycombio/honeymarker RUN honeymarker

Note that Honeymarker installs via go get, requiring that Go is installed in the same container.

Running Honeymarker Commands

Once you have Honeymarker installed via a new service in your codeship-services.yml file, you will need to run Honeymarker commands as a new step, using the service with Honeymarker installed, in your codeship-steps.yml file:

- name: honeymarker service: your_service command: "honeymarker -k <your-writekey> -d <dataset> COMMAND [command-specific flags]"

You can view the Honeymarker documentation for a full list of commands that you can use.

CloudBees CodeShip Basic

Setting Your Team Write Key

You will need to add your Honeycomb Team Write Key to your to your project’s environment variables.

You can do this by navigating to Project Settings and then clicking on the Environment tab.

Sending Events And Markers

Next, you will need to add your Honeycomb API calls to your test or deployment commands.

If you are logging events from your test pipelines, you will want to add the Honeycomb API call - or call a script in your repository with the API call commands in it - via your test commands.

Or, if you are calling the Honeycomb API during deployments you will want to use a custom-script deployment step in your deployment pipelines.

Whether in your test or deployment pipelines, you will want to call the Honeycomb API, similar to:

curl https://api.honeycomb.io/1/batch/Dataset%20Name -X POST \ -H "YOUR TEAM: YOUR_WRITE_KEY" \ -d '[ { "time":"2017-02-09T02:00:00Z", "data":{"key1":"val1","key2":"val2"} }, { "data":{"key3":"val3"} } ]'

Using Honeymarker

Honeycomb also provides Honeymarker to make it even easier to use markets within your specific datasets.

Installing Honeymarker

To use Honeymarker, you will need to install the tool by adding a couple of new commands to your project’s setup commands:

$ go get github.com/honeycombio/honeymarker $ honeymarker

Note that Honeymarker installs via go get, which is configured by default on CloudBees CodeShip Basic build machines.

Running Honeymarker Commands

Once you have Honeymarker installed via your project’s setup commands, you will need to add new commands to your project’s test commands to make use of it:

honeymarker -k <your-writekey> -d <dataset> COMMAND [command-specific flags]

You can view the Honeymarker documentation for a full list of commands that you can use.