Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
e061043c
Commit
e061043c
authored
Apr 24, 2015
by
Dawn Chen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7327 from yifan-gu/metrics
kubelet/metrics: Move instrumented_docker.go to dockertools.
parents
c3ce410c
6c98b9da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
23 deletions
+21
-23
instrumented_docker.go
pkg/kubelet/dockertools/instrumented_docker.go
+20
-22
kubelet.go
pkg/kubelet/kubelet.go
+1
-1
No files found.
pkg/kubelet/
metric
s/instrumented_docker.go
→
pkg/kubelet/
dockertool
s/instrumented_docker.go
View file @
e061043c
...
@@ -14,23 +14,21 @@ See the License for the specific language governing permissions and
...
@@ -14,23 +14,21 @@ See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
*/
*/
package
metric
s
package
dockertool
s
import
(
import
(
"time"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/
dockertool
s"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/
metric
s"
docker
"github.com/fsouza/go-dockerclient"
"github.com/fsouza/go-dockerclient"
)
)
var
_
dockertools
.
DockerInterface
=
instrumentedDockerInterface
{}
type
instrumentedDockerInterface
struct
{
type
instrumentedDockerInterface
struct
{
client
dockertools
.
DockerInterface
client
DockerInterface
}
}
// Creates an instrumented DockerInterface from an existing DockerInterface.
// Creates an instrumented DockerInterface from an existing DockerInterface.
func
NewInstrumentedDockerInterface
(
dockerClient
dockertools
.
DockerInterface
)
dockertools
.
DockerInterface
{
func
NewInstrumentedDockerInterface
(
dockerClient
DockerInterface
)
DockerInterface
{
return
instrumentedDockerInterface
{
return
instrumentedDockerInterface
{
client
:
dockerClient
,
client
:
dockerClient
,
}
}
...
@@ -39,7 +37,7 @@ func NewInstrumentedDockerInterface(dockerClient dockertools.DockerInterface) do
...
@@ -39,7 +37,7 @@ func NewInstrumentedDockerInterface(dockerClient dockertools.DockerInterface) do
func
(
in
instrumentedDockerInterface
)
ListContainers
(
options
docker
.
ListContainersOptions
)
([]
docker
.
APIContainers
,
error
)
{
func
(
in
instrumentedDockerInterface
)
ListContainers
(
options
docker
.
ListContainersOptions
)
([]
docker
.
APIContainers
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"list_containers"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"list_containers"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
ListContainers
(
options
)
return
in
.
client
.
ListContainers
(
options
)
}
}
...
@@ -47,7 +45,7 @@ func (in instrumentedDockerInterface) ListContainers(options docker.ListContaine
...
@@ -47,7 +45,7 @@ func (in instrumentedDockerInterface) ListContainers(options docker.ListContaine
func
(
in
instrumentedDockerInterface
)
InspectContainer
(
id
string
)
(
*
docker
.
Container
,
error
)
{
func
(
in
instrumentedDockerInterface
)
InspectContainer
(
id
string
)
(
*
docker
.
Container
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"inspect_container"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"inspect_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
InspectContainer
(
id
)
return
in
.
client
.
InspectContainer
(
id
)
}
}
...
@@ -55,7 +53,7 @@ func (in instrumentedDockerInterface) InspectContainer(id string) (*docker.Conta
...
@@ -55,7 +53,7 @@ func (in instrumentedDockerInterface) InspectContainer(id string) (*docker.Conta
func
(
in
instrumentedDockerInterface
)
CreateContainer
(
opts
docker
.
CreateContainerOptions
)
(
*
docker
.
Container
,
error
)
{
func
(
in
instrumentedDockerInterface
)
CreateContainer
(
opts
docker
.
CreateContainerOptions
)
(
*
docker
.
Container
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"create_container"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"create_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
CreateContainer
(
opts
)
return
in
.
client
.
CreateContainer
(
opts
)
}
}
...
@@ -63,7 +61,7 @@ func (in instrumentedDockerInterface) CreateContainer(opts docker.CreateContaine
...
@@ -63,7 +61,7 @@ func (in instrumentedDockerInterface) CreateContainer(opts docker.CreateContaine
func
(
in
instrumentedDockerInterface
)
StartContainer
(
id
string
,
hostConfig
*
docker
.
HostConfig
)
error
{
func
(
in
instrumentedDockerInterface
)
StartContainer
(
id
string
,
hostConfig
*
docker
.
HostConfig
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"start_container"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"start_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
StartContainer
(
id
,
hostConfig
)
return
in
.
client
.
StartContainer
(
id
,
hostConfig
)
}
}
...
@@ -71,7 +69,7 @@ func (in instrumentedDockerInterface) StartContainer(id string, hostConfig *dock
...
@@ -71,7 +69,7 @@ func (in instrumentedDockerInterface) StartContainer(id string, hostConfig *dock
func
(
in
instrumentedDockerInterface
)
StopContainer
(
id
string
,
timeout
uint
)
error
{
func
(
in
instrumentedDockerInterface
)
StopContainer
(
id
string
,
timeout
uint
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"stop_container"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"stop_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
StopContainer
(
id
,
timeout
)
return
in
.
client
.
StopContainer
(
id
,
timeout
)
}
}
...
@@ -79,7 +77,7 @@ func (in instrumentedDockerInterface) StopContainer(id string, timeout uint) err
...
@@ -79,7 +77,7 @@ func (in instrumentedDockerInterface) StopContainer(id string, timeout uint) err
func
(
in
instrumentedDockerInterface
)
RemoveContainer
(
opts
docker
.
RemoveContainerOptions
)
error
{
func
(
in
instrumentedDockerInterface
)
RemoveContainer
(
opts
docker
.
RemoveContainerOptions
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"remove_container"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"remove_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
RemoveContainer
(
opts
)
return
in
.
client
.
RemoveContainer
(
opts
)
}
}
...
@@ -87,7 +85,7 @@ func (in instrumentedDockerInterface) RemoveContainer(opts docker.RemoveContaine
...
@@ -87,7 +85,7 @@ func (in instrumentedDockerInterface) RemoveContainer(opts docker.RemoveContaine
func
(
in
instrumentedDockerInterface
)
InspectImage
(
image
string
)
(
*
docker
.
Image
,
error
)
{
func
(
in
instrumentedDockerInterface
)
InspectImage
(
image
string
)
(
*
docker
.
Image
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"inspect_image"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"inspect_image"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
InspectImage
(
image
)
return
in
.
client
.
InspectImage
(
image
)
}
}
...
@@ -95,7 +93,7 @@ func (in instrumentedDockerInterface) InspectImage(image string) (*docker.Image,
...
@@ -95,7 +93,7 @@ func (in instrumentedDockerInterface) InspectImage(image string) (*docker.Image,
func
(
in
instrumentedDockerInterface
)
ListImages
(
opts
docker
.
ListImagesOptions
)
([]
docker
.
APIImages
,
error
)
{
func
(
in
instrumentedDockerInterface
)
ListImages
(
opts
docker
.
ListImagesOptions
)
([]
docker
.
APIImages
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"list_images"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"list_images"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
ListImages
(
opts
)
return
in
.
client
.
ListImages
(
opts
)
}
}
...
@@ -103,7 +101,7 @@ func (in instrumentedDockerInterface) ListImages(opts docker.ListImagesOptions)
...
@@ -103,7 +101,7 @@ func (in instrumentedDockerInterface) ListImages(opts docker.ListImagesOptions)
func
(
in
instrumentedDockerInterface
)
PullImage
(
opts
docker
.
PullImageOptions
,
auth
docker
.
AuthConfiguration
)
error
{
func
(
in
instrumentedDockerInterface
)
PullImage
(
opts
docker
.
PullImageOptions
,
auth
docker
.
AuthConfiguration
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"pull_image"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"pull_image"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
PullImage
(
opts
,
auth
)
return
in
.
client
.
PullImage
(
opts
,
auth
)
}
}
...
@@ -111,7 +109,7 @@ func (in instrumentedDockerInterface) PullImage(opts docker.PullImageOptions, au
...
@@ -111,7 +109,7 @@ func (in instrumentedDockerInterface) PullImage(opts docker.PullImageOptions, au
func
(
in
instrumentedDockerInterface
)
RemoveImage
(
image
string
)
error
{
func
(
in
instrumentedDockerInterface
)
RemoveImage
(
image
string
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"remove_image"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"remove_image"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
RemoveImage
(
image
)
return
in
.
client
.
RemoveImage
(
image
)
}
}
...
@@ -119,7 +117,7 @@ func (in instrumentedDockerInterface) RemoveImage(image string) error {
...
@@ -119,7 +117,7 @@ func (in instrumentedDockerInterface) RemoveImage(image string) error {
func
(
in
instrumentedDockerInterface
)
Logs
(
opts
docker
.
LogsOptions
)
error
{
func
(
in
instrumentedDockerInterface
)
Logs
(
opts
docker
.
LogsOptions
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"logs"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"logs"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
Logs
(
opts
)
return
in
.
client
.
Logs
(
opts
)
}
}
...
@@ -127,7 +125,7 @@ func (in instrumentedDockerInterface) Logs(opts docker.LogsOptions) error {
...
@@ -127,7 +125,7 @@ func (in instrumentedDockerInterface) Logs(opts docker.LogsOptions) error {
func
(
in
instrumentedDockerInterface
)
Version
()
(
*
docker
.
Env
,
error
)
{
func
(
in
instrumentedDockerInterface
)
Version
()
(
*
docker
.
Env
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"version"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"version"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
Version
()
return
in
.
client
.
Version
()
}
}
...
@@ -135,7 +133,7 @@ func (in instrumentedDockerInterface) Version() (*docker.Env, error) {
...
@@ -135,7 +133,7 @@ func (in instrumentedDockerInterface) Version() (*docker.Env, error) {
func
(
in
instrumentedDockerInterface
)
Info
()
(
*
docker
.
Env
,
error
)
{
func
(
in
instrumentedDockerInterface
)
Info
()
(
*
docker
.
Env
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"version"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"version"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
Info
()
return
in
.
client
.
Info
()
}
}
...
@@ -143,7 +141,7 @@ func (in instrumentedDockerInterface) Info() (*docker.Env, error) {
...
@@ -143,7 +141,7 @@ func (in instrumentedDockerInterface) Info() (*docker.Env, error) {
func
(
in
instrumentedDockerInterface
)
CreateExec
(
opts
docker
.
CreateExecOptions
)
(
*
docker
.
Exec
,
error
)
{
func
(
in
instrumentedDockerInterface
)
CreateExec
(
opts
docker
.
CreateExecOptions
)
(
*
docker
.
Exec
,
error
)
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"create_exec"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"create_exec"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
CreateExec
(
opts
)
return
in
.
client
.
CreateExec
(
opts
)
}
}
...
@@ -151,7 +149,7 @@ func (in instrumentedDockerInterface) CreateExec(opts docker.CreateExecOptions)
...
@@ -151,7 +149,7 @@ func (in instrumentedDockerInterface) CreateExec(opts docker.CreateExecOptions)
func
(
in
instrumentedDockerInterface
)
StartExec
(
startExec
string
,
opts
docker
.
StartExecOptions
)
error
{
func
(
in
instrumentedDockerInterface
)
StartExec
(
startExec
string
,
opts
docker
.
StartExecOptions
)
error
{
start
:=
time
.
Now
()
start
:=
time
.
Now
()
defer
func
()
{
defer
func
()
{
DockerOperationsLatency
.
WithLabelValues
(
"start_exec"
)
.
Observe
(
SinceInMicroseconds
(
start
))
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"start_exec"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
}()
return
in
.
client
.
StartExec
(
startExec
,
opts
)
return
in
.
client
.
StartExec
(
startExec
,
opts
)
}
}
pkg/kubelet/kubelet.go
View file @
e061043c
...
@@ -165,7 +165,7 @@ func NewMainKubelet(
...
@@ -165,7 +165,7 @@ func NewMainKubelet(
if
resyncInterval
<=
0
{
if
resyncInterval
<=
0
{
return
nil
,
fmt
.
Errorf
(
"invalid sync frequency %d"
,
resyncInterval
)
return
nil
,
fmt
.
Errorf
(
"invalid sync frequency %d"
,
resyncInterval
)
}
}
dockerClient
=
metric
s
.
NewInstrumentedDockerInterface
(
dockerClient
)
dockerClient
=
dockertool
s
.
NewInstrumentedDockerInterface
(
dockerClient
)
// Wait for the Docker daemon to be up (with a timeout).
// Wait for the Docker daemon to be up (with a timeout).
waitStart
:=
time
.
Now
()
waitStart
:=
time
.
Now
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment