Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
df0be2c4
Commit
df0be2c4
authored
May 04, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add git archive cache hit/miss counter
parent
eacd5b7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
internal/git/archive.go
internal/git/archive.go
+19
-1
No files found.
internal/git/archive.go
View file @
df0be2c4
...
...
@@ -19,6 +19,8 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/senddata"
"github.com/prometheus/client_golang/prometheus"
)
type
archive
struct
{
senddata
.
Prefix
}
...
...
@@ -29,7 +31,20 @@ type archiveParams struct {
CommitId
string
}
var
SendArchive
=
&
archive
{
"git-archive:"
}
var
(
SendArchive
=
&
archive
{
"git-archive:"
}
gitArchiveCache
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"gitlab_workhorse_git_archive_cache"
,
Help
:
"Cache hits and misses for 'git archive' streaming"
,
},
[]
string
{
"result"
},
)
)
func
init
()
{
prometheus
.
MustRegister
(
gitArchiveCache
)
}
func
(
a
*
archive
)
Inject
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
sendData
string
)
{
var
params
archiveParams
...
...
@@ -50,6 +65,7 @@ func (a *archive) Inject(w http.ResponseWriter, r *http.Request, sendData string
if
cachedArchive
,
err
:=
os
.
Open
(
params
.
ArchivePath
);
err
==
nil
{
defer
cachedArchive
.
Close
()
gitArchiveCache
.
WithLabelValues
(
"hit"
)
.
Inc
()
log
.
Printf
(
"Serving cached file %q"
,
params
.
ArchivePath
)
setArchiveHeaders
(
w
,
format
,
archiveFilename
)
// Even if somebody deleted the cachedArchive from disk since we opened
...
...
@@ -59,6 +75,8 @@ func (a *archive) Inject(w http.ResponseWriter, r *http.Request, sendData string
return
}
gitArchiveCache
.
WithLabelValues
(
"miss"
)
.
Inc
()
// We assume the tempFile has a unique name so that concurrent requests are
// safe. We create the tempfile in the same directory as the final cached
// archive we want to create so that we can use an atomic link(2) operation
...
...
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