go-test-trace is like go test but it also generates distributed traces.

Overview

go-test-trace

CircleCI

go-test-trace is like go test but it also generates distributed traces.

Generated traces are exported in OTLP to a OpenTelemetry collector. You need to run go-test-trace alongside a collector to export data to distributed tracing service.

Honeycomb

Installation

go get -u github.com/rakyll/go-test-trace

Usage

You can use go-test-trace as a drop-in replacement for go test. The following example will generate a distributed trace and export it to a collector available at "127.0.0.1:55680".

$ go-test-trace ./example
=== RUN   TestStart
--- PASS: TestStart (0.50s)
=== RUN   TestStartWithOptions
--- PASS: TestStartWithOptions (1.00s)
=== RUN   TestFileParser
--- FAIL: TestFileParser (0.30s)
=== RUN   TestLoading
=== PAUSE TestLoading
=== RUN   TestLoading_abort
=== PAUSE TestLoading_abort
=== RUN   TestLoading_interrupt
=== PAUSE TestLoading_interrupt
=== CONT  TestLoading
=== CONT  TestLoading_abort
=== CONT  TestLoading_interrupt
--- PASS: TestLoading_interrupt (0.08s)
--- PASS: TestLoading (1.00s)
--- PASS: TestLoading_abort (2.50s)
FAIL
FAIL	github.com/rakyll/go-test-trace/example	4.823s
exit status 1
make: *** [default] Error 1

Alternatively, you can use -stdin option to parse the output of go test. This option won't be as accurate in terms of timestamps because it will generate trace spans as it sees output in stdin.

$ go test -v ./example | go-test-trace -stdin

You can export to any collector by using the endpoint flag:

$ go-test-trace ./example -endpoint=my-otel-collector.io:9090

You can make the go-test-trace to participate into an existing trace with the traceparent flag.

$ go-test-trace ./example -traceparent=00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01

Running the collector

An example collector configuration is available at example/collector.yaml. It exports to Honeycomb but you can choose to any other destination by changing the configuration. Please edit the write key and data set with your details from Honeycomb before using it.

Then, you can run the collector locally by the following command and export the traces to Honeycomb:

$ docker run --rm -p 4317:4317 -p 55680:55680 -p 8888:8888 \
    -v "${PWD}/example/collector.yaml":/collector.yaml \
    --name awscollector public.ecr.aws/aws-observability/aws-otel-collector:latest \
    --config collector.yaml;

You can use any configuration supported by ADOT or export to any other OpenTelemetry collector.

Comments
  • Rely on supported env variables if no endpoint is specified

    Rely on supported env variables if no endpoint is specified

    This allows using the environment variables provided by OpenTelemetry to configure the OTLP exporter instead of the collector. Example:

    OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io:443 OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=foobar go-test-trace ./...
    
    opened by dmathieu 1
  • Upgrade otel to 1.7.0

    Upgrade otel to 1.7.0

    This upgrades OpenTelemetry to use the latest version, 1.7.0, as well as a go mod tidy. There are no changes to the public API, so no required changes in code.

    opened by dmathieu 1
  • Skip pass actions if no test name is present

    Skip pass actions if no test name is present

    Thanks for releasing this, I'm looking forward to getting traces set up for tests in my projects! This PR just addresses a few minor issues I had getting started:

    • Updated the examples in the README to put the go-test-trace flags before the arguments for go test
    • Fixes an issue where the decoder goroutine would exit early after a package where all the tests pass. The output from go test in that case looks like {"Time":"2021-10-07T15:05:01.541387-05:00","Action":"pass","Package":"github.com/example/package","Elapsed":0.023} and it would return after failing to find the empty string in collectedSpans
    opened by willgorman 1
  • Provide useful `--help` message

    Provide useful `--help` message

    Currently --help does nothing:

     go-test-trace -help
    

    will just hang indefinitely. It would be great if this output some help message to understand the flags available

    opened by howardjohn 0
  • Update collector port to match recent releases

    Update collector port to match recent releases

    The 55860 legacy port was removed in v0.35.0 of the upstream collector and v0.13.0 of the ADOT collector. https://github.com/open-telemetry/opentelemetry-collector/releases/tag/v0.35.0 https://github.com/aws-observability/aws-otel-collector/releases/tag/v0.13.0

    opened by ccpost 1
  • Document go-test-trace global trace context propagation to go test

    Document go-test-trace global trace context propagation to go test

    Currently, go-test-trace propagates the global context to go test via TRACE_CONTEXT environmental variable, but this feature is not documented and it's not clear what the limitations are.

    opened by rakyll 4
  • Link the collector to go-test-trace

    Link the collector to go-test-trace

    Currently, go-test-trace requires a standalone collector running to export spans. We can also link the collector into the go-test-trace binary to optionally allow users to run the collector as a part of the go-test-trace binary. This option will make it much easier to run the tool locally.

    opened by rakyll 0
Releases(v0.1.1)
  • v0.1.1(Oct 12, 2021)

    What's Changed

    • Skip pass actions if no test name is present by @willgorman in https://github.com/rakyll/go-test-trace/pull/8

    New Contributors

    • @willgorman made their first contribution in https://github.com/rakyll/go-test-trace/pull/8

    Full Changelog: https://github.com/rakyll/go-test-trace/compare/v0.1.0...v0.1.1

    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Sep 24, 2021)

Owner
JBD
I work on observability for container platforms at @aws. [email protected] or [email protected] to email.
JBD
Ruby on Rails like test fixtures for Go. Write tests against a real database

testfixtures Warning: this package will wipe the database data before loading the fixtures! It is supposed to be used on a test database. Please, doub

null 873 Nov 21, 2022
Generate a test coverage badge like this one for your go projects.

coverage-badge-go ?? Generate a test coverage badge like this one for your go projects. Usage on: pull_request: branches: -

tj-actions 28 Nov 11, 2022
Flugel Test Documentation for steps to run and test the automatio

Flugel Test Documentation Documentation for steps to run and test the automation #Test-01 1 - Local Test Using Terratest (End To End) 1- By runing " t

Suc0_Unix 0 Nov 13, 2022
Test-assignment - Test assignment with golang

test-assignment We have a two steam of data and we need to save it in the map: I

null 0 Jan 19, 2022
This repository includes consumer driven contract test for provider, unit test and counter api.

This repository includes consumer driven contract test for provider, unit test and counter api.

Ahmet Zümberoğlu 0 Feb 1, 2022
Configuration management tool inspired by Ansible, but with no yaml - just Go

GOSSH This repo is an experiement with creating a declarative IT automation and configuration management package for Golang. Think Ansible, but no Yam

Kristoffer Lorentsen 26 Oct 31, 2022
Hive-fleet: a distributed, scalable load-testing tool built in go that leverages Google Cloud Functions

hive-fleet hive-fleet is a distributed, scalable load-testing tool, built on top

Cristian Glavan 5 Jan 27, 2022
GoCrest - Hamcrest-like matchers for Go

gocrest A hamcrest-like assertion library for Go. GoCrest matchers are composable, self-describing and can be strung together in a more readable form

Matt 84 Nov 23, 2022
🏳️ Go package that provides function like assert of Python or C++.

gassert gassert is Go package that provides function like assert of Python or C++. With gassert, you can check validation of parameters or values more

KyuSik Kim 4 Aug 5, 2022
An assert function for Go that works like the one in C.

Assert This package provides an assert function for Go. It's designed to work like assert in C.

Josh 20 Nov 16, 2022
Rest API to receive solana tokens in testnet just like a faucet

solana-example Rest API to receive solana tokens in testnet just like a faucet Running go run main.go Test Request airdrop curl --header "Content-Type

Rafael Escrich 0 Oct 14, 2021
Test your command line interfaces on windows, linux and osx and nodes viá ssh and docker

Commander Define language independent tests for your command line scripts and programs in simple yaml files. It runs on windows, osx and linux It can

null 206 Nov 14, 2022
Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test

embedded-postgres Run a real Postgres database locally on Linux, OSX or Windows as part of another Go application or test. When testing this provides

Fergus Strange 468 Nov 19, 2022
End to end functional test and automation framework

Declarative end to end functional testing (endly) This library is compatible with Go 1.12+ Please refer to CHANGELOG.md if you encounter breaking chan

Viant, Inc 224 Nov 19, 2022
Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻

Gnomock – tests without mocks ??️ Spin up entire dependency stack ?? Setup initial dependency state – easily! ?? Test against actual, close to product

Yury Fedorov 987 Nov 21, 2022
go-carpet - show test coverage in terminal for Go source files

go-carpet - show test coverage for Go source files To view the test coverage in the terminal, just run go-carpet. It works outside of the GOPATH direc

Sergey Mudrik 231 Nov 3, 2022
http integration test framework

go-hit hit is an http integration test framework written in golang. It is designed to be flexible as possible, but to keep a simple to use interface f

Tobias Salzmann 148 Nov 17, 2022
Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.

GoConvey is awesome Go testing Welcome to GoConvey, a yummy Go testing tool for gophers. Works with go test. Use it in the terminal or browser accordi

SmartyStreets 7.5k Nov 27, 2022
A Go test assertion library for verifying that two representations of JSON are semantically equal

jsonassert is a Go test assertion library for verifying that two representations of JSON are semantically equal. Usage Create a new *jsonassert.Assert

Roger Guldbrandsen 96 Nov 9, 2022