MCPcopy
hub / github.com/grafana/tempo / main

Function main

cmd/tempo/main.go:47–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45}
46
47func main() {
48 printVersion := flag.Bool("version", false, "Print this builds version information")
49 healthCheck := flag.Bool("health", false, "Run a health check against the /ready endpoint and exit")
50 healthURL := flag.String("health.url", defaultHealthURL, "URL to check when running health check")
51 mutexProfileFraction := flag.Int("mutex-profile-fraction", 0, "Override default mutex profiling fraction.")
52 blockProfileThreshold := flag.Int("block-profile-threshold", 0, "Override default block profiling threshold.")
53
54 config, configVerify, err := loadConfig()
55 if err != nil {
56 fmt.Fprintf(os.Stderr, "failed parsing config: %v\n", err)
57 os.Exit(1)
58 }
59 if *printVersion {
60 fmt.Println(version.Print(appName))
61 os.Exit(0)
62 }
63 if *healthCheck {
64 os.Exit(RunHealthCheck(*healthURL))
65 }
66
67 // Init automemlimit if enabled
68 app.InitAutoMemLimit(config)
69
70 // Init the logger which will honor the log level set in config.Server
71 if reflect.DeepEqual(&config.Server.LogLevel, &dslog.Level{}) {
72 level.Error(log.Logger).Log("msg", "invalid log level")
73 os.Exit(1)
74 }
75 log.InitLogger(&config.Server)
76
77 // Verifying the config's validity and log warnings now that the logger is initialized
78 isValid := configIsValid(config)
79
80 // Exit if config.verify flag is true
81 if configVerify {
82 if !isValid {
83 os.Exit(1)
84 }
85 os.Exit(0)
86 }
87
88 // Init tracer if OTEL_TRACES_EXPORTER, OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is set
89 if os.Getenv("OTEL_TRACES_EXPORTER") != "" || os.Getenv("OTEL_EXPORTER_OTLP_ENDPOINT") != "" || os.Getenv("OTEL_EXPORTER_OTLP_TRACES_ENDPOINT") != "" {
90 shutdownTracer, err := tracing.InstallOpenTelemetryTracer(appName, config.Target, config.SpanProfiling)
91 if err != nil {
92 level.Error(log.Logger).Log("msg", "error initialising tracer", "err", err)
93 os.Exit(1)
94 }
95 defer shutdownTracer()
96 }
97
98 setMutexBlockProfiling(*mutexProfileFraction, *blockProfileThreshold)
99
100 // Start Tempo
101 t, err := app.New(*config)
102 if err != nil {
103 level.Error(log.Logger).Log("msg", "error initialising Tempo", "err", err)
104 os.Exit(1)

Callers

nothing calls this directly

Calls 14

InitAutoMemLimitFunction · 0.92
InitLoggerFunction · 0.92
NewFunction · 0.92
loadConfigFunction · 0.85
RunHealthCheckFunction · 0.85
configIsValidFunction · 0.85
setMutexBlockProfilingFunction · 0.85
BoolMethod · 0.80
IntMethod · 0.80
LogMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected