Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for sending traces to OpenTelemetry #1230

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
FeatureGoogleAnalytics = "googleanalytics"
FeatureMatomo = "matomo"
FeatureChat = "chat"
FeatureOtel = "otel"
)

var (
Expand Down
6 changes: 6 additions & 0 deletions config/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ func TestReplicaEnabled(t *testing.T) {
assert.True(t, gl.FeatureEnabled(FeatureReplica, "android", common.DefaultAppName, "99.0.0", 1, false, "us"), "Replica is enabled in USA when running QA version 99.0.0")
}

func TestOtelEnabled(t *testing.T) {
gl := globalFromTemplate(t)
assert.True(t, gl.FeatureEnabled(FeatureOtel, "android", common.DefaultAppName, "7.0.0", 1, false, "ae"), "Otel is enabled for low user")
assert.False(t, gl.FeatureEnabled(FeatureOtel, "android", common.DefaultAppName, "7.0.0", 500, false, "ae"), "Otel is disabled for high user")
}

func getReplicaOptionsRoot(t *testing.T) (fos ReplicaOptionsRoot) {
g := globalFromTemplate(t)
require.NoError(t, g.UnmarshalFeatureOptions(FeatureReplica, &fos))
Expand Down
4 changes: 4 additions & 0 deletions config/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/getlantern/flashlight/browsers/simbrowser"
"github.com/getlantern/flashlight/domainrouting"
"github.com/getlantern/flashlight/otel"
"github.com/getlantern/fronted"
"github.com/getlantern/keyman"
)
Expand Down Expand Up @@ -61,6 +62,9 @@ type Global struct {
// Market share data used by the simbrowser package when picking a browser to simulate.
GlobalBrowserMarketShareData simbrowser.MarketShareData
RegionalBrowserMarketShareData map[simbrowser.CountryCode]simbrowser.MarketShareData

// Configuration for OpenTelemetry
Otel *otel.Config
}

// NewGlobal creates a new global config with otherwise nil values set.
Expand Down
15 changes: 15 additions & 0 deletions embeddedconfig/global.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ reportissueemail: support@lantern.jitbit.com
#

featuresenabled:
otel:
- label: opentelemetry
userfloor: 0
userceil: 0.01
oxtoacart marked this conversation as resolved.
Show resolved Hide resolved
yinbi:
- label: yinbi
application: lantern
Expand Down Expand Up @@ -427,3 +431,14 @@ replica:
staticpeeraddrs: []
metadatabaseurls: *AllReplicaBaseUrls
replicaserviceendpoint: *GlobalReplicaRust

otel:
endpoint: api.honeycomb.io:443
headers:
x-honeycomb-team: GKSJeT1vfWEWgGzPoxiKLE
samplerate: 1000
opsamplerates:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the rationale for treating these ops differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It varies by op, but let's take something like client_started as an example. We may want to use that as a signifier that the client ran at all and use that to derive our user numbers. This even happens only once per startup, so if we're sampling it at a low rate, we'll completely miss a bunch of clients. If we're interesting in looking for clients of a specific app version in a small country, this means that we could completely miss the presence of these if they just didn't make the cut for getting sampled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More generally, for low frequency ops, sampling at low rates risks missing them completely, so it's desirable to sample some things at higher rates.

client_started: 1
client_stopped: 1
report_issue: 1

8 changes: 8 additions & 0 deletions flashlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/getlantern/flashlight/geolookup"
"github.com/getlantern/flashlight/goroutines"
fops "github.com/getlantern/flashlight/ops"
"github.com/getlantern/flashlight/otel"
"github.com/getlantern/flashlight/proxied"
"github.com/getlantern/flashlight/shortcut"
"github.com/getlantern/flashlight/stats"
Expand Down Expand Up @@ -103,6 +104,7 @@ func (f *Flashlight) onGlobalConfig(cfg *config.Global, src config.Source) {
f.applyClientConfig(cfg)
f.applyProxyBench(cfg)
f.applyBorda(cfg)
f.applyOtel(cfg)
select {
case f.onBordaConfigured <- true:
// okay
Expand Down Expand Up @@ -303,6 +305,12 @@ func (f *Flashlight) applyBorda(cfg *config.Global) {
borda.Configure(cfg.BordaReportInterval, enableBorda)
}

func (f *Flashlight) applyOtel(cfg *config.Global) {
if cfg.Otel != nil && f.FeatureEnabled(config.FeatureOtel) {
otel.Configure(cfg.Otel)
}
}

// New creates a client proxy.
func New(
appName string,
Expand Down
27 changes: 20 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ require (
github.com/getlantern/mtime v0.0.0-20200417132445-23682092d1f7
github.com/getlantern/multipath v0.0.0-20220119171839-238498e77dc4
github.com/getlantern/netx v0.0.0-20211206143627-7ccfeb739cbd
github.com/getlantern/ops v0.0.0-20200403153110-8476b16edcd6
github.com/getlantern/ops v0.0.0-20220622024155-46238aeb954f
github.com/getlantern/osversion v0.0.0-20190510010111-432ecec19031
github.com/getlantern/proxy/v2 v2.0.1-0.20220303164029-b34b76e0e581
github.com/getlantern/proxybench v0.0.0-20220404140110-f49055cb86de
Expand Down Expand Up @@ -87,9 +87,14 @@ require (
github.com/stretchr/testify v1.7.1
github.com/xtaci/smux v1.5.15-0.20200704123958-f7188026ba01
gitlab.com/yawning/obfs4.git v0.0.0-20220204003609-77af0cba934d
go.opentelemetry.io/otel v1.7.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.7.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.7.0
go.opentelemetry.io/otel/sdk v1.7.0
go.opentelemetry.io/otel/trace v1.7.0
golang.org/x/mobile v0.0.0-20210831151748-9cba7bc03c0f
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd
golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5
)

Expand All @@ -114,10 +119,12 @@ require (
github.com/anacrolix/utp v0.1.0 // indirect
github.com/andybalholm/cascadia v1.1.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/benbjohnson/immutable v0.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -131,7 +138,7 @@ require (
github.com/getlantern/byteexec v0.0.0-20200509011419-2f5ed5531ada // indirect
github.com/getlantern/bytemap v0.0.0-20210122162547-b07440a617f0 // indirect
github.com/getlantern/cmux v0.0.0-20200905031936-c55b16ee8462 // indirect
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
github.com/getlantern/context v0.0.0-20220418194847-3d5e7a086201 // indirect
github.com/getlantern/dns v0.0.0-20210120185712-8d005533efa0 // indirect
github.com/getlantern/elevate v0.0.0-20210901195629-ce58359e4d0e // indirect
github.com/getlantern/enproxy v0.0.0-20180913191734-002212d417a4 // indirect
Expand Down Expand Up @@ -161,6 +168,8 @@ require (
github.com/getlantern/withtimeout v0.0.0-20160829163843-511f017cd913 // indirect
github.com/getlantern/zenodb v0.0.0-20220217194355-df46cc148a8c // indirect
github.com/go-errors/errors v1.4.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-redis/redis/v8 v8.11.3 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
Expand All @@ -177,6 +186,7 @@ require (
github.com/google/btree v1.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.10.1 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/juju/ratelimit v1.0.1 // indirect
github.com/klauspost/compress v1.13.6 // indirect
Expand Down Expand Up @@ -249,7 +259,10 @@ require (
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 // indirect
gitlab.com/yawning/edwards25519-extra.git v0.0.0-20211229043746-2f91fcc9fbdb // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.7.0 // indirect
go.opentelemetry.io/proto/otlp v0.16.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/goleak v1.1.12 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 // indirect
Expand All @@ -260,9 +273,9 @@ require (
golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00 // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect
google.golang.org/grpc v1.46.2 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Expand Down
Loading