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
d72f5139
Commit
d72f5139
authored
Jul 08, 2020
by
dreis2211
Committed by
Andy Wilkinson
Jul 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Measure with nanoseconds in HttpExchangeTracer
See gh-22266
parent
ec3433aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
HttpExchangeTracer.java
...framework/boot/actuate/trace/http/HttpExchangeTracer.java
+7
-3
HttpTrace.java
...rg/springframework/boot/actuate/trace/http/HttpTrace.java
+9
-1
No files found.
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java
View file @
d72f5139
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -22,6 +22,7 @@ import java.util.LinkedHashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Consumer
;
import
java.util.function.Predicate
;
import
java.util.function.Supplier
;
...
...
@@ -68,8 +69,7 @@ public class HttpExchangeTracer {
*/
public
final
void
sendingResponse
(
HttpTrace
trace
,
TraceableResponse
response
,
Supplier
<
Principal
>
principal
,
Supplier
<
String
>
sessionId
)
{
setIfIncluded
(
Include
.
TIME_TAKEN
,
()
->
System
.
currentTimeMillis
()
-
trace
.
getTimestamp
().
toEpochMilli
(),
trace:
:
setTimeTaken
);
setIfIncluded
(
Include
.
TIME_TAKEN
,
()
->
calculateTimeTaken
(
trace
),
trace:
:
setTimeTaken
);
setIfIncluded
(
Include
.
SESSION_ID
,
sessionId
,
trace:
:
setSessionId
);
setIfIncluded
(
Include
.
PRINCIPAL
,
principal
,
trace:
:
setPrincipal
);
trace
.
setResponse
(
new
HttpTrace
.
Response
(
new
FilteredTraceableResponse
(
response
)));
...
...
@@ -102,6 +102,10 @@ public class HttpExchangeTracer {
.
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
Map
.
Entry
::
getValue
));
}
private
long
calculateTimeTaken
(
HttpTrace
trace
)
{
return
TimeUnit
.
NANOSECONDS
.
toMillis
(
System
.
nanoTime
()
-
trace
.
getNanoTime
());
}
private
final
class
FilteredTraceableRequest
implements
TraceableRequest
{
private
final
TraceableRequest
delegate
;
...
...
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpTrace.java
View file @
d72f5139
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -46,6 +46,8 @@ public final class HttpTrace {
private
volatile
Long
timeTaken
;
private
final
transient
long
nanoTime
;
/**
* Creates a fully-configured {@code HttpTrace} instance. Primarily for use by
* {@link HttpTraceRepository} implementations when recreating a trace from a
...
...
@@ -67,11 +69,13 @@ public final class HttpTrace {
this
.
principal
=
principal
;
this
.
session
=
session
;
this
.
timeTaken
=
timeTaken
;
this
.
nanoTime
=
0
;
}
HttpTrace
(
TraceableRequest
request
)
{
this
.
request
=
new
Request
(
request
);
this
.
timestamp
=
Instant
.
now
();
this
.
nanoTime
=
System
.
nanoTime
();
}
public
Instant
getTimestamp
()
{
...
...
@@ -118,6 +122,10 @@ public final class HttpTrace {
this
.
timeTaken
=
timeTaken
;
}
long
getNanoTime
()
{
return
this
.
nanoTime
;
}
/**
* Trace of an HTTP request.
*/
...
...
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