Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
926414a0
Commit
926414a0
authored
Jul 01, 2016
by
Bertrand Renuart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GH1155: remove Guava ImmutableMap in favour of Collections.unmodifiableMap()
Make sanitizeUrlTemplate() protected for easy sub-classing
parent
3991c8c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
DefaultMetricsTagProvider.java
...work/cloud/netflix/metrics/DefaultMetricsTagProvider.java
+14
-10
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/metrics/DefaultMetricsTagProvider.java
View file @
926414a0
...
...
@@ -14,6 +14,7 @@
package
org
.
springframework
.
cloud
.
netflix
.
metrics
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -25,8 +26,6 @@ import org.springframework.http.client.ClientHttpResponse;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.servlet.HandlerMapping
;
import
com.google.common.collect.ImmutableMap
;
/**
* @author Jon Schneider
*/
...
...
@@ -49,14 +48,19 @@ public class DefaultMetricsTagProvider implements MetricsTagProvider {
}
String
host
=
request
.
getURI
().
getHost
();
if
(
host
==
null
)
{
host
=
"none"
;
}
String
strippedUrlTemplate
=
urlTemplate
.
replaceAll
(
"^https?://[^/]+/"
,
""
);
//@formatter:off
return
ImmutableMap
.
of
(
"method"
,
request
.
getMethod
().
name
(),
"uri"
,
sanitizeUrlTemplate
(
strippedUrlTemplate
),
"status"
,
status
,
"clientName"
,
host
!=
null
?
host
:
"none"
);
//@formatter:on
Map
<
String
,
String
>
tags
=
new
HashMap
<>();
tags
.
put
(
"method"
,
request
.
getMethod
().
name
());
tags
.
put
(
"uri"
,
sanitizeUrlTemplate
(
strippedUrlTemplate
));
tags
.
put
(
"status"
,
status
);
tags
.
put
(
"clientName"
,
host
);
return
Collections
.
unmodifiableMap
(
tags
);
}
@Override
...
...
@@ -94,7 +98,7 @@ public class DefaultMetricsTagProvider implements MetricsTagProvider {
* As is, the urlTemplate is not suitable for use with Atlas, as all interactions with
* Atlas take place via query parameters
*/
pr
ivate
String
sanitizeUrlTemplate
(
String
urlTemplate
)
{
pr
otected
String
sanitizeUrlTemplate
(
String
urlTemplate
)
{
String
sanitized
=
urlTemplate
.
replaceAll
(
"/"
,
"_"
).
replaceAll
(
"[{}]"
,
"-"
);
if
(!
StringUtils
.
hasText
(
sanitized
))
{
sanitized
=
"none"
;
...
...
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