[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16711544#comment-16711544 ] ASF GitHub Bot commented on SCB-1065: - coveralls edited a comment on issue #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022#issuecomment-444874542 [![Coverage Status](https://coveralls.io/builds/20458947/badge)](https://coveralls.io/builds/20458947) Coverage increased (+0.006%) to 86.724% when pulling **8a52d3ab18ba3f9c03eeaec2ea3b1c356908a843 on weichao666:traceId** into **a21611163909bd075f3f7c737474e44c95f4c062 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16711460#comment-16711460 ] ASF GitHub Bot commented on SCB-1065: - coveralls commented on issue #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022#issuecomment-444874542 [![Coverage Status](https://coveralls.io/builds/20458821/badge)](https://coveralls.io/builds/20458821) Coverage increased (+0.01%) to 86.728% when pulling **8a52d3ab18ba3f9c03eeaec2ea3b1c356908a843 on weichao666:traceId** into **a21611163909bd075f3f7c737474e44c95f4c062 on apache:master**. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16709718#comment-16709718 ] ASF GitHub Bot commented on SCB-1065: - liubao68 closed pull request #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java index 932aef4c3..08dc3802a 100644 --- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java +++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java @@ -103,7 +103,7 @@ protected void setContext() throws Exception { @SuppressWarnings("unchecked") Map cseContext = JsonUtils.readValue(strCseContext.getBytes(StandardCharsets.UTF_8), Map.class); -invocation.setContext(cseContext); +invocation.mergeContext(cseContext); } public String getContext(String key) { diff --git a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java index faf37a539..d57ebe06c 100644 --- a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java +++ b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java @@ -250,6 +250,34 @@ public void setContextNormal() throws Exception { Assert.assertThat(invocation.getContext(), Matchers.hasEntry("name", "value")); } + @Test + public void setContextTraceId() throws Exception { +Map context = new HashMap<>(); +new Expectations() { + { +requestEx.getHeader(Const.CSE_CONTEXT); +result = JsonUtils.writeValueAsString(context); + } +}; +invocation.addContext("X-B3-traceId", "value1"); +//if request has no traceId, use invocation's traceId +restInvocation.setContext(); +Assert.assertThat(invocation.getContext().size(), Matchers.is(1)); +Assert.assertThat(invocation.getContext(), Matchers.hasEntry("X-B3-traceId", "value1")); + +context.put("X-B3-traceId", "value2"); +new Expectations() { + { +requestEx.getHeader(Const.CSE_CONTEXT); +result = JsonUtils.writeValueAsString(context); + } +}; +//if request has traceId, use request's traceId +restInvocation.setContext(); +Assert.assertThat(invocation.getContext().size(), Matchers.is(1)); +Assert.assertThat(invocation.getContext(), Matchers.hasEntry("X-B3-traceId", "value2")); + } + @Test public void getContext() { invocation.addContext("key", "test"); diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/context/InvocationContext.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/context/InvocationContext.java index 2edeca77e..0807beb1c 100644 --- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/context/InvocationContext.java +++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/context/InvocationContext.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.Response.StatusType; @@ -68,6 +69,24 @@ public void addContext(Map otherContext) { context.putAll(otherContext); } + public void mergeContext(InvocationContext otherContext) { +mergeContext(otherContext.getContext()); + } + + public void mergeContext(Map otherContext) { +if (otherContext == null) { + return; +} +if (otherContext.size() > context.size()) { + for (Entry entry : context.entrySet()) { +otherContext.putIfAbsent(entry.getKey(), entry.getValue()); + } + this.context = otherContext; + return; +} +context.putAll(otherContext); + } + public Map getLocalContext() { return localContext; } diff --git a/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/context/TestInvocationContext.java b/swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/context/TestInvocationContext.java new file mode 100644 index
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16709566#comment-16709566 ] ASF GitHub Bot commented on SCB-1065: - weichao666 commented on a change in pull request #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022#discussion_r238920499 ## File path: swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/context/InvocationContext.java ## @@ -68,6 +68,22 @@ public void addContext(Map otherContext) { context.putAll(otherContext); } + public void mergeContext(InvocationContext otherContext) { +mergeContext(otherContext.getContext()); + } + + public void mergeContext(Map otherContext) { +if (otherContext == null) { + return; +} +if (otherContext.size() > context.size()) { + otherContext.putAll(context); Review comment: done, use otherContext.putIfAbsent, when otherContext's key is already exists, use otherContext's value, when otherContext does not contain key, use context's value This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16709565#comment-16709565 ] ASF GitHub Bot commented on SCB-1065: - weichao666 commented on a change in pull request #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022#discussion_r238919805 ## File path: common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java ## @@ -103,7 +103,7 @@ protected void setContext() throws Exception { @SuppressWarnings("unchecked") Map cseContext = JsonUtils.readValue(strCseContext.getBytes(StandardCharsets.UTF_8), Map.class); -invocation.setContext(cseContext); +invocation.addContext(cseContext); Review comment: done This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16709524#comment-16709524 ] ASF GitHub Bot commented on SCB-1065: - jeho0815 commented on a change in pull request #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022#discussion_r238906399 ## File path: swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/context/InvocationContext.java ## @@ -68,6 +68,22 @@ public void addContext(Map otherContext) { context.putAll(otherContext); } + public void mergeContext(InvocationContext otherContext) { +mergeContext(otherContext.getContext()); + } + + public void mergeContext(Map otherContext) { +if (otherContext == null) { + return; +} +if (otherContext.size() > context.size()) { + otherContext.putAll(context); Review comment: > 1.loop context and otherContext.putIfAbsent > 2.still did not process highway transport? new traceid created in invocation.onStart, then merge context. if only merge absent keys, the traceid is the new one. can we put the merge context before invocation.onStart? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16708663#comment-16708663 ] ASF GitHub Bot commented on SCB-1065: - wujimin commented on a change in pull request #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022#discussion_r238653191 ## File path: swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/context/InvocationContext.java ## @@ -68,6 +68,22 @@ public void addContext(Map otherContext) { context.putAll(otherContext); } + public void mergeContext(InvocationContext otherContext) { +mergeContext(otherContext.getContext()); + } + + public void mergeContext(Map otherContext) { +if (otherContext == null) { + return; +} +if (otherContext.size() > context.size()) { + otherContext.putAll(context); Review comment: 1.loop context and otherContext.putIfAbsent 2.still did not process highway transport? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16708399#comment-16708399 ] ASF GitHub Bot commented on SCB-1065: - wujimin commented on a change in pull request #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022#discussion_r238569551 ## File path: common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java ## @@ -103,7 +103,7 @@ protected void setContext() throws Exception { @SuppressWarnings("unchecked") Map cseContext = JsonUtils.readValue(strCseContext.getBytes(StandardCharsets.UTF_8), Map.class); -invocation.setContext(cseContext); +invocation.addContext(cseContext); Review comment: highway have the same problem we can add a new method in invocation: mergeContext 1.if new context have more items, then addAll to new context, and replace old context 2.if new context have less items, then allAll to old context directly. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (SCB-1065) when request not contain traceId,should use provider's invocation's traceId
[ https://issues.apache.org/jira/browse/SCB-1065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16708386#comment-16708386 ] ASF GitHub Bot commented on SCB-1065: - weichao666 opened a new pull request #1022: [SCB-1065] when request not contain traceId,should use provider's invocation's traceId URL: https://github.com/apache/servicecomb-java-chassis/pull/1022 Follow this checklist to help us incorporate your contribution quickly and easily: - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes. - [ ] Each commit in the pull request should have a meaningful subject line and body. - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue. - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [ ] Run `mvn clean install` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). --- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > when request not contain traceId,should use provider's invocation's traceId > --- > > Key: SCB-1065 > URL: https://issues.apache.org/jira/browse/SCB-1065 > Project: Apache ServiceComb > Issue Type: Bug > Components: Java-Chassis >Reporter: WeiChao >Assignee: WeiChao >Priority: Major > Fix For: java-chassis-1.2.0 > > > when request not contain traceId,should use provider's invocation's traceId -- This message was sent by Atlassian JIRA (v7.6.3#76005)