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
1a805c71
Commit
1a805c71
authored
Jun 02, 2015
by
Victor Marmol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring handling of latency recording.
parent
393368f6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
64 deletions
+53
-64
instrumented_docker.go
pkg/kubelet/dockertools/instrumented_docker.go
+53
-64
No files found.
pkg/kubelet/dockertools/instrumented_docker.go
View file @
1a805c71
...
@@ -34,130 +34,119 @@ func NewInstrumentedDockerInterface(dockerClient DockerInterface) DockerInterfac
...
@@ -34,130 +34,119 @@ func NewInstrumentedDockerInterface(dockerClient DockerInterface) DockerInterfac
}
}
}
}
// Record the duration of the operation.
func
recordOperation
(
operation
string
,
start
time
.
Time
)
{
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
operation
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}
func
(
in
instrumentedDockerInterface
)
ListContainers
(
options
docker
.
ListContainersOptions
)
([]
docker
.
APIContainers
,
error
)
{
func
(
in
instrumentedDockerInterface
)
ListContainers
(
options
docker
.
ListContainersOptions
)
([]
docker
.
APIContainers
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"list_containers"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"list_containers"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
ListContainers
(
options
)
return
in
.
client
.
ListContainers
(
options
)
}
}
func
(
in
instrumentedDockerInterface
)
InspectContainer
(
id
string
)
(
*
docker
.
Container
,
error
)
{
func
(
in
instrumentedDockerInterface
)
InspectContainer
(
id
string
)
(
*
docker
.
Container
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"inspect_container"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"inspect_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
InspectContainer
(
id
)
return
in
.
client
.
InspectContainer
(
id
)
}
}
func
(
in
instrumentedDockerInterface
)
CreateContainer
(
opts
docker
.
CreateContainerOptions
)
(
*
docker
.
Container
,
error
)
{
func
(
in
instrumentedDockerInterface
)
CreateContainer
(
opts
docker
.
CreateContainerOptions
)
(
*
docker
.
Container
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"create_container"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"create_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
CreateContainer
(
opts
)
return
in
.
client
.
CreateContainer
(
opts
)
}
}
func
(
in
instrumentedDockerInterface
)
StartContainer
(
id
string
,
hostConfig
*
docker
.
HostConfig
)
error
{
func
(
in
instrumentedDockerInterface
)
StartContainer
(
id
string
,
hostConfig
*
docker
.
HostConfig
)
error
{
start
:=
time
.
Now
()
const
operation
=
"start_container"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"start_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
StartContainer
(
id
,
hostConfig
)
return
in
.
client
.
StartContainer
(
id
,
hostConfig
)
}
}
func
(
in
instrumentedDockerInterface
)
StopContainer
(
id
string
,
timeout
uint
)
error
{
func
(
in
instrumentedDockerInterface
)
StopContainer
(
id
string
,
timeout
uint
)
error
{
start
:=
time
.
Now
()
const
operation
=
"stop_container"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"stop_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
StopContainer
(
id
,
timeout
)
return
in
.
client
.
StopContainer
(
id
,
timeout
)
}
}
func
(
in
instrumentedDockerInterface
)
RemoveContainer
(
opts
docker
.
RemoveContainerOptions
)
error
{
func
(
in
instrumentedDockerInterface
)
RemoveContainer
(
opts
docker
.
RemoveContainerOptions
)
error
{
start
:=
time
.
Now
()
const
operation
=
"remove_container"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"remove_container"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
RemoveContainer
(
opts
)
return
in
.
client
.
RemoveContainer
(
opts
)
}
}
func
(
in
instrumentedDockerInterface
)
InspectImage
(
image
string
)
(
*
docker
.
Image
,
error
)
{
func
(
in
instrumentedDockerInterface
)
InspectImage
(
image
string
)
(
*
docker
.
Image
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"inspect_image"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"inspect_image"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
InspectImage
(
image
)
return
in
.
client
.
InspectImage
(
image
)
}
}
func
(
in
instrumentedDockerInterface
)
ListImages
(
opts
docker
.
ListImagesOptions
)
([]
docker
.
APIImages
,
error
)
{
func
(
in
instrumentedDockerInterface
)
ListImages
(
opts
docker
.
ListImagesOptions
)
([]
docker
.
APIImages
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"list_images"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"list_images"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
ListImages
(
opts
)
return
in
.
client
.
ListImages
(
opts
)
}
}
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
()
const
operation
=
"pull_image"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"pull_image"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
PullImage
(
opts
,
auth
)
return
in
.
client
.
PullImage
(
opts
,
auth
)
}
}
func
(
in
instrumentedDockerInterface
)
RemoveImage
(
image
string
)
error
{
func
(
in
instrumentedDockerInterface
)
RemoveImage
(
image
string
)
error
{
start
:=
time
.
Now
()
const
operation
=
"remove_image"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"remove_image"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
RemoveImage
(
image
)
return
in
.
client
.
RemoveImage
(
image
)
}
}
func
(
in
instrumentedDockerInterface
)
Logs
(
opts
docker
.
LogsOptions
)
error
{
func
(
in
instrumentedDockerInterface
)
Logs
(
opts
docker
.
LogsOptions
)
error
{
start
:=
time
.
Now
()
const
operation
=
"logs"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"logs"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
Logs
(
opts
)
return
in
.
client
.
Logs
(
opts
)
}
}
func
(
in
instrumentedDockerInterface
)
Version
()
(
*
docker
.
Env
,
error
)
{
func
(
in
instrumentedDockerInterface
)
Version
()
(
*
docker
.
Env
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"version"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"version"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
Version
()
return
in
.
client
.
Version
()
}
}
func
(
in
instrumentedDockerInterface
)
Info
()
(
*
docker
.
Env
,
error
)
{
func
(
in
instrumentedDockerInterface
)
Info
()
(
*
docker
.
Env
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"info"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"info"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
Info
()
return
in
.
client
.
Info
()
}
}
func
(
in
instrumentedDockerInterface
)
CreateExec
(
opts
docker
.
CreateExecOptions
)
(
*
docker
.
Exec
,
error
)
{
func
(
in
instrumentedDockerInterface
)
CreateExec
(
opts
docker
.
CreateExecOptions
)
(
*
docker
.
Exec
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"create_exec"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"create_exec"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
CreateExec
(
opts
)
return
in
.
client
.
CreateExec
(
opts
)
}
}
func
(
in
instrumentedDockerInterface
)
StartExec
(
startExec
string
,
opts
docker
.
StartExecOptions
)
error
{
func
(
in
instrumentedDockerInterface
)
StartExec
(
startExec
string
,
opts
docker
.
StartExecOptions
)
error
{
start
:=
time
.
Now
()
const
operation
=
"start_exec"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"start_exec"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
StartExec
(
startExec
,
opts
)
return
in
.
client
.
StartExec
(
startExec
,
opts
)
}
}
func
(
in
instrumentedDockerInterface
)
InspectExec
(
id
string
)
(
*
docker
.
ExecInspect
,
error
)
{
func
(
in
instrumentedDockerInterface
)
InspectExec
(
id
string
)
(
*
docker
.
ExecInspect
,
error
)
{
start
:=
time
.
Now
()
const
operation
=
"inspect_exec"
defer
func
()
{
defer
recordOperation
(
operation
,
time
.
Now
())
metrics
.
DockerOperationsLatency
.
WithLabelValues
(
"inspect_exec"
)
.
Observe
(
metrics
.
SinceInMicroseconds
(
start
))
}()
return
in
.
client
.
InspectExec
(
id
)
return
in
.
client
.
InspectExec
(
id
)
}
}
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