Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Queue
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
EIP
Labrador
Queue
Commits
2d6832f4
Verified
Commit
2d6832f4
authored
Oct 8, 2019
by
Sander van den Oever
Browse files
Options
Downloads
Patches
Plain Diff
Use the original IP instead of Proxy IP for Sentry reports
Resolves
#250
.
parent
4dd7a4a0
Branches
feature/sentry-use-real-ip
No related tags found
1 merge request
!183
Use Real IPs instead of Proxy IP for Sentry (#250)
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/nl/tudelft/ewi/queue/factory/QueueSentryClientFactory.java
+46
-0
46 additions, 0 deletions
...l/tudelft/ewi/queue/factory/QueueSentryClientFactory.java
src/main/resources/sentry.properties.template
+2
-1
2 additions, 1 deletion
src/main/resources/sentry.properties.template
with
48 additions
and
1 deletion
src/main/java/nl/tudelft/ewi/queue/factory/QueueSentryClientFactory.java
0 → 100644
+
46
−
0
View file @
2d6832f4
/*
* Queue - A Queueing system that can be used to handle labs in higher education Copyright (C) 2016-2019 Delft
* University of Technology
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero
* General Public License as published by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program. If not,
* see <https://www.gnu.org/licenses/>.
*/
package
nl.tudelft.ewi.queue.factory
;
import
io.sentry.DefaultSentryClientFactory
;
import
io.sentry.SentryClient
;
import
io.sentry.dsn.Dsn
;
import
io.sentry.event.helper.ContextBuilderHelper
;
import
io.sentry.event.helper.ForwardedAddressResolver
;
import
io.sentry.event.helper.HttpEventBuilderHelper
;
public
class
QueueSentryClientFactory
extends
DefaultSentryClientFactory
{
/**
* Enable the ForwardedAddressResolver so we can see actual IPs in Sentry for TAM, which is hosted behind a proxy.
*
* See: https://docs.sentry.io/clients/java/config/#custom-functionality
*
* @param dsn URI can be found in Sentry settings (given appropriate access).
* @return a new Sentry Client.
*/
@Override
public
SentryClient
createSentryClient
(
final
Dsn
dsn
)
{
final
SentryClient
sentryClient
=
new
SentryClient
(
createConnection
(
dsn
),
getContextManager
(
dsn
));
// Create and use the ForwardedAddressResolver, which will use the
// X-FORWARDED-FOR header for the remote address if it exists.
final
ForwardedAddressResolver
addressResolver
=
new
ForwardedAddressResolver
();
sentryClient
.
addBuilderHelper
(
new
HttpEventBuilderHelper
(
addressResolver
));
sentryClient
.
addBuilderHelper
(
new
ContextBuilderHelper
(
sentryClient
));
return
configureSentryClient
(
sentryClient
,
dsn
);
}
}
This diff is collapsed.
Click to expand it.
src/main/resources/sentry.properties.template
+
2
−
1
View file @
2d6832f4
...
...
@@ -23,3 +23,4 @@
environment=dev
servername=localhost
stacktrace.app.packages=nl.tudelft.ewi.queue
factory=nl.tudelft.ewi.queue.factory.QueueSentryClientFactory
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment