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

NOISSUE - Add Call Home Client to Mainflux services #1751

Merged
merged 33 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
04644a2
Move Things and Users to Clients
rodneyosodo Feb 3, 2023
0fc996d
collect and send data package
SammyOina Mar 20, 2023
59165e9
create telemetry migrations
SammyOina Mar 20, 2023
b03ebec
add telemetry endpoints
SammyOina Mar 21, 2023
cfcd5b3
add transport
SammyOina Mar 22, 2023
fe641c4
create service
SammyOina Mar 22, 2023
e8efc07
remove homing server
SammyOina Mar 23, 2023
d754c50
add call home to adapters
SammyOina Mar 27, 2023
ff366b6
add last seen
SammyOina Mar 27, 2023
3e493aa
rename logger
SammyOina Mar 28, 2023
0597dbd
remove homing client
SammyOina Mar 28, 2023
00b223d
use unmerged repo
SammyOina Apr 22, 2023
5f581fa
use renamed module
SammyOina Apr 22, 2023
3880748
update call home version
SammyOina Apr 23, 2023
ba6f5d6
edit documentation
SammyOina Apr 23, 2023
6f3c1eb
align table
SammyOina Apr 27, 2023
9ae4df6
use alias for call home client
SammyOina Apr 28, 2023
c890d6e
update callhome
SammyOina May 18, 2023
22dd239
update call home pkg
SammyOina May 31, 2023
2126e9a
update call home
SammyOina May 31, 2023
6ded640
fix modules
SammyOina Jun 7, 2023
c86d123
use mf build version
SammyOina Jun 7, 2023
adfd69f
use mf build version
SammyOina Jun 7, 2023
c6bb7e9
restore default
SammyOina Jun 7, 2023
05d9db1
add call home for users and things
SammyOina Jun 7, 2023
14c8024
enable opting on call home
SammyOina Jun 7, 2023
a2ca821
remove full stops
SammyOina Jun 7, 2023
5b430ed
update callhome client
SammyOina Jun 8, 2023
65ba929
add call home to all services
SammyOina Jun 8, 2023
5148293
fix build
SammyOina Jun 13, 2023
c717647
restore sdk tests
SammyOina Jun 13, 2023
dc781cc
remove unnecessary changes
SammyOina Jun 13, 2023
80d57df
restore health_test.go
SammyOina Jun 14, 2023
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 bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ The service is configured using the environment variables presented in the follo
| MF_JAEGER_URL | Jaeger server URL | localhost:6831 |
| MF_AUTH_GRPC_URL | Users service gRPC URL | localhost:7001 |
| MF_AUTH_GRPC_TIMEOUT | Users service gRPC request timeout in seconds | 1s |
| MF_SEND_TELEMETRY | Send telemetry to mainflux call home server | true |

## Deployment

Expand Down
9 changes: 9 additions & 0 deletions cmd/bootstrap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"

bootstrapPg "github.com/mainflux/mainflux/bootstrap/postgres"
rediscons "github.com/mainflux/mainflux/bootstrap/redis/consumer"
redisprod "github.com/mainflux/mainflux/bootstrap/redis/producer"
Expand Down Expand Up @@ -46,6 +49,7 @@ type config struct {
ESConsumerName string `env:"MF_BOOTSTRAP_EVENT_CONSUMER" envDefault:"bootstrap"`
ThingsURL string `env:"MF_THINGS_URL" envDefault:"http://localhost:9000"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -96,6 +100,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc, bootstrap.NewConfigReader([]byte(cfg.EncKey)), logger), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

// Start servers
g.Go(func() error {
return hs.Start()
Expand Down
12 changes: 10 additions & 2 deletions cmd/cassandra-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"os"

"github.com/gocql/gocql"
chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/internal"
cassandraClient "github.com/mainflux/mainflux/internal/clients/cassandra"
authClient "github.com/mainflux/mainflux/internal/clients/grpc/auth"
Expand All @@ -33,8 +35,9 @@ const (
)

type config struct {
LogLevel string `env:"MF_CASSANDRA_READER_LOG_LEVEL" envDefault:"info"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
LogLevel string `env:"MF_CASSANDRA_READER_LOG_LEVEL" envDefault:"info"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -88,6 +91,11 @@ func main() {

hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(repo, tc, auth, svcName), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

// Start servers
g.Go(func() error {
return hs.Start()
Expand Down
17 changes: 13 additions & 4 deletions cmd/cassandra-writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"

"github.com/gocql/gocql"
"github.com/mainflux/mainflux/consumers"
"github.com/mainflux/mainflux/consumers/writers/api"
Expand All @@ -34,10 +37,11 @@ const (
)

type config struct {
LogLevel string `env:"MF_CASSANDRA_WRITER_LOG_LEVEL" envDefault:"info"`
ConfigPath string `env:"MF_CASSANDRA_WRITER_CONFIG_PATH" envDefault:"/config.toml"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"localhost:6831"`
LogLevel string `env:"MF_CASSANDRA_WRITER_LOG_LEVEL" envDefault:"info"`
ConfigPath string `env:"MF_CASSANDRA_WRITER_CONFIG_PATH" envDefault:"/config.toml"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"localhost:6831"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -98,6 +102,11 @@ func main() {

hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svcName), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

// Start servers
g.Go(func() error {
return hs.Start()
Expand Down
17 changes: 13 additions & 4 deletions cmd/certs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"

"github.com/mainflux/mainflux/certs"
"github.com/mainflux/mainflux/certs/api"
vault "github.com/mainflux/mainflux/certs/pki"
Expand Down Expand Up @@ -37,10 +40,11 @@ const (
)

type config struct {
LogLevel string `env:"MF_CERTS_LOG_LEVEL" envDefault:"info"`
CertsURL string `env:"MF_SDK_CERTS_URL" envDefault:"http://localhost"`
ThingsURL string `env:"MF_THINGS_URL" envDefault:"http://things:9000"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
LogLevel string `env:"MF_CERTS_LOG_LEVEL" envDefault:"info"`
CertsURL string `env:"MF_SDK_CERTS_URL" envDefault:"http://localhost"`
ThingsURL string `env:"MF_THINGS_URL" envDefault:"http://things:9000"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`

// Sign and issue certificates without 3rd party PKI
SignCAPath string `env:"MF_CERTS_SIGN_CA_PATH" envDefault:"ca.crt"`
Expand Down Expand Up @@ -101,6 +105,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc, logger), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
14 changes: 11 additions & 3 deletions cmd/coap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/coap"
"github.com/mainflux/mainflux/coap/api"
"github.com/mainflux/mainflux/coap/tracing"
Expand All @@ -36,9 +38,10 @@ const (
)

type config struct {
LogLevel string `env:"MF_INFLUX_READER_LOG_LEVEL" envDefault:"info"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
LogLevel string `env:"MF_INFLUX_READER_LOG_LEVEL" envDefault:"info"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -101,6 +104,11 @@ func main() {
}
cs := coapserver.New(ctx, cancel, svcName, coapServerConfig, api.MakeCoAPHandler(svc, logger), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
14 changes: 11 additions & 3 deletions cmd/http/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"
adapter "github.com/mainflux/mainflux/http"
"github.com/mainflux/mainflux/http/api"
"github.com/mainflux/mainflux/http/tracing"
Expand Down Expand Up @@ -37,9 +39,10 @@ const (
)

type config struct {
LogLevel string `env:"MF_HTTP_ADAPTER_LOG_LEVEL" envDefault:"info"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
LogLevel string `env:"MF_HTTP_ADAPTER_LOG_LEVEL" envDefault:"info"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -89,6 +92,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svc), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
13 changes: 11 additions & 2 deletions cmd/influxdb-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"

influxdb2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/mainflux/mainflux/internal"
authClient "github.com/mainflux/mainflux/internal/clients/grpc/auth"
Expand All @@ -34,8 +37,9 @@ const (
)

type config struct {
LogLevel string `env:"MF_INFLUX_READER_LOG_LEVEL" envDefault:"info"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
LogLevel string `env:"MF_INFLUX_READER_LOG_LEVEL" envDefault:"info"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -91,6 +95,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(repo, tc, auth, svcName), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
16 changes: 12 additions & 4 deletions cmd/influxdb-writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/consumers"
"github.com/mainflux/mainflux/consumers/writers/api"
"github.com/mainflux/mainflux/consumers/writers/influxdb"
Expand All @@ -33,10 +35,11 @@ const (
)

type config struct {
LogLevel string `env:"MF_INFLUX_WRITER_LOG_LEVEL" envDefault:"info"`
ConfigPath string `env:"MF_INFLUX_WRITER_CONFIG_PATH" envDefault:"/config.toml"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"localhost:6831"`
LogLevel string `env:"MF_INFLUX_WRITER_LOG_LEVEL" envDefault:"info"`
ConfigPath string `env:"MF_INFLUX_WRITER_CONFIG_PATH" envDefault:"/config.toml"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"localhost:6831"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -109,6 +112,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svcName), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
8 changes: 8 additions & 0 deletions cmd/lora/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

mqttPaho "github.com/eclipse/paho.mqtt.golang"
r "github.com/go-redis/redis/v8"
chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/internal"
"github.com/mainflux/mainflux/internal/env"
"github.com/mainflux/mainflux/internal/server"
Expand Down Expand Up @@ -54,6 +56,7 @@ type config struct {
ESConsumerName string `env:"MF_LORA_ADAPTER_EVENT_CONSUMER" envDefault:"lora"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"localhost:6831"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -113,6 +116,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
12 changes: 10 additions & 2 deletions cmd/mongodb-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/internal"
authClient "github.com/mainflux/mainflux/internal/clients/grpc/auth"
thingsClient "github.com/mainflux/mainflux/internal/clients/grpc/things"
Expand All @@ -34,8 +36,9 @@ const (
)

type config struct {
LogLevel string `env:"MF_MONGO_READER_LOG_LEVEL" envDefault:"info"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
LogLevel string `env:"MF_MONGO_READER_LOG_LEVEL" envDefault:"info"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"http://jaeger:14268/api/traces"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -79,6 +82,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(repo, tc, auth, svcName), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
16 changes: 12 additions & 4 deletions cmd/mongodb-writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"log"
"os"

chclient "github.com/mainflux/callhome/pkg/client"
"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/consumers"
"github.com/mainflux/mainflux/consumers/writers/api"
"github.com/mainflux/mainflux/consumers/writers/mongodb"
Expand All @@ -35,10 +37,11 @@ const (
)

type config struct {
LogLevel string `env:"MF_MONGO_WRITER_LOG_LEVEL" envDefault:"info"`
ConfigPath string `env:"MF_MONGO_WRITER_CONFIG_PATH" envDefault:"/config.toml"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"localhost:6831"`
LogLevel string `env:"MF_MONGO_WRITER_LOG_LEVEL" envDefault:"info"`
ConfigPath string `env:"MF_MONGO_WRITER_CONFIG_PATH" envDefault:"/config.toml"`
BrokerURL string `env:"MF_BROKER_URL" envDefault:"nats://localhost:4222"`
JaegerURL string `env:"MF_JAEGER_URL" envDefault:"localhost:6831"`
SendTelemetry bool `env:"MF_SEND_TELEMETRY" envDefault:"true"`
}

func main() {
Expand Down Expand Up @@ -90,6 +93,11 @@ func main() {
}
hs := httpserver.New(ctx, cancel, svcName, httpServerConfig, api.MakeHandler(svcName), logger)

if cfg.SendTelemetry {
chc := chclient.New(svcName, mainflux.Version, logger, cancel)
go chc.CallHome(ctx)
}

g.Go(func() error {
return hs.Start()
})
Expand Down
Loading