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
6a2cb883
Commit
6a2cb883
authored
Aug 06, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
14a9ec87
f731f6aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
3 deletions
+37
-3
HttpExchangeTracer.java
...framework/boot/actuate/trace/http/HttpExchangeTracer.java
+5
-2
HttpExchangeTracerTests.java
...work/boot/actuate/trace/http/HttpExchangeTracerTests.java
+30
-0
production-ready-features.adoc
...oot-docs/src/main/asciidoc/production-ready-features.adoc
+2
-1
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java
View file @
6a2cb883
...
...
@@ -127,8 +127,11 @@ public class HttpExchangeTracer {
@Override
public
Map
<
String
,
List
<
String
>>
getHeaders
()
{
return
getHeadersIfIncluded
(
Include
.
REQUEST_HEADERS
,
this
.
delegate
::
getHeaders
,
this
::
includedHeader
);
Map
<
String
,
List
<
String
>>
headers
=
getHeadersIfIncluded
(
Include
.
REQUEST_HEADERS
,
this
.
delegate
::
getHeaders
,
this
::
includedHeader
);
postProcessRequestHeaders
(
headers
);
return
headers
;
}
private
boolean
includedHeader
(
String
name
)
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracerTests.java
View file @
6a2cb883
...
...
@@ -29,6 +29,8 @@ import org.junit.Test;
import
org.springframework.boot.actuate.trace.http.HttpTrace.Request
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
...
...
@@ -89,6 +91,19 @@ public class HttpExchangeTracerTests {
assertThat
(
request
.
getHeaders
()).
containsOnlyKeys
(
HttpHeaders
.
ACCEPT
);
}
@Test
public
void
requestHeadersCanBeCustomized
()
{
MultiValueMap
<
String
,
String
>
headers
=
new
LinkedMultiValueMap
<>();
headers
.
add
(
"to-remove"
,
"test"
);
headers
.
add
(
"test"
,
"value"
);
HttpTrace
trace
=
new
RequestHeadersFilterHttpExchangeTracer
()
.
receivedRequest
(
createRequest
(
headers
));
Request
request
=
trace
.
getRequest
();
assertThat
(
request
.
getHeaders
()).
containsOnlyKeys
(
"test"
,
"to-add"
);
assertThat
(
request
.
getHeaders
().
get
(
"test"
)).
containsExactly
(
"value"
);
assertThat
(
request
.
getHeaders
().
get
(
"to-add"
)).
containsExactly
(
"42"
);
}
@Test
public
void
authorizationHeaderIsNotIncludedByDefault
()
{
HttpTrace
trace
=
new
HttpExchangeTracer
(
EnumSet
.
of
(
Include
.
REQUEST_HEADERS
))
...
...
@@ -332,4 +347,19 @@ public class HttpExchangeTracerTests {
return
output
.
toString
();
}
private
static
class
RequestHeadersFilterHttpExchangeTracer
extends
HttpExchangeTracer
{
RequestHeadersFilterHttpExchangeTracer
()
{
super
(
EnumSet
.
of
(
Include
.
REQUEST_HEADERS
));
}
@Override
protected
void
postProcessRequestHeaders
(
Map
<
String
,
List
<
String
>>
headers
)
{
headers
.
remove
(
"to-remove"
);
headers
.
putIfAbsent
(
"to-add"
,
Collections
.
singletonList
(
"42"
));
}
}
}
spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
View file @
6a2cb883
...
...
@@ -1988,7 +1988,8 @@ endpoint and obtain basic information about the last 100 request-response exchan
[[production-ready-http-tracing-custom]]
=== Custom HTTP tracing
To customize the items that are included in each trace, use the
`management.trace.http.include` configuration property.
`management.trace.http.include` configuration property. For advanced customization,
consider registering your own `HttpExchangeTracer` implementation.
By default, an `InMemoryHttpTraceRepository` that stores traces for the last 100
request-response exchanges is used. If you need to expand the capacity, you can define
...
...
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