Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
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
DEMO
spring-boot
Commits
958e08c4
Commit
958e08c4
authored
Jan 08, 2019
by
Brian Clozel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x' into 2.1.x
parents
6200a319
95e26ffc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
5 deletions
+38
-5
WebFluxTags.java
...boot/actuate/metrics/web/reactive/server/WebFluxTags.java
+15
-4
WebFluxTagsTests.java
...actuate/metrics/web/reactive/server/WebFluxTagsTests.java
+23
-1
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java
View file @
958e08c4
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -41,6 +41,8 @@ public final class WebFluxTags {
...
@@ -41,6 +41,8 @@ public final class WebFluxTags {
private
static
final
Tag
URI_ROOT
=
Tag
.
of
(
"uri"
,
"root"
);
private
static
final
Tag
URI_ROOT
=
Tag
.
of
(
"uri"
,
"root"
);
private
static
final
Tag
URI_UNKNOWN
=
Tag
.
of
(
"uri"
,
"UNKNOWN"
);
private
static
final
Tag
EXCEPTION_NONE
=
Tag
.
of
(
"exception"
,
"None"
);
private
static
final
Tag
EXCEPTION_NONE
=
Tag
.
of
(
"exception"
,
"None"
);
private
static
final
Tag
OUTCOME_UNKNOWN
=
Tag
.
of
(
"outcome"
,
"UNKNOWN"
);
private
static
final
Tag
OUTCOME_UNKNOWN
=
Tag
.
of
(
"outcome"
,
"UNKNOWN"
);
...
@@ -86,7 +88,10 @@ public final class WebFluxTags {
...
@@ -86,7 +88,10 @@ public final class WebFluxTags {
/**
/**
* Creates a {@code uri} tag based on the URI of the given {@code exchange}. Uses the
* Creates a {@code uri} tag based on the URI of the given {@code exchange}. Uses the
* {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern.
* {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern if
* available. Falling back to {@code REDIRECTION} for 3xx responses, {@code NOT_FOUND}
* for 404 responses, {@code root} for requests with no path info, and {@code UNKNOWN}
* for all other requests.
* @param exchange the exchange
* @param exchange the exchange
* @return the uri tag derived from the exchange
* @return the uri tag derived from the exchange
*/
*/
...
@@ -105,11 +110,17 @@ public final class WebFluxTags {
...
@@ -105,11 +110,17 @@ public final class WebFluxTags {
return
URI_NOT_FOUND
;
return
URI_NOT_FOUND
;
}
}
}
}
String
path
=
exchange
.
getRequest
().
getPath
().
value
(
);
String
path
=
getPathInfo
(
exchange
);
if
(
path
.
isEmpty
())
{
if
(
path
.
isEmpty
())
{
return
URI_ROOT
;
return
URI_ROOT
;
}
}
return
Tag
.
of
(
"uri"
,
path
);
return
URI_UNKNOWN
;
}
private
static
String
getPathInfo
(
ServerWebExchange
exchange
)
{
String
path
=
exchange
.
getRequest
().
getPath
().
value
();
String
uri
=
StringUtils
.
hasText
(
path
)
?
path
:
"/"
;
return
uri
.
replaceAll
(
"//+"
,
"/"
).
replaceAll
(
"/$"
,
""
);
}
}
/**
/**
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java
View file @
958e08c4
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -79,6 +79,28 @@ public class WebFluxTagsTests {
...
@@ -79,6 +79,28 @@ public class WebFluxTagsTests {
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"root"
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"root"
);
}
}
@Test
public
void
uriTagValueIsRootWhenRequestHasNoPatternOrPathInfo
()
{
Tag
tag
=
WebFluxTags
.
uri
(
this
.
exchange
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"root"
);
}
@Test
public
void
uriTagValueIsRootWhenRequestHasNoPatternAndSlashPathInfo
()
{
MockServerHttpRequest
request
=
MockServerHttpRequest
.
get
(
"/"
).
build
();
ServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
request
);
Tag
tag
=
WebFluxTags
.
uri
(
exchange
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"root"
);
}
@Test
public
void
uriTagValueIsUnknownWhenRequestHasNoPatternAndNonRootPathInfo
()
{
MockServerHttpRequest
request
=
MockServerHttpRequest
.
get
(
"/example"
).
build
();
ServerWebExchange
exchange
=
MockServerWebExchange
.
from
(
request
);
Tag
tag
=
WebFluxTags
.
uri
(
exchange
);
assertThat
(
tag
.
getValue
()).
isEqualTo
(
"UNKNOWN"
);
}
@Test
@Test
public
void
methodTagToleratesNonStandardHttpMethods
()
{
public
void
methodTagToleratesNonStandardHttpMethods
()
{
ServerWebExchange
exchange
=
mock
(
ServerWebExchange
.
class
);
ServerWebExchange
exchange
=
mock
(
ServerWebExchange
.
class
);
...
...
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