-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathir_collector.go
72 lines (58 loc) · 2.15 KB
/
ir_collector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package jaeger
import (
"github.com/blueprint-uservices/blueprint/blueprint/pkg/coreplugins/address"
"github.com/blueprint-uservices/blueprint/blueprint/pkg/coreplugins/service"
"github.com/blueprint-uservices/blueprint/blueprint/pkg/ir"
"github.com/blueprint-uservices/blueprint/plugins/docker"
"github.com/blueprint-uservices/blueprint/plugins/golang/goparser"
"github.com/blueprint-uservices/blueprint/plugins/workflow/workflowspec"
"github.com/blueprint-uservices/blueprint/runtime/plugins/jaeger"
)
// Blueprint IR node that represents the Jaeger container
type JaegerCollectorContainer struct {
docker.Container
CollectorName string
BindAddr *address.BindConfig
UIBindAddr *address.BindConfig
Iface *goparser.ParsedInterface
}
// Jaeger interface exposed to the application.
type JaegerInterface struct {
service.ServiceInterface
Wrapped service.ServiceInterface
}
func (j *JaegerInterface) GetName() string {
return "j(" + j.Wrapped.GetName() + ")"
}
func (j *JaegerInterface) GetMethods() []service.Method {
return j.Wrapped.GetMethods()
}
func newJaegerCollectorContainer(name string) (*JaegerCollectorContainer, error) {
spec, err := workflowspec.GetService[jaeger.JaegerTracer]()
if err != nil {
return nil, err
}
collector := &JaegerCollectorContainer{
CollectorName: name,
Iface: spec.Iface,
}
return collector, nil
}
func (node *JaegerCollectorContainer) Name() string {
return node.CollectorName
}
func (node *JaegerCollectorContainer) String() string {
return node.Name() + " = JaegerCollector(" + node.BindAddr.Name() + ")"
}
func (node *JaegerCollectorContainer) GetInterface(ctx ir.BuildContext) (service.ServiceInterface, error) {
iface := node.Iface.ServiceInterface(ctx)
return &JaegerInterface{Wrapped: iface}, nil
}
func (node *JaegerCollectorContainer) AddContainerArtifacts(targer docker.ContainerWorkspace) error {
return nil
}
func (node *JaegerCollectorContainer) AddContainerInstance(target docker.ContainerWorkspace) error {
node.UIBindAddr.Port = 16686
node.BindAddr.Port = 14268
return target.DeclarePrebuiltInstance(node.CollectorName, "jaegertracing/all-in-one:latest", node.BindAddr, node.UIBindAddr)
}