Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 0dbf0b3

Browse files
committed
exporter: add Honeycomb.io
Add Honeycomb.io as a trace exporter. This exporter is based off OpenCensus-Go trace.Exporter. However, I shall file an issue or firstly page them to ask them to implement an OpenCensus-Proto trace Exporter. This change currently imports the work from: https://opencensus.io/exporters/supported-exporters/go/honeycomb/ or succinctly https://github.com/honeycombio/opencensus-exporter A sample YAML file is: ```yaml receivers: opencensus: address: "localhost:55678" exporters: honeycomb: write_key: "739769d7-e61c-42ec-82b9-3ee88dfeff43" dataset_name: "dc8_9" ``` Fixes #398
1 parent f019968 commit 0dbf0b3

5 files changed

Lines changed: 88 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ exporters:
175175
default_service_name: "verifiability_agent"
176176
version: "latest"
177177
buffer_size: 200
178+
honeycomb:
179+
write_key: "739769d7-e61c-42ec-82b9-3ee88dfeff43"
180+
dataset_name: "dc8_9"
178181
```
179182
180183
### <a name="config-diagnostics"></a>Diagnostics
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2019, OpenCensus Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package exporterparser
16+
17+
// TODO: (@odeke-em) file an issue at the official Honeycomb repository to
18+
// ask them to make an exporter that uses OpenCensus-Proto instead of OpenCensus-Go.
19+
20+
import (
21+
"context"
22+
23+
"github.com/honeycombio/opencensus-exporter/honeycomb"
24+
"github.com/spf13/viper"
25+
26+
"github.com/census-instrumentation/opencensus-service/data"
27+
"github.com/census-instrumentation/opencensus-service/exporter"
28+
)
29+
30+
type honeycombConfig struct {
31+
WriteKey string `mapstructure:"write_key"`
32+
DatasetName string `mapstructure:"dataset_name"`
33+
}
34+
35+
// HoneycombTraceExportersFromViper unmarshals the viper and returns an exporter.TraceExporter
36+
// targeting Honeycomb according to the configuration settings.
37+
func HoneycombTraceExportersFromViper(v *viper.Viper) (tes []exporter.TraceExporter, mes []exporter.MetricsExporter, doneFns []func() error, err error) {
38+
var cfg struct {
39+
Honeycomb *honeycombConfig `mapstructure:"honeycomb"`
40+
}
41+
if err := v.Unmarshal(&cfg); err != nil {
42+
return nil, nil, nil, err
43+
}
44+
45+
hc := cfg.Honeycomb
46+
if hc == nil {
47+
return nil, nil, nil, nil
48+
}
49+
50+
rawExp := honeycomb.NewExporter(hc.WriteKey, hc.DatasetName)
51+
hce := &honeycombExporter{exporter: rawExp}
52+
53+
tes = append(tes, hce)
54+
doneFns = append(doneFns, func() error {
55+
rawExp.Close()
56+
return nil
57+
})
58+
return
59+
}
60+
61+
type honeycombExporter struct {
62+
exporter *honeycomb.Exporter
63+
}
64+
65+
func (hce *honeycombExporter) ExportSpans(ctx context.Context, td data.TraceData) error {
66+
return exportSpans(ctx, "honeycomb", hce.exporter, td)
67+
}

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ require (
1717
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b // indirect
1818
github.com/census-instrumentation/opencensus-proto v0.1.0-0.20181214143942-ba49f56771b8
1919
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
20+
github.com/facebookgo/limitgroup v0.0.0-20150612190941-6abd8d71ec01 // indirect
21+
github.com/facebookgo/muster v0.0.0-20150708232844-fd3d7953fd52 // indirect
2022
github.com/go-logfmt/logfmt v0.4.0 // indirect
2123
github.com/gogo/googleapis v1.1.0 // indirect
2224
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
@@ -32,6 +34,8 @@ require (
3234
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
3335
github.com/hashicorp/go-rootcerts v1.0.0 // indirect
3436
github.com/hashicorp/serf v0.8.2 // indirect
37+
github.com/honeycombio/libhoney-go v1.8.2 // indirect
38+
github.com/honeycombio/opencensus-exporter v0.0.0-20181101214123-9be2bb327b5a
3539
github.com/inconshreveable/mousetrap v1.0.0 // indirect
3640
github.com/jaegertracing/jaeger v1.8.2
3741
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
@@ -78,6 +82,7 @@ require (
7882
google.golang.org/genproto v0.0.0-20181101192439-c830210a61df // indirect
7983
google.golang.org/grpc v1.17.0
8084
gopkg.in/DataDog/dd-trace-go.v1 v1.4.0 // indirect
85+
gopkg.in/alexcesaro/statsd.v2 v2.0.0 // indirect
8186
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
8287
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
8388
gopkg.in/inf.v0 v0.9.1 // indirect

go.sum

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ github.com/elastic/gosigar v0.9.0/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyC
9292
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
9393
github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc=
9494
github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
95+
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw=
9596
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a/go.mod h1:7Ga40egUymuWXxAe151lTNnCv97MddSOVsjpPPkityA=
97+
github.com/facebookgo/limitgroup v0.0.0-20150612190941-6abd8d71ec01 h1:IeaD1VDVBPlx3viJT9Md8if8IxxJnO+x0JCGb054heg=
98+
github.com/facebookgo/limitgroup v0.0.0-20150612190941-6abd8d71ec01/go.mod h1:ypD5nozFk9vcGw1ATYefw6jHe/jZP++Z15/+VTMcWhc=
99+
github.com/facebookgo/muster v0.0.0-20150708232844-fd3d7953fd52 h1:a4DFiKFJiDRGFD1qIcqGLX/WlUMD9dyLSLDt+9QZgt8=
100+
github.com/facebookgo/muster v0.0.0-20150708232844-fd3d7953fd52/go.mod h1:yIquW87NGRw1FU5p5lEkpnt/QxoH5uPAOUlOVkAUuMg=
96101
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
97102
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
98103
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -199,6 +204,10 @@ github.com/hashicorp/serf v0.0.0-20161007004122-1d4fa605f6ff/go.mod h1:h/Ru6tmZa
199204
github.com/hashicorp/serf v0.8.2 h1:YZ7UKsJv+hKjqGVUUbtE3HNj79Eln2oQ75tniF6iPt0=
200205
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
201206
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
207+
github.com/honeycombio/libhoney-go v1.8.2 h1:stYQJi/21p37Qan2DlSkXDuIrup9zxOul2UyeqMAqX0=
208+
github.com/honeycombio/libhoney-go v1.8.2/go.mod h1:jdLxh51fcBTy6XIpx1efuJmHePs2xUfVkw25lr+hsmg=
209+
github.com/honeycombio/opencensus-exporter v0.0.0-20181101214123-9be2bb327b5a h1:XZRt69AYOjIRW3KGpzOh0ulEa4DOep0snLPlIgtaXPE=
210+
github.com/honeycombio/opencensus-exporter v0.0.0-20181101214123-9be2bb327b5a/go.mod h1:Zx4YGFb3eHJsstwhyB5yaVGLROSXWCd0b4PkFKb1mdc=
202211
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
203212
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
204213
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
@@ -461,6 +470,8 @@ google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3
461470
gopkg.in/DataDog/dd-trace-go.v1 v1.4.0 h1:RYj+AsYR1/yW/6vuZ2YFAXKVJEV7sTiupNcQeslicM4=
462471
gopkg.in/DataDog/dd-trace-go.v1 v1.4.0/go.mod h1:DVp8HmDh8PuTu2Z0fVVlBsyWaC++fzwVCaGWylTe3tg=
463472
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
473+
gopkg.in/alexcesaro/statsd.v2 v2.0.0 h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVCwMc=
474+
gopkg.in/alexcesaro/statsd.v2 v2.0.0/go.mod h1:i0ubccKGzBVNBpdGV5MocxyA/XlLUJzA7SLonnE4drU=
464475
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
465476
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
466477
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=

internal/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ func eqLocalHost(host string) bool {
391391
// + opencensus
392392
// + prometheus
393393
// + aws-xray
394+
// + honeycomb
394395
func ExportersFromViperConfig(logger *zap.Logger, v *viper.Viper) ([]exporter.TraceExporter, []exporter.MetricsExporter, []func() error, error) {
395396
parseFns := []struct {
396397
name string
@@ -404,6 +405,7 @@ func ExportersFromViperConfig(logger *zap.Logger, v *viper.Viper) ([]exporter.Tr
404405
{name: "opencensus", fn: exporterparser.OpenCensusTraceExportersFromViper},
405406
{name: "prometheus", fn: exporterparser.PrometheusExportersFromViper},
406407
{name: "aws-xray", fn: exporterparser.AWSXRayTraceExportersFromViper},
408+
{name: "honeycomb", fn: exporterparser.HoneycombTraceExportersFromViper},
407409
}
408410

409411
var traceExporters []exporter.TraceExporter

0 commit comments

Comments
 (0)