MCPcopy
hub / github.com/elastic/go-elasticsearch / main

Function main

_examples/instrumentation/apmelasticsearch.go:70–316  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70func main() {
71 log.SetFlags(0)
72 start := time.Now()
73
74 // Create new elasticsearch client ...
75 //
76 es, err := elasticsearch.New(
77 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
78 // ... using the "apmelasticsearch" wrapper for instrumentation
79 elasticsearch.WithTransportOptions(elastictransport.WithTransport(apmelasticsearch.WrapRoundTripper(http.DefaultTransport))),
80 // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
81 )
82 if err != nil {
83 log.Fatalf("ERROR: %s", err)
84 }
85
86 // Set up the "done" channel
87 //
88 done := make(chan os.Signal)
89 signal.Notify(done, os.Interrupt)
90
91 // Set up tickers
92 //
93 tickers := struct {
94 Info *time.Ticker
95 Index *time.Ticker
96 Health *time.Ticker
97 Search *time.Ticker
98 }{
99 Info: time.NewTicker(time.Second),
100 Index: time.NewTicker(500 * time.Millisecond),
101 Health: time.NewTicker(5 * time.Second),
102 Search: time.NewTicker(10 * time.Second),
103 }
104 defer tickers.Info.Stop()
105 defer tickers.Index.Stop()
106 defer tickers.Health.Stop()
107 defer tickers.Search.Stop()
108
109 // Initialize the context
110 //
111 ctx := context.Background()
112
113 // Perform API calls
114 //
115 for {
116 select {
117 case <-done:
118 fmt.Print("\n")
119 fmt.Println(strings.Repeat("━", tWidth))
120 faint.Printf("Finished in %s\n\n", time.Now().Sub(start).Truncate(time.Second))
121 return
122
123 // -> Info
124 //
125 case <-tickers.Info.C:
126 func() {
127 // >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Callers

nothing calls this directly

Calls 15

PrintfMethod · 0.80
CloseMethod · 0.65
StopMethod · 0.45
TruncateMethod · 0.45
EndMethod · 0.45
InfoMethod · 0.45
WithContextMethod · 0.45
StatusMethod · 0.45
FormatMethod · 0.45
IndexMethod · 0.45
HealthMethod · 0.45
WithLevelMethod · 0.45

Tested by

no test coverage detected