forked from open-telemetry/opentelemetry-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.go
180 lines (170 loc) · 6.36 KB
/
helpers.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package receivers
import (
corev1 "k8s.io/api/core/v1"
"github.com/open-telemetry/opentelemetry-operator/internal/components"
)
// registry holds a record of all known receiver parsers.
var registry = make(map[string]components.Parser)
// Register adds a new parser builder to the list of known builders.
func Register(name string, p components.Parser) {
registry[name] = p
}
// IsRegistered checks whether a parser is registered with the given name.
func IsRegistered(name string) bool {
_, ok := registry[components.ComponentType(name)]
return ok
}
// ReceiverFor returns a parser builder for the given exporter name.
func ReceiverFor(name string) components.Parser {
if parser, ok := registry[components.ComponentType(name)]; ok {
return parser
}
return components.NewSilentSinglePortParserBuilder(components.ComponentType(name), components.UnsetPort).MustBuild()
}
// NewScraperParser is an instance of a generic parser that returns nothing when called and never fails.
func NewScraperParser(name string) *components.GenericParser[any] {
return components.NewBuilder[any]().WithName(name).WithPort(components.UnsetPort).MustBuild()
}
var (
componentParsers = []components.Parser{
components.NewMultiPortReceiverBuilder("otlp").
AddPortMapping(components.NewProtocolBuilder("grpc", 4317).
WithAppProtocol(&components.GrpcProtocol).
WithTargetPort(4317)).
AddPortMapping(components.NewProtocolBuilder("http", 4318).
WithAppProtocol(&components.HttpProtocol).
WithTargetPort(4318)).
MustBuild(),
components.NewMultiPortReceiverBuilder("skywalking").
AddPortMapping(components.NewProtocolBuilder(components.GrpcProtocol, 11800).
WithTargetPort(11800).
WithAppProtocol(&components.GrpcProtocol)).
AddPortMapping(components.NewProtocolBuilder(components.HttpProtocol, 12800).
WithTargetPort(12800).
WithAppProtocol(&components.HttpProtocol)).
MustBuild(),
components.NewMultiPortReceiverBuilder("jaeger").
AddPortMapping(components.NewProtocolBuilder(components.GrpcProtocol, 14250).
WithTargetPort(14250).
WithProtocol(corev1.ProtocolTCP).
WithAppProtocol(&components.GrpcProtocol)).
AddPortMapping(components.NewProtocolBuilder("thrift_http", 14268).
WithTargetPort(14268).
WithProtocol(corev1.ProtocolTCP).
WithAppProtocol(&components.HttpProtocol)).
AddPortMapping(components.NewProtocolBuilder("thrift_compact", 6831).
WithTargetPort(6831).
WithProtocol(corev1.ProtocolUDP)).
AddPortMapping(components.NewProtocolBuilder("thrift_binary", 6832).
WithTargetPort(6832).
WithProtocol(corev1.ProtocolUDP)).
MustBuild(),
components.NewMultiPortReceiverBuilder("loki").
AddPortMapping(components.NewProtocolBuilder(components.GrpcProtocol, 9095).
WithTargetPort(9095).
WithAppProtocol(&components.GrpcProtocol)).
AddPortMapping(components.NewProtocolBuilder(components.HttpProtocol, 3100).
WithTargetPort(3100).
WithAppProtocol(&components.HttpProtocol)).
MustBuild(),
components.NewSinglePortParserBuilder("awsxray", 2000).
WithTargetPort(2000).
WithProtocol(corev1.ProtocolUDP).
MustBuild(),
components.NewSinglePortParserBuilder("carbon", 2003).
WithTargetPort(2003).
MustBuild(),
components.NewSinglePortParserBuilder("collectd", 8081).
WithTargetPort(8081).
MustBuild(),
components.NewSinglePortParserBuilder("fluentforward", 8006).
WithTargetPort(8006).
MustBuild(),
components.NewSinglePortParserBuilder("influxdb", 8086).
WithTargetPort(8086).
MustBuild(),
components.NewSinglePortParserBuilder("opencensus", 55678).
WithAppProtocol(nil).
WithTargetPort(55678).
MustBuild(),
components.NewSinglePortParserBuilder("sapm", 7276).
WithTargetPort(7276).
MustBuild(),
components.NewSinglePortParserBuilder("signalfx", 9943).
WithTargetPort(9943).
MustBuild(),
components.NewSinglePortParserBuilder("splunk_hec", 8088).
WithTargetPort(8088).
MustBuild(),
components.NewSinglePortParserBuilder("statsd", 8125).
WithProtocol(corev1.ProtocolUDP).
WithTargetPort(8125).
MustBuild(),
components.NewSinglePortParserBuilder("tcplog", components.UnsetPort).
WithProtocol(corev1.ProtocolTCP).
MustBuild(),
components.NewSinglePortParserBuilder("udplog", components.UnsetPort).
WithProtocol(corev1.ProtocolUDP).
MustBuild(),
components.NewSinglePortParserBuilder("wavefront", 2003).
WithTargetPort(2003).
MustBuild(),
components.NewSinglePortParserBuilder("zipkin", 9411).
WithAppProtocol(&components.HttpProtocol).
WithProtocol(corev1.ProtocolTCP).
WithTargetPort(3100).
MustBuild(),
components.NewBuilder[kubeletStatsConfig]().WithName("kubeletstats").
WithRbacGen(generateKubeletStatsRbacRules).
WithEnvVarGen(generateKubeletStatsEnvVars).
MustBuild(),
NewScraperParser("prometheus"),
NewScraperParser("sshcheck"),
NewScraperParser("cloudfoundry"),
NewScraperParser("vcenter"),
NewScraperParser("oracledb"),
NewScraperParser("snmp"),
NewScraperParser("googlecloudpubsub"),
NewScraperParser("chrony"),
NewScraperParser("jmx"),
NewScraperParser("podman_stats"),
NewScraperParser("pulsar"),
NewScraperParser("docker_stats"),
NewScraperParser("aerospike"),
NewScraperParser("zookeeper"),
NewScraperParser("prometheus_simple"),
NewScraperParser("saphana"),
NewScraperParser("riak"),
NewScraperParser("redis"),
NewScraperParser("rabbitmq"),
NewScraperParser("purefb"),
NewScraperParser("postgresql"),
NewScraperParser("nsxt"),
NewScraperParser("nginx"),
NewScraperParser("mysql"),
NewScraperParser("memcached"),
NewScraperParser("httpcheck"),
NewScraperParser("haproxy"),
NewScraperParser("flinkmetrics"),
NewScraperParser("couchdb"),
NewScraperParser("filelog"),
}
)
func init() {
for _, parser := range componentParsers {
Register(parser.ParserType(), parser)
}
}