Skip to content

Commit 2f61fc5

Browse files
committed
Merge branch 'master' into develop
# Conflicts: # scouter.agent.java/src/main/java/scouter/xtra/http/UseridUtil.java
2 parents 0802db2 + fab908a commit 2f61fc5

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

scouter.agent.java/src/main/java/scouter/agent/Configure.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,10 @@ public static final Configure getInstance() {
202202
public boolean profile_reactor_more_checkpoint_enabled = false;
203203

204204
//Trace
205-
@ConfigDesc("User ID based(0 : Remote Address, 1 : Cookie, 2 : Scouter Cookie, 2 : Header) \n - able to set value for 1.Cookie and 3.Header \n - refer to 'trace_user_session_key'")
205+
@ConfigDesc("User ID based(0 : Remote IP Address, 1 : Cookie(JSESSIONID), 2 : Cookie(SCOUTER), 3 : Header) \n - able to set value for 1.Cookie and 3.Header \n - refer to 'trace_user_session_key'")
206206
public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:Scouter Cookie, 3:Header
207+
@ConfigDesc("Setting a cookie expired time for SCOUTER cookie when trace_user_mode is 2")
208+
public int trace_scouter_cookie_max_age = Integer.MAX_VALUE;
207209
@ConfigDesc("Setting a cookie path for SCOUTER cookie when trace_user_mode is 2")
208210
public String trace_user_cookie_path = "/";
209211

@@ -1100,6 +1102,7 @@ private void apply() {
11001102
this.profile_connection_open_fullstack_enabled = getBoolean("profile_connection_open_fullstack_enabled", false);
11011103
this.profile_connection_autocommit_status_enabled = getBoolean("profile_connection_autocommit_status_enabled", false);
11021104
this.trace_user_mode = getInt("trace_user_mode", 2);
1105+
this.trace_scouter_cookie_max_age = getInt("trace_scouter_cookie_max_age", Integer.MAX_VALUE);
11031106
this.trace_user_cookie_path = getValue("trace_user_cookie_path", "/");
11041107
this.trace_user_session_key = getValue("trace_user_session_key", "JSESSIONID");
11051108
this._trace_auto_service_enabled = getBoolean("_trace_auto_service_enabled", false);

scouter.agent.java/src/main/java/scouter/xtra/http/HttpTrace.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,16 @@ public void start(TraceContext ctx, Object req, Object res) {
251251
try {
252252
switch (conf.trace_user_mode) {
253253
case 3:
254-
ctx.userid = UseridUtil.getUseridFromHeader(request, response, conf.trace_user_session_key);
254+
ctx.userid = UseridUtil.getUseridFromHeader(request, conf.trace_user_session_key);
255255
if (ctx.userid == 0 && ctx.remoteIp != null) {
256256
ctx.userid = HashUtil.hash(ctx.remoteIp);
257257
}
258258
break;
259259
case 2:
260-
ctx.userid = UseridUtil.getUserid(request, response, conf.trace_user_cookie_path);
260+
ctx.userid = UseridUtil.getUserid(request, response, conf.trace_user_cookie_path, conf.trace_scouter_cookie_max_age);
261261
break;
262262
case 1:
263-
ctx.userid = UseridUtil.getUseridCustom(request, response, conf.trace_user_session_key);
263+
ctx.userid = UseridUtil.getUseridCustom(request, conf.trace_user_session_key);
264264
if (ctx.userid == 0 && ctx.remoteIp != null) {
265265
ctx.userid = HashUtil.hash(ctx.remoteIp);
266266
}
@@ -378,7 +378,7 @@ public void start(TraceContext ctx, Object req, Object res) {
378378
if (startTime != null) {
379379
int t = startTime.indexOf("t=");
380380
int ts = startTime.indexOf("ts=");
381-
long startMillis = 0l;
381+
long startMillis = 0L;
382382
if (t >= 0) {
383383
startMillis = Long.parseLong(startTime.substring(t + 2).trim())/1000;
384384
} else if (ts >= 0) {
@@ -395,7 +395,7 @@ public void start(TraceContext ctx, Object req, Object res) {
395395
if (startTime != null) {
396396
int t = startTime.indexOf("t=");
397397
int ts = startTime.indexOf("ts=");
398-
long startMillis = 0l;
398+
long startMillis = 0L;
399399
if (t >= 0) {
400400
startMillis = Long.parseLong(startTime.substring(t + 2).trim())/1000;
401401
} else if (ts >= 0) {

scouter.agent.java/src/main/java/scouter/xtra/http/UseridUtil.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015 the original author or authors.
33
* @https://github.com/scouter-project/scouter
44
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
77
* You may obtain a copy of the License at
88
*
@@ -12,7 +12,7 @@
1212
* distributed under the License is distributed on an "AS IS" BASIS,
1313
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
* See the License for the specific language governing permissions and
15-
* limitations under the License.
15+
* limitations under the License.
1616
*/
1717
package scouter.xtra.http;
1818

@@ -30,7 +30,7 @@
3030
public class UseridUtil {
3131
private static final String SCOUTE_R = "SCOUTER";
3232

33-
public static long getUserid(HttpServletRequest req, HttpServletResponse res, String cookiePath) {
33+
public static long getUserid(HttpServletRequest req, HttpServletResponse res, String cookiePath, int maxAge) {
3434
try {
3535
String cookie = req.getHeader("Cookie");
3636
if (cookie != null) {
@@ -53,7 +53,7 @@ public static long getUserid(HttpServletRequest req, HttpServletResponse res, St
5353
if ( cookiePath != null && cookiePath.trim().length() > 0 ) {
5454
c.setPath(cookiePath);
5555
}
56-
c.setMaxAge(Integer.MAX_VALUE);
56+
c.setMaxAge(maxAge);
5757
res.addCookie(c);
5858
} catch (Throwable t) {
5959
Logger.println("A153", t.toString());
@@ -95,7 +95,7 @@ public static long getUserid(ServerHttpRequest req, ServerHttpResponse res, Stri
9595
return 0;
9696
}
9797

98-
public static long getUseridCustom(HttpServletRequest req, HttpServletResponse res, String key) {
98+
public static long getUseridCustom(HttpServletRequest req, String key) {
9999
if (key == null || key.length() == 0)
100100
return 0;
101101
try {
@@ -147,7 +147,7 @@ public static long getUseridCustom(ServerHttpRequest req, ServerHttpResponse res
147147
return 0;
148148
}
149149

150-
public static long getUseridFromHeader(HttpServletRequest req, HttpServletResponse res, String key) {
150+
public static long getUseridFromHeader(HttpServletRequest req, String key) {
151151
if (key == null || key.length() == 0)
152152
return 0;
153153
try {

scouter.document/main/Configuration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,10 @@
527527
public boolean profile_fullstack_stmt_leak_enabled = false;
528528

529529
//Trace
530-
@ConfigDesc("User ID based(0 : Remote Address, 1 : Cookie, 2 : Scouter Cookie, 2 : Header) \n - able to set value for 1.Cookie and 3.Header \n - refer to 'trace_user_session_key'")
530+
@ConfigDesc("User ID based(0 : Remote IP Address, 1 : Cookie(JSESSIONID), 2 : Cookie(SCOUTER), 3 : Header) \n - able to set value for 1.Cookie and 3.Header \n - refer to 'trace_user_session_key'")
531531
public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:Scouter Cookie, 3:Header
532+
@ConfigDesc("Setting a cookie expired time for SCOUTER cookie when trace_user_mode is 2")
533+
public int trace_scouter_cookie_max_age = Integer.MAX_VALUE;
532534
@ConfigDesc("Setting a cookie path for SCOUTER cookie when trace_user_mode is 2")
533535
public String trace_user_cookie_path = "/";
534536

scouter.document/main/Configuration_kr.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,11 @@ public boolean sfa_dump_enabled = false;
377377
@ConfigDesc("SFA thread dump Interval(ms)")
378378
public int sfa_dump_interval_ms = 10000;
379379

380-
//miscellaneous
381-
@ConfigDesc("User ID based(0 : Remote Address, 1 : JSessionID, 2 : Scouter Cookie)")
382-
public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:SetCookie
380+
//Trace
381+
@ConfigDesc("User ID based(0 : Remote IP Address, 1 : Cookie(JSESSIONID), 2 : Cookie(SCOUTER), 3 : Header) \n - able to set value for 1.Cookie and 3.Header \n - refer to 'trace_user_session_key'")
382+
public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:Scouter Cookie, 3:Header
383+
@ConfigDesc("Setting a cookie expired time for SCOUTER cookie when trace_user_mode is 2")
384+
public int trace_scouter_cookie_max_age = Integer.MAX_VALUE;
383385
@ConfigDesc("Setting a cookie path for SCOUTER cookie when trace_user_mode is 2")
384386
public String trace_user_cookie_path = "/";
385387

0 commit comments

Comments
 (0)