MCPcopy Create free account
hub / github.com/efficientgo/e2e / deployWithMonitoring

Function deployWithMonitoring

examples/thanos/standalone.go:22–107  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

20)
21
22func deployWithMonitoring(ctx context.Context) error {
23 // Start isolated environment with given ref.
24 e, err := e2e.New()
25 if err != nil {
26 return err
27 }
28 // Make sure resources (e.g docker containers, network, dir) are cleaned.
29 defer e.Close()
30
31 mon, err := e2emon.Start(e)
32 if err != nil {
33 return err
34 }
35
36 prof, err := e2eprof.Start(e)
37 if err != nil {
38 return err
39 }
40
41 // Setup Jaeger for example purposes, on how easy is to setup tracing pipeline in e2e framework.
42 j := e.Runnable("tracing").
43 WithPorts(
44 map[string]int{
45 "http.front": 16686,
46 "jaeger.thrift": 14268,
47 }).
48 Init(e2e.StartOptions{Image: "jaegertracing/all-in-one:1.25"})
49
50 jaegerConfig := fmt.Sprintf(
51 `type: JAEGER
52config:
53 service_name: thanos
54 sampler_type: const
55 sampler_param: 1
56 endpoint: http://%s/api/traces`, j.InternalEndpoint("jaeger.thrift"),
57 )
58
59 // Create structs for Prometheus containers scraping itself.
60 p1 := e2edb.NewPrometheus(e, "prometheus-1")
61 s1 := e2edb.NewThanosSidecar(e, "sidecar-1", p1, e2edb.WithFlagOverride(map[string]string{"--tracing.config": jaegerConfig}))
62
63 p2 := e2edb.NewPrometheus(e, "prometheus-2")
64 s2 := e2edb.NewThanosSidecar(e, "sidecar-2", p2, e2edb.WithFlagOverride(map[string]string{"--tracing.config": jaegerConfig}))
65
66 // Create Thanos Query container. We can point the peer network addresses of both Prometheus instance
67 // using InternalEndpoint methods, even before they started.
68 t1 := e2edb.NewThanosQuerier(e, "query-1", []string{s1.InternalEndpoint("grpc"), s2.InternalEndpoint("grpc")}, e2edb.WithFlagOverride(map[string]string{"--tracing.config": jaegerConfig}))
69
70 // Start them.
71 if err := e2e.StartAndWaitReady(j, p1, s1, p2, s2, t1); err != nil {
72 return err
73 }
74
75 if err := merrors.New(
76 // To ensure query should have access we can check its Prometheus metric using WaitSumMetrics method. Since the metric we are looking for
77 // only appears after init, we add option to wait for it.
78 t1.WaitSumMetricsWithOptions(e2emon.Equals(2), []string{"thanos_store_nodes_grpc_connections"}, e2emon.WaitMissingMetrics()),
79 // To ensure Prometheus scraped already something ensure number of scrapes.

Callers 1

mainFunction · 0.85

Calls 12

NewFunction · 0.92
StartAndWaitReadyFunction · 0.92
CloseMethod · 0.65
StartMethod · 0.65
InitMethod · 0.65
WithPortsMethod · 0.65
RunnableMethod · 0.65
InternalEndpointMethod · 0.65
WaitSumMetricsMethod · 0.65
EndpointMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…