2 Copyright 2018 The Kubernetes Authors.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
24 // DefaultBindAddress sets the default bind address for the metrics
26 // The metrics is off by default.
27 // TODO: Flip the default by changing DefaultBindAddress back to ":8080" in the v0.2.0.
28 var DefaultBindAddress = "0"
30 // NewListener creates a new TCP listener bound to the given address.
31 func NewListener(addr string) (net.Listener, error) {
33 // If the metrics bind address is empty, default to ":8080"
34 addr = DefaultBindAddress
37 // Add a case to disable metrics altogether
42 ln, err := net.Listen("tcp", addr)
44 return nil, fmt.Errorf("error listening on %s: %v", addr, err)