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

Commit 926bd44

Browse files
mshvolsongy23
authored andcommitted
exporter: Add Wavefront exporter (#527)
* Add wavefront agent exporter (w/ license and nocover) * Rebase, add go.mod & cosmetic fixes to README
1 parent 10953d1 commit 926bd44

File tree

7 files changed

+186
-0
lines changed

7 files changed

+186
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Empty test file
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Wavefront Agent Exporter
2+
3+
- [Format](#format)
4+
- [Proxy Example](#proxy-example)
5+
- [Direct Ingestion Example](#direct-ingestion-example)
6+
7+
### Configuration
8+
Wavefront exporter supports sending data using Direct Ingestion (`direct_ingestion`) or via Wavefront Proxy (`proxy`).
9+
10+
In the Service's YAML configuration file, under section "exporters" and sub-section "wavefront", please configure these fields.
11+
12+
### Format
13+
```yaml
14+
exporters:
15+
wavefront:
16+
enable_traces: true|false
17+
18+
# One of "proxy" or "direct_ingestion" is required
19+
proxy:
20+
Host: "<Proxy_IP_or_FQDN>"
21+
MetricsPort: <wf_metrics_port>
22+
TracingPort: <wf_trace_port>
23+
DistributionPort: <wf_distribution_port>
24+
direct_ingestion:
25+
Server: "<wavefront_url>"
26+
Token: "<wavefront_token>"
27+
28+
# The following are optional
29+
override_source: "<source_name>"
30+
application_name: "<app_name>"
31+
service_name: "<service_name>"
32+
custom_tags:
33+
- "<key1>" : "<val1>"
34+
- "<key2>" : "<val2>"
35+
# ...
36+
max_queue_size: number
37+
verbose_logging: true|false
38+
```
39+
40+
### Proxy Example
41+
```yaml
42+
exporters:
43+
wavefront:
44+
proxy:
45+
Host: "localhost"
46+
TracingPort: 30000
47+
enable_traces: true
48+
```
49+
50+
### Direct Ingestion Example
51+
```yaml
52+
exporters:
53+
wavefront:
54+
direct_ingestion:
55+
Server: "https://<MYINSTANCE>.wavefront.com"
56+
Token: "MY_WAVEFRONT_TOKEN_HERE"
57+
enable_traces: true
58+
```
59+
60+
### References
61+
- [https://github.com/wavefrontHQ/opencensus-exporter](https://github.com/wavefrontHQ/opencensus-exporter)
62+
- [https://github.com/wavefrontHQ/wavefront-sdk-go](https://github.com/wavefrontHQ/wavefront-sdk-go)
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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 wavefrontexporter
16+
17+
import (
18+
"errors"
19+
20+
"github.com/wavefronthq/opencensus-exporter/wavefront"
21+
"github.com/wavefronthq/wavefront-sdk-go/senders"
22+
23+
"github.com/spf13/viper"
24+
25+
"github.com/census-instrumentation/opencensus-service/consumer"
26+
"github.com/census-instrumentation/opencensus-service/exporter/exporterwrapper"
27+
)
28+
29+
type wavefrontConfig struct {
30+
ProxyConfiguration *senders.ProxyConfiguration `mapstructure:"proxy,omitempty"`
31+
DirectConfiguration *senders.DirectConfiguration `mapstructure:"direct_ingestion,omitempty"`
32+
wavefront.ServiceOptions `mapstructure:",squash"`
33+
34+
EnableTracing bool `mapstructure:"enable_tracing,omitempty"`
35+
EnableMetrics bool `mapstructure:"enable_metrics,omitempty"`
36+
}
37+
38+
// WavefrontTraceExportersFromViper unmarshals the viper and returns trace and metric consumers.
39+
func WavefrontTraceExportersFromViper(v *viper.Viper) (tps []consumer.TraceConsumer, mps []consumer.MetricsConsumer, doneFns []func() error, err error) {
40+
var cfg struct {
41+
Wavefront *wavefrontConfig `mapstructure:"wavefront,omitempty"`
42+
}
43+
if err := v.Unmarshal(&cfg); err != nil {
44+
return nil, nil, nil, err
45+
}
46+
47+
wc := cfg.Wavefront
48+
if wc == nil {
49+
return nil, nil, nil, nil
50+
}
51+
if !wc.EnableTracing && !wc.EnableMetrics {
52+
return nil, nil, nil, nil
53+
}
54+
55+
var ws senders.Sender
56+
57+
switch {
58+
case wc.ProxyConfiguration != nil:
59+
ws, err = senders.NewProxySender(wc.ProxyConfiguration)
60+
case wc.DirectConfiguration != nil:
61+
ws, err = senders.NewDirectSender(wc.DirectConfiguration)
62+
default:
63+
err = errors.New("At least one of 'proxy' or 'direct_ingestion' must be specified")
64+
}
65+
if err != nil {
66+
return nil, nil, nil, err
67+
}
68+
69+
we, err := wavefront.NewExporter(ws, wavefront.WithServiceOptions(&wc.ServiceOptions))
70+
if err != nil {
71+
return nil, nil, nil, err
72+
}
73+
74+
doneFns = append(doneFns, func() error {
75+
we.Stop()
76+
ws.Close()
77+
return nil
78+
})
79+
80+
wew, err := exporterwrapper.NewExporterWrapper("wavefront", "ocservice.exporter.Wavefront.ConsumeTraceData", we)
81+
if err != nil {
82+
return nil, nil, nil, err
83+
}
84+
85+
tps = append(tps, wew)
86+
87+
// TODO: Metrics Exporter. NewExporterWrapper only creates Trace Exporter now.
88+
// mps = append(mps, wew)
89+
90+
return
91+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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 wavefrontexporter
16+
17+
// TODO: Add tests.

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ require (
4949
github.com/uber/jaeger-client-go v2.16.0+incompatible // indirect
5050
github.com/uber/jaeger-lib v2.0.0+incompatible
5151
github.com/uber/tchannel-go v1.10.0
52+
github.com/wavefronthq/opencensus-exporter v0.0.0-20190506162721-983d7cdaceaf
53+
github.com/wavefronthq/wavefront-sdk-go v0.9.2
5254
github.com/yancl/opencensus-go-exporter-kafka v0.0.0-20181029030031-9c471c1bfbeb
5355
go.opencensus.io v0.21.0
5456
go.uber.org/atomic v1.3.2 // indirect

go.sum

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
5959
github.com/biogo/store v0.0.0-20160505134755-913427a1d5e8/go.mod h1:Iev9Q3MErcn+w3UOJD/DkEzllvugfdx7bGcMOFhvr/4=
6060
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b h1:AP/Y7sqYicnjGDfD5VcY4CIfh1hRXBUavxrvELjTiOE=
6161
github.com/bmizerany/perks v0.0.0-20141205001514-d9a9656a3a4b/go.mod h1:ac9efd0D1fsDb3EJvhqgXRbFx7bs2wqZ10HQPeU8U/Q=
62+
github.com/caio/go-tdigest v2.3.0+incompatible h1:zP6nR0nTSUzlSqqr7F/LhslPlSZX/fZeGmgmwj2cxxY=
63+
github.com/caio/go-tdigest v2.3.0+incompatible/go.mod h1:sHQM/ubZStBUmF1WbB8FAm8q9GjDajLC5T7ydxE3JHI=
6264
github.com/cenk/backoff v2.0.0+incompatible/go.mod h1:7FtoeaSnHoZnmZzz47cM35Y9nSW7tNyaidugnHTaFDE=
6365
github.com/census-instrumentation/opencensus-proto v0.0.2/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
6466
github.com/census-instrumentation/opencensus-proto v0.2.0 h1:LzQXZOgg4CQfE6bFvXGM30YZL1WW/M337pXml+GrcZ4=
@@ -231,6 +233,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
231233
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
232234
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
233235
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
236+
github.com/leesper/go_rng v0.0.0-20171009123644-5344a9259b21/go.mod h1:N0SVk0uhy+E1PZ3C9ctsPRlvOPAFPkCNlcPBDkt0N3U=
234237
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
235238
github.com/lightstep/lightstep-tracer-go v0.15.6/go.mod h1:6AMpwZpsyCFwSovxzM78e+AsYxE8sGwiM6C3TytaWeI=
236239
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
@@ -382,6 +385,10 @@ github.com/uber/jaeger-lib v2.0.0+incompatible h1:iMSCV0rmXEogjNWPh2D0xk9YVKvrtG
382385
github.com/uber/jaeger-lib v2.0.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U=
383386
github.com/uber/tchannel-go v1.10.0 h1:YOihLHuvkwT3nzvpgqFtexFW+pb5vD1Tz7h/bIWApgE=
384387
github.com/uber/tchannel-go v1.10.0/go.mod h1:Rrgz1eL8kMjW/nEzZos0t+Heq0O4LhnUJVA32OvWKHo=
388+
github.com/wavefronthq/opencensus-exporter v0.0.0-20190506162721-983d7cdaceaf h1:KO5PCIdHHzqs9c9fanhFuBxhK5eRiRz1ZGTqTrm17FU=
389+
github.com/wavefronthq/opencensus-exporter v0.0.0-20190506162721-983d7cdaceaf/go.mod h1:2pXfsubgEW9xaV795VimF4TNNQDyl6YpLCwTInzUvCU=
390+
github.com/wavefronthq/wavefront-sdk-go v0.9.2 h1:/LvWgZYNjHFUg+ZUX+qv+7e+M8sEMi0lM15zPp681Gk=
391+
github.com/wavefronthq/wavefront-sdk-go v0.9.2/go.mod h1:hQI6y8M9OtTCtc0xdwh+dCER4osxXdEAeCpacjpDZEU=
385392
github.com/yancl/opencensus-go-exporter-kafka v0.0.0-20181029030031-9c471c1bfbeb h1:DSch+h+LW/9zO8ImnA2KzFylC/ShRAAgRPJVlx6FMSA=
386393
github.com/yancl/opencensus-go-exporter-kafka v0.0.0-20181029030031-9c471c1bfbeb/go.mod h1:zfby7AY8Vh0VWAMyiFKkTvMyYKAmWTT5x3DSAOJM6xM=
387394
go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0=
@@ -399,6 +406,7 @@ golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnf
399406
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
400407
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
401408
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
409+
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
402410
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
403411
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
404412
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -451,9 +459,12 @@ golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52 h1:JG/0uqcGdTNgq7FdU+61l5P
451459
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
452460
golang.org/x/tools v0.0.0-20181023010539-40a48ad93fbe/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
453461
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
462+
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
454463
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
455464
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
456465
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
466+
gonum.org/v1/gonum v0.0.0-20190506115330-fb5cd163d924/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
467+
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
457468
google.golang.org/api v0.0.0-20180506000402-20530fd5d65a/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
458469
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
459470
google.golang.org/api v0.0.0-20181017004218-3f6e8463aa1d/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=

internal/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/census-instrumentation/opencensus-service/exporter/opencensusexporter"
3636
"github.com/census-instrumentation/opencensus-service/exporter/prometheusexporter"
3737
"github.com/census-instrumentation/opencensus-service/exporter/stackdriverexporter"
38+
"github.com/census-instrumentation/opencensus-service/exporter/wavefrontexporter"
3839
"github.com/census-instrumentation/opencensus-service/exporter/zipkinexporter"
3940
"github.com/census-instrumentation/opencensus-service/receiver/opencensusreceiver"
4041
"github.com/census-instrumentation/opencensus-service/receiver/prometheusreceiver"
@@ -457,6 +458,7 @@ func ExportersFromViperConfig(logger *zap.Logger, v *viper.Viper) ([]consumer.Tr
457458
name string
458459
fn func(*viper.Viper) ([]consumer.TraceConsumer, []consumer.MetricsConsumer, []func() error, error)
459460
}{
461+
{name: "wavefront", fn: wavefrontexporter.WavefrontTraceExportersFromViper},
460462
{name: "datadog", fn: datadogexporter.DatadogTraceExportersFromViper},
461463
{name: "stackdriver", fn: stackdriverexporter.StackdriverTraceExportersFromViper},
462464
{name: "zipkin", fn: zipkinexporter.ZipkinExportersFromViper},

0 commit comments

Comments
 (0)