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

Remove telemetry #378

Merged
merged 1 commit into from
Nov 19, 2024
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
11 changes: 0 additions & 11 deletions .github/workflows/master-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ jobs:
uses: jakejarvis/wait-action@master
with:
time: '30s'
# - name: Install Code Climate reporter
# run: |
# sudo curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# sudo chmod +x ./cc-test-reporter
# ./cc-test-reporter before-build
# - name: Master buld tests
# run: |
# make test/coverage
# - name: Upload coverage information
# run: |
# GIT_BRANCH=master ./cc-test-reporter after-build -p github.com/streamdal/plumber -r ${{ secrets.CC_TEST_REPORTER_ID }}
functional:
name: Run functional tests
runs-on: ubuntu-latest
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/pr-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ jobs:
uses: jakejarvis/wait-action@master
with:
time: '30s'
# - name: Install Code Climate reporter
# run: |
# sudo curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# sudo chmod +x ./cc-test-reporter
# ./cc-test-reporter before-build
# - name: Test
# run: |
# make test/coverage
# - name: Upload coverage information
# run: |
# GIT_BRANCH="${GITHUB_HEAD_REF}" ./cc-test-reporter after-build -p github.com/streamdal/plumber -r ${{ secrets.CC_TEST_REPORTER_ID }}

functional:
name: Run functional tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
push_options: '--force'
- name: Build
run: |
VERSION="$GITHUB_TAG-$GITHUB_SHORT_SHA" TELEMETRY_API_KEY="${{secrets.TELEMETRY_API_KEY}}" make build
VERSION="$GITHUB_TAG-$GITHUB_SHORT_SHA" make build
- name: Update nfpm version value
run: |
sed -i '/version/ s/"[^"][^"]*"/"${{ env.GITHUB_TAG }}"/' nfpm.yaml
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARCH ?= $(shell uname -m)

GO = CGO_ENABLED=$(CGO_ENABLED) GONOPROXY=github.com/streamdal GOFLAGS=-mod=vendor go
CGO_ENABLED ?= 0
GO_BUILD_FLAGS = -ldflags "-X 'github.com/streamdal/plumber/options.VERSION=${VERSION}' -X 'main.TELEMETRY_API_KEY=${TELEMETRY_API_KEY}'"
GO_BUILD_FLAGS = -ldflags "-X 'github.com/streamdal/plumber/options.VERSION=${VERSION}'"

# Pattern #1 example: "example : description = Description for example target"
# Pattern #2 example: "### Example separator text
Expand Down
96 changes: 7 additions & 89 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package config
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path"
Expand Down Expand Up @@ -38,13 +37,12 @@ const (

// Config stores Account IDs and the auth_token cookie
type Config struct {
ClusterID string `json:"-"` // This comes from an environment variable
PlumberID string `json:"plumber_id"`
Token string `json:"token"`
TeamID string `json:"team_id"`
UserID string `json:"user_id"`
EnableTelemetry bool `json:"enable_telemetry"`
LastVersion string `json:"last_version"`
ClusterID string `json:"-"` // This comes from an environment variable
PlumberID string `json:"plumber_id"`
Token string `json:"token"`
TeamID string `json:"team_id"`
UserID string `json:"user_id"`
LastVersion string `json:"last_version"`

Connections map[string]*stypes.Connection `json:"connections"`
Relays map[string]*stypes.Relay `json:"relays"`
Expand Down Expand Up @@ -168,87 +166,7 @@ func requireReconfig(initialRun bool, cfg *Config) bool {
}

func (c *Config) Configure() {
// No need to ask about telemetry if it's already enabled
if !c.EnableTelemetry {
c.askTelemetry()
}
}

func (c *Config) askTelemetry() {
telemetryDescription := `If telemetry is enabled, plumber will collect the following anonymous telemetry data:

> General
- PlumberID (a unique, randomly generated ID for this plumber instance)
- Plumber version
- OS and architecture
- Plumber mode (server or CLI)

> For CLI
- Plumber action (read, write, relay, etc.)
- Backend used (kafka, rabbitmq, nats, etc.)
- Data format used for read or write (json, protobuf, etc.)
- If reading, whether continuous mode is used
- If using protobuf, whether file descriptors are used

> For server
- Number of connections, relays, tunnels
- Server uptime
- ClusterID
- gRPC methods used (create relay, stop tunnel, etc.)

NOTE: We do NOT collect ANY personally identifiable or confidential information.

You can read this statement here: https://docs.streamdal.com/plumber/telemetry
`
fmt.Printf(telemetryDescription + "\n")

enableTelemetry, err := askYesNo("Do you want to enable telemetry?", "N")
if err != nil {
c.log.Fatalf("unable to configure plumber: %s", err)
}

if enableTelemetry {
fmt.Printf("\nNICE! Thank you for opting in! This will help us improve plumber :)\n\n")
}

c.EnableTelemetry = enableTelemetry
}

func askYesNo(question, defaultAnswer string) (bool, error) {
if defaultAnswer != "" {
fmt.Printf(question+" [y/n (default: %s)]: ", defaultAnswer)
} else {
fmt.Print(question + " [y/n]: ")
}

var answer string

i, err := fmt.Scanln(&answer)

// Scan() doesn't return on only newline and empty string
// Scanln() will error on only new line and empty string
if err != nil && !strings.Contains(err.Error(), "unexpected newline") {
return false, fmt.Errorf("unable to read input: %s", err)
}

if i == 0 {
if defaultAnswer != "" {
answer = defaultAnswer
}
}

answer = strings.ToLower(answer)

if answer == "y" || answer == "yes" {
return true, nil
}

if answer == "n" || answer == "no" {
return false, nil
}

fmt.Println("invalid input")
return askYesNo(question, defaultAnswer)
// purposefully empty since we removed telemetry
}

func newConfig(enableCluster bool, k kv.IKV) *Config {
Expand Down
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ require (
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.30.0
github.com/pkg/errors v0.9.1
github.com/posthog/posthog-go v0.0.0-20220817142604-0b0bbf0f9c0f
github.com/prometheus/client_golang v1.11.1
github.com/rabbitmq/rabbitmq-stream-go-client v1.0.1-rc.2
github.com/relistan/go-director v0.0.0-20200406104025-dbbf5d95248d
Expand All @@ -66,7 +65,7 @@ require (
github.com/cloudevents/sdk-go/protocol/kafka_sarama/v2 v2.13.0
github.com/cloudevents/sdk-go/protocol/nats/v2 v2.13.0
github.com/cloudevents/sdk-go/v2 v2.13.0
github.com/streamdal/streamdal/sdks/go v0.1.32
github.com/streamdal/streamdal/sdks/go v0.1.36
)

require (
Expand Down Expand Up @@ -153,7 +152,7 @@ require (
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.1.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/streamdal/streamdal/libs/protos v0.1.57 // indirect
github.com/streamdal/streamdal/libs/protos v0.1.58 // indirect
github.com/tetratelabs/wazero v1.7.3 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
Expand All @@ -165,7 +164,6 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v1.0.0 // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
Expand Down
13 changes: 4 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posthog/posthog-go v0.0.0-20220817142604-0b0bbf0f9c0f h1:h0p1aZ9F5d6IXOygysob3g4B07b+HuVUQC0VJKD8wA4=
github.com/posthog/posthog-go v0.0.0-20220817142604-0b0bbf0f9c0f/go.mod h1:oa2sAs9tGai3VldabTV0eWejt/O4/OOD7azP8GaikqU=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
Expand Down Expand Up @@ -714,10 +712,10 @@ github.com/streadway/amqp v1.0.0 h1:kuuDrUJFZL1QYL9hUNuCxNObNzB0bV/ZG5jV3RWAQgo=
github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streamdal/pgoutput v0.3.3 h1:4XLuGQFzmMFQd4U/zy1X5lMICXduHp8vG7FlbYpUFn0=
github.com/streamdal/pgoutput v0.3.3/go.mod h1:19V8kXi7a88guhXqvNpL2HH7sbnCYk0i93H4Q2i5iUA=
github.com/streamdal/streamdal/libs/protos v0.1.57 h1:WcdPA6d/jSBbr4BF07q5bgnoA7NaadL1rccQbvLXer8=
github.com/streamdal/streamdal/libs/protos v0.1.57/go.mod h1:1rQ250ydoKeRoJftIV9qGrR28Iqdb9+7Jcnoxber/eQ=
github.com/streamdal/streamdal/sdks/go v0.1.32 h1:1NA96RFsAmKEYp2IgWV/X+zn8D2XqrFYYqv6Fn5lJbU=
github.com/streamdal/streamdal/sdks/go v0.1.32/go.mod h1:JwuDEm46fAsjpuz8Nt6IkFX4BWX8g0IAox2MBiF5bKc=
github.com/streamdal/streamdal/libs/protos v0.1.58 h1:N/ts/V8DtWsIEueijCiGyKwElrFkC0swqUtbvgNbZKc=
github.com/streamdal/streamdal/libs/protos v0.1.58/go.mod h1:1rQ250ydoKeRoJftIV9qGrR28Iqdb9+7Jcnoxber/eQ=
github.com/streamdal/streamdal/sdks/go v0.1.36 h1:eaOgIcnM/fk11ruHzaO8jRYWjMHWZXE0VL4FW/zlvIQ=
github.com/streamdal/streamdal/sdks/go v0.1.36/go.mod h1:D6p5gLhXNmtP4468DQ7zPcv5n4IIt5zX+6ihMZGtavA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
Expand Down Expand Up @@ -750,7 +748,6 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6 h1:hb7P11ytAQIcQ7Cq1uQBNTGgKQle7N+jsP4L72ooa7Q=
github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6/go.mod h1:0VP5W9AFNVWU8C1QLNeVg8TvzoEkIHWZ4vxtxEVFWUY=
Expand All @@ -771,8 +768,6 @@ github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhe
github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c h1:3lbZUMbMiGUW/LMkfsEABsc5zNT9+b1CvsJx47JzJ8g=
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
30 changes: 0 additions & 30 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"os/signal"
"strings"
"syscall"
"time"

"github.com/sirupsen/logrus"
"github.com/tidwall/gjson"
Expand All @@ -23,11 +22,6 @@ import (
"github.com/streamdal/plumber/plumber"
"github.com/streamdal/plumber/printer"
"github.com/streamdal/plumber/prometheus"
"github.com/streamdal/plumber/telemetry"
)

var (
TELEMETRY_API_KEY = "UNSET"
)

func main() {
Expand Down Expand Up @@ -70,29 +64,6 @@ func main() {
// Save config automatically on exit
defer persistentConfig.Save()

// If enabled, setup telemetry
var as telemetry.ITelemetry

if persistentConfig.EnableTelemetry {
var err error

as, err = telemetry.New(&telemetry.Config{
Token: TELEMETRY_API_KEY,
PlumberID: persistentConfig.PlumberID,
CLIOptions: cliOpts,
})
if err != nil {
logrus.Fatalf("unable to create telemetry client: %s", err)
}

logrus.Debug("telemetry enabled")

// Making sure that we give enough time for telemetry to finish
defer time.Sleep(time.Second)
} else {
as = &telemetry.NoopTelemetry{}
}

// We only want to intercept interrupt signals in relay or server mode
if cliOpts.Global.XAction == "relay" || cliOpts.Global.XAction == "server" || cliOpts.Global.XAction == "read" {
logrus.Debug("Intercepting signals")
Expand Down Expand Up @@ -135,7 +106,6 @@ func main() {
}

p, err := plumber.New(&plumber.Config{
Telemetry: as,
PersistentConfig: persistentConfig,
ServiceShutdownCtx: serviceCtx,
KongCtx: kongCtx,
Expand Down
10 changes: 0 additions & 10 deletions plumber/cli_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"strings"

"github.com/posthog/posthog-go"

"github.com/streamdal/plumber/backends/streamdal"
)

Expand All @@ -16,14 +14,6 @@ func (p *Plumber) HandleStreamdalCmd() error {
// Less typing
cmd := p.CLIOptions.Global.XFullCommand

p.Telemetry.Enqueue(posthog.Capture{
Event: "cli_batch",
DistinctId: p.PersistentConfig.PlumberID,
Properties: map[string]interface{}{
"command": cmd,
},
})

switch {
case strings.HasPrefix(cmd, "streamdal login"):
return b.Login()
Expand Down
33 changes: 0 additions & 33 deletions plumber/cli_manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/golang/protobuf/proto"
"github.com/hokaccha/go-prettyjson"
"github.com/pkg/errors"
"github.com/posthog/posthog-go"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

Expand Down Expand Up @@ -138,38 +137,6 @@ func (p *Plumber) displayJSON(input map[string]string) {
fmt.Println(string(data))
}

func (p *Plumber) EnqueueManage(event posthog.Capture) {
if event.Properties == nil {
event.Properties = make(map[string]interface{})
}

if _, ok := event.Properties["use_tls"]; !ok {
event.Properties["use_tls"] = p.CLIOptions.Manage.GlobalOptions.ManageUseTls
}

if _, ok := event.Properties["insecure_tls"]; !ok {
event.Properties["insecure_tls"] = p.CLIOptions.Manage.GlobalOptions.ManageInsecureTls
}

if _, ok := event.Properties["disable_pretty"]; !ok {
event.Properties["disable_pretty"] = p.CLIOptions.Manage.GlobalOptions.DisablePretty
}

event.Properties["default_manage_token"] = false

if p.CLIOptions.Manage.GlobalOptions.ManageToken == "streamdal" {
event.Properties["default_manage_token"] = true
}

event.Properties["default_manage_address"] = false

if p.CLIOptions.Manage.GlobalOptions.ManageAddress == "localhost:9090" {
event.Properties["default_manage_address"] = true
}

p.Telemetry.Enqueue(event)
}

func (p *Plumber) displayProtobuf(msg proto.Message) error {
marshaller := jsonpb.Marshaler{
Indent: " ",
Expand Down
Loading
Loading