Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
027e7ed
Import Loki usagestats package
zalegrala Jun 2, 2022
7d17f72
Begin implementing usagestats package
zalegrala Jun 7, 2022
abc94fa
Begin integrating backend into module init
zalegrala Jun 7, 2022
6b8fc59
Add BuildVersion() to build package
zalegrala Jun 8, 2022
3e55eb1
Update vendor
zalegrala Jun 8, 2022
e78f3db
Update backend.Raw interfaces for error handling and object deletion
zalegrala Jun 8, 2022
45ca107
Add UsageReport dependency for main components
zalegrala Jun 8, 2022
46420d5
Use backend.ErrDoesNotExist in place of interface extension
zalegrala Jun 9, 2022
f0305a0
Updates for tempo implementation
zalegrala Jun 9, 2022
57728ae
Update tests
zalegrala Jun 9, 2022
61a29e6
Add metrics generator reporting
zalegrala Jun 9, 2022
67b357c
Add replication_factor usage metric
zalegrala Jun 10, 2022
ebc6b17
Add store configuration usage metrics
zalegrala Jun 10, 2022
3824487
Update vendor
zalegrala Jun 27, 2022
f578555
UsageReport requires MemberlistKV for the store
zalegrala Jun 27, 2022
42cfac4
Include ring kv store stat
zalegrala Jun 27, 2022
bc9f792
Include frontend version stats
zalegrala Jun 27, 2022
c68266b
Include feature stats
zalegrala Jun 27, 2022
de176c1
Include receiver stats
zalegrala Jun 27, 2022
86d76f6
Include missed feature stat
zalegrala Jun 27, 2022
04d2dfd
Include docs on how to disable the usage report
zalegrala Jun 28, 2022
1a2bfdf
Update changelog
zalegrala Jun 28, 2022
61603db
Include Loki attribution in `usagestats` package
zalegrala Jun 30, 2022
d4f9ae6
Rename stats
zalegrala Jun 30, 2022
460cec9
Fix stat reference
zalegrala Jul 5, 2022
04483c3
Call out storage dependency for distributor
zalegrala Jul 11, 2022
afbaaf3
Go mod tidy
zalegrala Jul 11, 2022
382fada
Raise log level of reporting message
zalegrala Jul 11, 2022
5a3ba02
Take docs suggestions
zalegrala Jul 13, 2022
0fbff99
Move backoff defaults into config defaults
zalegrala Jul 13, 2022
aaebdd1
Remove DeleteObject interface extension
zalegrala Jul 13, 2022
1c135b6
Include ErrBadSeedFile to indicate new seed generation should proceed
zalegrala Jul 13, 2022
2e0da06
Handle ErrBadSeedFile
zalegrala Jul 13, 2022
77f9fa8
Update vendor
zalegrala Jul 13, 2022
c0e430e
Update vendor
zalegrala Jul 18, 2022
7160417
Update config handling to use prefix
zalegrala Jul 19, 2022
a5988f9
Tidy up for PR feedback
zalegrala Jul 29, 2022
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* [FEATURE] Mark `log_received_traces` as deprecated. New flag is `log_received_spans`.
Extend distributor spans logger with optional features to include span attributes and a filter by error status. [#1465](https://github.com/grafana/tempo/pull/1465) (@faustodavid)
* [FEATURE] Add tags option for s3 backends. This allows new objects to be written with the configured tags. [#1442](https://github.com/grafana/tempo/pull/1442) (@stevenbrookes)
* [FEATURE] Add anonymous usage reporting, enabled by default. [#1481](https://github.com/grafana/tempo/pull/1481) (@zalegrala)
**BREAKING CHANGE** As part of the usage stats inclusion, the distributor will also require access to the store. This is required so the distirbutor can know which cluster it should be reporting membership of.
* [CHANGE] metrics-generator: Changed added metric label `instance` to `__metrics_gen_instance` to reduce collisions with custom dimensions. [#1439](https://github.com/grafana/tempo/pull/1439) (@joe-elliott)
* [CHANGE] Don't enforce `max_bytes_per_tag_values_query` when set to 0. [#1447](https://github.com/grafana/tempo/pull/1447) (@joe-elliott)
* [CHANGE] Add new querier service in deployment jsonnet to serve `/status` endpoint. [#1474](https://github.com/grafana/tempo/pull/1474) (@annanay25)
Expand Down
30 changes: 30 additions & 0 deletions cmd/tempo/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/grafana/tempo/modules/overrides"
"github.com/grafana/tempo/modules/querier"
"github.com/grafana/tempo/modules/storage"
"github.com/grafana/tempo/pkg/usagestats"
"github.com/grafana/tempo/pkg/util"
"github.com/grafana/tempo/pkg/util/log"
)
Expand All @@ -49,6 +50,11 @@ var (
[]string{"feature"},
nil,
)

statFeatureEnabledMetricsGenerator = usagestats.NewInt("feature_enabled_metrics_generator")
statFeatureEnabledAuth = usagestats.NewInt("feature_enabled_auth_stats")
statFeatureEnabledMultitenancy = usagestats.NewInt("feature_enabled_multitenancy")
statFeatureEnabledSearch = usagestats.NewInt("feature_enabled_search")
)

// App is the root datastructure.
Expand All @@ -66,13 +72,15 @@ type App struct {
ingester *ingester.Ingester
generator *generator.Generator
store storage.Store
usageReport *usagestats.Reporter
MemberlistKV *memberlist.KVInitService

HTTPAuthMiddleware middleware.Interface
TracesConsumerMiddleware receiver.Middleware

ModuleManager *modules.Manager
serviceMap map[string]services.Service
deps map[string][]string
}

// New makes a new app.
Expand All @@ -81,6 +89,28 @@ func New(cfg Config) (*App, error) {
cfg: cfg,
}

usagestats.Edition("oss")

statFeatureEnabledAuth.Set(0)
if cfg.AuthEnabled {
statFeatureEnabledAuth.Set(1)
}

statFeatureEnabledMetricsGenerator.Set(0)
if cfg.MetricsGeneratorEnabled {
statFeatureEnabledMetricsGenerator.Set(1)
}

statFeatureEnabledMultitenancy.Set(0)
if cfg.SearchEnabled {
statFeatureEnabledMultitenancy.Set(1)
}

statFeatureEnabledSearch.Set(0)
if cfg.SearchEnabled {
statFeatureEnabledSearch.Set(1)
}

app.setupAuthMiddleware()

if err := app.setupModuleManager(); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion cmd/tempo/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/grafana/tempo/modules/overrides"
"github.com/grafana/tempo/modules/querier"
"github.com/grafana/tempo/modules/storage"
"github.com/grafana/tempo/pkg/usagestats"
"github.com/grafana/tempo/pkg/util"
"github.com/grafana/tempo/pkg/util/log"
"github.com/grafana/tempo/tempodb"
Expand Down Expand Up @@ -46,6 +47,7 @@ type Config struct {
StorageConfig storage.Config `yaml:"storage,omitempty"`
LimitsConfig overrides.Limits `yaml:"overrides,omitempty"`
MemberlistKV memberlist.KVConfig `yaml:"memberlist,omitempty"`
UsageReport usagestats.Config `yaml:"usage_report,omitempty"`
}

func newDefaultConfig() *Config {
Expand Down Expand Up @@ -107,7 +109,7 @@ func (c *Config) RegisterFlagsAndApplyDefaults(prefix string, f *flag.FlagSet) {
c.Frontend.RegisterFlagsAndApplyDefaults(util.PrefixConfig(prefix, "frontend"), f)
c.Compactor.RegisterFlagsAndApplyDefaults(util.PrefixConfig(prefix, "compactor"), f)
c.StorageConfig.RegisterFlagsAndApplyDefaults(util.PrefixConfig(prefix, "storage"), f)

c.UsageReport.RegisterFlagsAndApplyDefaults(util.PrefixConfig(prefix, "reporting"), f)
}

// MultitenancyIsEnabled checks if multitenancy is enabled
Expand Down
91 changes: 85 additions & 6 deletions cmd/tempo/app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ import (
"github.com/grafana/tempo/pkg/api"
tempo_ring "github.com/grafana/tempo/pkg/ring"
"github.com/grafana/tempo/pkg/tempopb"
"github.com/grafana/tempo/pkg/usagestats"
"github.com/grafana/tempo/pkg/util/log"
util_log "github.com/grafana/tempo/pkg/util/log"
"github.com/grafana/tempo/tempodb/backend"
"github.com/grafana/tempo/tempodb/backend/azure"
"github.com/grafana/tempo/tempodb/backend/gcs"
"github.com/grafana/tempo/tempodb/backend/local"
"github.com/grafana/tempo/tempodb/backend/s3"
)

// The various modules that make up tempo.
Expand All @@ -47,6 +54,7 @@ const (
MemberlistKV string = "memberlist-kv"
SingleBinary string = "all"
ScalableSingleBinary string = "scalable-single-binary"
UsageReport string = "usage-report"
)

func (t *App) initServer() (services.Service, error) {
Expand Down Expand Up @@ -283,6 +291,7 @@ func (t *App) initMemberlistKV() (services.Service, error) {
t.cfg.MemberlistKV.MetricsNamespace = metricsNamespace
t.cfg.MemberlistKV.Codecs = []codec.Codec{
ring.GetCodec(),
usagestats.JSONCodec,
}

dnsProviderReg := prometheus.WrapRegistererWithPrefix(
Expand All @@ -306,6 +315,48 @@ func (t *App) initMemberlistKV() (services.Service, error) {
return t.MemberlistKV, nil
}

func (t *App) initUsageReport() (services.Service, error) {
if !t.cfg.UsageReport.Enabled {
return nil, nil
}

t.cfg.UsageReport.Leader = false
if t.isModuleActive(Ingester) {
t.cfg.UsageReport.Leader = true
}

usagestats.Target(t.cfg.Target)

var err error
var reader backend.RawReader
var writer backend.RawWriter

switch t.cfg.StorageConfig.Trace.Backend {
Comment thread
joe-elliott marked this conversation as resolved.
case "local":
reader, writer, _, err = local.New(t.cfg.StorageConfig.Trace.Local)
case "gcs":
reader, writer, _, err = gcs.New(t.cfg.StorageConfig.Trace.GCS)
case "s3":
reader, writer, _, err = s3.New(t.cfg.StorageConfig.Trace.S3)
case "azure":
reader, writer, _, err = azure.New(t.cfg.StorageConfig.Trace.Azure)
default:
err = fmt.Errorf("unknown backend %s", t.cfg.StorageConfig.Trace.Backend)
}

if err != nil {
return nil, fmt.Errorf("failed to initialize usage report: %w", err)
}

ur, err := usagestats.NewReporter(t.cfg.UsageReport, t.cfg.Ingester.LifecyclerConfig.RingConfig.KVStore, reader, writer, util_log.Logger, prometheus.DefaultRegisterer)
if err != nil {
level.Info(util_log.Logger).Log("msg", "failed to initialize usage report", "err", err)
return nil, nil
}
t.usageReport = ur
return ur, nil
}

func (t *App) setupModuleManager() error {
mm := modules.NewManager(log.Logger)

Expand All @@ -323,22 +374,24 @@ func (t *App) setupModuleManager() error {
mm.RegisterModule(Store, t.initStore, modules.UserInvisibleModule)
mm.RegisterModule(SingleBinary, nil)
mm.RegisterModule(ScalableSingleBinary, nil)
mm.RegisterModule(UsageReport, t.initUsageReport)

deps := map[string][]string{
// Server: nil,
// Store: nil,
Overrides: {Server},
MemberlistKV: {Server},
QueryFrontend: {Store, Server, Overrides},
QueryFrontend: {Store, Server, Overrides, UsageReport},
Ring: {Server, MemberlistKV},
MetricsGeneratorRing: {Server, MemberlistKV},
Distributor: {Ring, Server, Overrides},
Ingester: {Store, Server, Overrides, MemberlistKV},
MetricsGenerator: {Server, Overrides, MemberlistKV},
Querier: {Store, Ring, Overrides},
Compactor: {Store, Server, Overrides, MemberlistKV},
Distributor: {Ring, Server, Overrides, UsageReport},
Ingester: {Store, Server, Overrides, MemberlistKV, UsageReport},
MetricsGenerator: {Server, Overrides, MemberlistKV, UsageReport},
Querier: {Store, Ring, Overrides, UsageReport},
Compactor: {Store, Server, Overrides, MemberlistKV, UsageReport},
SingleBinary: {Compactor, QueryFrontend, Querier, Ingester, Distributor},
ScalableSingleBinary: {SingleBinary},
UsageReport: {MemberlistKV, Store},
}

if t.cfg.MetricsGeneratorEnabled {
Expand All @@ -355,10 +408,36 @@ func (t *App) setupModuleManager() error {
}

t.ModuleManager = mm
t.deps = deps

return nil
}

func (t *App) isModuleActive(m string) bool {
if t.cfg.Target == m {
return true
}
if t.recursiveIsModuleActive(t.cfg.Target, m) {
return true
}

return false
}

func (t *App) recursiveIsModuleActive(target, m string) bool {
if targetDeps, ok := t.deps[target]; ok {
for _, dep := range targetDeps {
if dep == m {
return true
}
if t.recursiveIsModuleActive(dep, m) {
return true
}
}
}
return false
}

func addHTTPAPIPrefix(cfg *Config, apiPath string) string {
return path.Join(cfg.HTTPAPIPrefix, apiPath)
}
Expand Down
16 changes: 15 additions & 1 deletion cmd/tempo/build/build.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package build

import "github.com/prometheus/common/version"
import (
"github.com/prometheus/common/version"
prom "github.com/prometheus/prometheus/web/api/v1"
)

// Version information passed to Prometheus version package.
// Package path as used by linker changes based on vendoring being used or not,
Expand All @@ -21,3 +24,14 @@ func init() {
version.BuildUser = BuildUser
version.BuildDate = BuildDate
}

func GetVersion() prom.PrometheusVersion {
return prom.PrometheusVersion{
Version: version.Version,
Revision: version.Revision,
Branch: version.Branch,
BuildUser: version.BuildUser,
BuildDate: version.BuildDate,
GoVersion: version.GoVersion,
}
}
17 changes: 17 additions & 0 deletions docs/tempo/website/configuration/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This document explains the configuration options for Tempo as well as the detail
- [memberlist](#memberlist)
- [overrides](#overrides)
- [search](#search)
- [usage-report](#usage-report)

#### Use environment variables in the configuration

Expand Down Expand Up @@ -1144,3 +1145,19 @@ search_enabled: true
```

Additional search-related settings are available in the [distributor](#distributor) and [ingester](#ingester) sections.

Comment thread
zalegrala marked this conversation as resolved.
## Usage-report

By default, Tempo will report anonymous usage data about the shape of a
deployment to Grafana Labs. This data is used to determine how common the
deployment of certain features are, if a feature flag has been enabled,
replication factor or compression levels, etc.

Reporting is controlled by a configuration option. You can disable the
automatic reporting of this generic information using the following
configuration:

```yaml
usage_report:
reporting_enabled: false
```
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ require (
github.com/hashicorp/go-plugin v1.4.3
github.com/jaegertracing/jaeger v1.31.0
github.com/jedib0t/go-pretty/v6 v6.2.4
github.com/json-iterator/go v1.1.12
github.com/jsternberg/zap-logfmt v1.2.0
github.com/klauspost/compress v1.15.7
github.com/minio/minio-go/v7 v7.0.16-0.20211116163909-d00629356463
Expand Down Expand Up @@ -127,6 +128,7 @@ require (
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
Expand Down Expand Up @@ -167,7 +169,7 @@ require (
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/knadh/koanf v1.4.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ github.com/jsternberg/zap-logfmt v1.2.0 h1:1v+PK4/B48cy8cfQbxL4FmmNZrjnIMr2BsnyE
github.com/jsternberg/zap-logfmt v1.2.0/go.mod h1:kz+1CUmCutPWABnNkOu9hOHKdT2q3TDYCcsFy9hpqb0=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
Expand Down
22 changes: 22 additions & 0 deletions modules/distributor/receiver/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

"github.com/grafana/tempo/pkg/tempopb"
v1 "github.com/grafana/tempo/pkg/tempopb/trace/v1"
"github.com/grafana/tempo/pkg/usagestats"
"github.com/grafana/tempo/pkg/util/log"
)

Expand All @@ -51,6 +52,12 @@ var (
Help: "Records the amount of time to push a batch to the ingester.",
Buckets: prom_client.DefBuckets,
})

statReceiverOtlp = usagestats.NewInt("receiver_enabled_otlp")
statReceiverJaeger = usagestats.NewInt("receiver_enabled_jaeger")
statReceiverZipkin = usagestats.NewInt("receiver_enabled_zipkin")
statReceiverOpencensus = usagestats.NewInt("receiver_enabled_opencensus")
statReceiverKafka = usagestats.NewInt("receiver_enabled_kafka")
)

type BatchPusher interface {
Expand Down Expand Up @@ -96,6 +103,21 @@ func New(receiverCfg map[string]interface{}, pusher BatchPusher, middleware Midd
return nil, err
}

for recv := range receiverCfg {
switch recv {
case "otlp":
statReceiverOtlp.Set(1)
case "jaeger":
statReceiverJaeger.Set(1)
case "zipkin":
statReceiverZipkin.Set(1)
case "opencensus":
statReceiverOpencensus.Set(1)
case "kafka":
statReceiverKafka.Set(1)
}
}

p := config.NewMapFromStringMap(map[string]interface{}{
"receivers": receiverCfg,
})
Expand Down
Loading