Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
1ba3c747
Commit
1ba3c747
authored
Oct 06, 2017
by
Andrew Newdigate
Committed by
Rémy Coutable
Oct 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gitaly feature flag metadata
parent
c7622606
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
changelogs/unreleased/gitaly_feature_flag_metadata.yml
changelogs/unreleased/gitaly_feature_flag_metadata.yml
+5
-0
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+19
-2
No files found.
changelogs/unreleased/gitaly_feature_flag_metadata.yml
0 → 100644
View file @
1ba3c747
---
title
:
Add client and call site metadata to Gitaly calls for better traceability
merge_request
:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14332
author
:
type
:
added
lib/gitlab/gitaly_client.rb
View file @
1ba3c747
...
@@ -28,6 +28,7 @@ module Gitlab
...
@@ -28,6 +28,7 @@ module Gitlab
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
.
freeze
SERVER_VERSION_FILE
=
'GITALY_SERVER_VERSION'
.
freeze
MAXIMUM_GITALY_CALLS
=
30
MAXIMUM_GITALY_CALLS
=
30
CLIENT_NAME
=
(
Sidekiq
.
server?
?
'gitlab-sidekiq'
:
'gitlab-web'
).
freeze
MUTEX
=
Mutex
.
new
MUTEX
=
Mutex
.
new
private_constant
:MUTEX
private_constant
:MUTEX
...
@@ -79,7 +80,16 @@ module Gitlab
...
@@ -79,7 +80,16 @@ module Gitlab
def
self
.
request_metadata
(
storage
)
def
self
.
request_metadata
(
storage
)
encoded_token
=
Base64
.
strict_encode64
(
token
(
storage
).
to_s
)
encoded_token
=
Base64
.
strict_encode64
(
token
(
storage
).
to_s
)
{
metadata:
{
'authorization'
=>
"Bearer
#{
encoded_token
}
"
}
}
metadata
=
{
'authorization'
=>
"Bearer
#{
encoded_token
}
"
,
'client_name'
=>
CLIENT_NAME
}
feature_stack
=
Thread
.
current
[
:gitaly_feature_stack
]
feature
=
feature_stack
&&
feature_stack
[
0
]
metadata
[
'call_site'
]
=
feature
.
to_s
if
feature
{
metadata:
metadata
}
end
end
def
self
.
token
(
storage
)
def
self
.
token
(
storage
)
...
@@ -137,7 +147,14 @@ module Gitlab
...
@@ -137,7 +147,14 @@ module Gitlab
Gitlab
::
Metrics
.
measure
(
metric_name
)
do
Gitlab
::
Metrics
.
measure
(
metric_name
)
do
# Some migrate calls wrap other migrate calls
# Some migrate calls wrap other migrate calls
allow_n_plus_1_calls
do
allow_n_plus_1_calls
do
feature_stack
=
Thread
.
current
[
:gitaly_feature_stack
]
||=
[]
feature_stack
.
unshift
(
feature
)
begin
yield
is_enabled
yield
is_enabled
ensure
feature_stack
.
shift
Thread
.
current
[
:gitaly_feature_stack
]
=
nil
if
feature_stack
.
empty?
end
end
end
end
end
end
end
...
...
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