I am using spring-cloud-starter-sleuth:1.3.2.RELEASE. For each request to the rest endpoint entires with two different traceId s are generated. Below is a sample log output for one complete request.
two traceIds: ce67bb66181b4368 & b228413a4cdd6eb8
{"timestamp":"2018-02-14T14:18:19.052+00:00","trace":"ce67bb66181b4368","span":"ce67bb66181b4368","parent":"","exportable":"false","pid":"12856"}
{"timestamp":"2018-02-14T14:18:19.055+00:00","trace":"ce67bb66181b4368","span":"ce67bb66181b4368","parent":"","exportable":"false","pid":"12856"}
{"timestamp":"2018-02-14T14:18:19.055+00:00","trace":"ce67bb66181b4368","span":"ce67bb66181b4368","parent":"","exportable":"false","pid":"12856"}
{"timestamp":"2018-02-14T14:18:19.131+00:00","trace":"ce67bb66181b4368","span":"ce67bb66181b4368","parent":"ce67bb66181b4368","exportable":"false","pid":"12856","stack_trace":"o.s.w.c.HttpClientErrorException: 403 ..."}
{"timestamp":"2018-02-14T14:18:19.147+00:00","trace":"ce67bb66181b4368","span":"ce67bb66181b4368","parent":"ce67bb66181b4368","exportable":"false","pid":"12856","stack_trace":"o.s.w.c.HttpClientErrorException: 403 ..."}
{"timestamp":"2018-02-14T14:18:19.163+00:00","trace":"ce67bb66181b4368","span":"ce67bb66181b4368","parent":"ce67bb66181b4368","exportable":"false","pid":"12856","stack_trace":"o.s.w.c.HttpClientErrorException: 403 ..."}
{"timestamp":"2018-02-14T14:18:19.178+00:00","trace":"","span":"","parent":"","exportable":"","pid":"12856","stack_trace":"o.s.w.c.HttpClientErrorException: 403 \r\n\tat o.s.w.c.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:85)\r\n\tat o.s.w.c.RestTemplate.handleResponse(RestTemplate.java:707)\r\n\t... 75 frames truncated\r\n"}
{"timestamp":"2018-02-14T14:18:19.194+00:00","trace":"b228413a4cdd6eb8","span":"b228413a4cdd6eb8","parent":"","exportable":"false","pid":"12856"}
{"timestamp":"2018-02-14T14:18:19.194+00:00","trace":"b228413a4cdd6eb8","span":"b228413a4cdd6eb8","parent":"","exportable":"false","pid":"12856"}
{"timestamp":"2018-02-14T14:18:19.194+00:00","trace":"b228413a4cdd6eb8","span":"b228413a4cdd6eb8","parent":"","exportable":"false","pid":"12856"}
{"timestamp":"2018-02-14T14:18:19.194+00:00","trace":"b228413a4cdd6eb8","span":"b228413a4cdd6eb8","parent":"","exportable":"false","pid":"12856"}
Flow:
Rest client(postman) (calls)-> serviceA (calls)-> serviceB. ServiceB rejects the call with 403 and the same is propagated to the rest client - flow working as expected
Issue is ServiceA is logging entries which have two different trace ids.
both serviceA and serviceB are spring boot apps.
Do not have any sample app. these are services I am working on. Doing nothing unusaual.
Added the dependency "spring-cloud-starter-sleuth:1.3.2.RELEASE" in the pom and updated logback-spring.xml config with encoder LoggingEventCompositeJsonEncoder.
Please advise. Thanks,
Thanks in Advance!
Related
My ASP.NET application has the healthcheck service enabled with the default options, so a request to /hc returns "healthy" and that's all. The application itself requires an authenticated user.
services.AddHealthChecks();
app.UseHealthChecks("/hc");
In Azure, the webapp's health check is configured to /hc. This works fine for other webapps but on this particular one, I get a weird behavior as shown in these logs:
2022-12-08T15:38:32.753925985Z: [INFO] my-app : [ff3978bc-25c6-45f3-8d5e-134d7501ae3f] Incoming request on /hc
2022-12-08T15:38:32.753952886Z: [INFO] my-app : [ff3978bc-25c6-45f3-8d5e-134d7501ae3f] Request to TokenService: Endpoint my-app.azurewebsites.net, Port (null), Path /hc, Query , Method GET, UserAgent HealthCheck/1.0
2022-12-08T15:38:32.754763126Z: [INFO] my-app : [ff3978bc-25c6-45f3-8d5e-134d7501ae3f] Returning response for Site , Endpoint my-app.azurewebsites.net, Port (null), Path /hc, Method GET, Result = 404
2022-12-08T15:38:45.032379314Z: [INFO] info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
2022-12-08T15:38:45.033372564Z: [INFO] Request starting HTTP/1.1 GET http://my-app.mycompany.net/hc?manualtest - -
2022-12-08T15:38:45.033419666Z: [INFO] info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
2022-12-08T15:38:45.033428067Z: [INFO] Request finished HTTP/1.1 GET http://my-app.mycompany.net/hc?manualtest - - - 200 - text/plain 0.3773ms
Why does the request from UserAgent HealthCheck/1.0 involves the TokenService and then fails with a 404 status? If I manually call the /hc endpoint with a browser (for example the request with ?manualtest), curl or another application, it answers properly with a 200 status and "Healthy" body.
It's not a big deal but it's annoying because Azure thinks my webapp is unhealthy.
Just to highlight on what App Service does with Health checks
Further App Service Always ON also generate periodic (every 5min) probes to app instances and causing failed requests with error 404, and this can be found in Application Insights.
You may try rewriting the Always on path by referring this blog:
404 response code caused by App Services– AlwaysOn feature might be helpful
Also check this official document on Health checks in ASP.NET Core for relevant coding
You might refer to Azure App Service Health check details
This question is on Mule CXF error handling. I have a soap based web service basically this is a validation service that validates an incoming file and reports on any errors in the file. Once validation is unsuccessful i have a catch-exception-strategy which logs the error and sends a email to Prod support team. After validation is unsuccessful i need not call the subsequent steps in the flow. And only the logging and sending an email alert should happen. Shouldn't using a catch-exception-strategy solve the problem ( similar to a try/catch block in Java). But what i notice is the caller is sent a response back and subsequent flow steps are executed
In your catch exception strategy put an asynchronous flow and in that put your logger and smtp to send the mail ... I guess it will solve your problem ...
Since you will be using asynchronous flow response shouldn't be there ... Pls let me know if it solve your issue
Is there any way to get detail exception & Stack trace from deployed Web Api?
Even if I deployed in Debug mode, do I get detail error traces?
I got bellow message from server API
"message": "Processing of the HTTP request resulted in an exception.
Please see the HTTP response returned by the 'Response' property of
this exception for details."
This happened only in server, same code running perfectly in local machine.
Did you check the content-type for the request that you are performing?
Sometimes this error comes because you don't specify this value, e.g. "application/json" in the headers of the request.
If your scenario is to have a central place to log any exceptions that happen when requests are being processed, then I would suggest to take a look at 5.1 version of Web API (released couple of days back), specifically the Global Error Handling feature.
http://www.asp.net/web-api/overview/releases/whats-new-in-aspnet-web-api-21#global-error
If you go to the above page,you should notice ExceptionLoggerContext which gives you details of the exception.
About Web API versions 5.0 and before:
In these versions there was no really a central place for catching exceptions. ExceptionFilterAttributes caught exceptions for only certain areas of Web API.
I am using Spring Integration in my project.
Endpoints used in application are in-bound gateway, header based router, transformer, spliter, service activator.
In case of success flow(not any exception), in-bound gateway reply-channel getting desired response and client gets that response which is fine but in case of any exception, I want to send customized error response which is not working as per my requirement.
I am using error-channel to accomplish above requirement but not succeeding in that.
Please find my configuration of in-bound gateway, error channel etc.
I have not use any chain in configuration.
<int-http:inbound-gateway id="inboundGateway"
supported-methods="GET, POST" request-channel="requestChannel"
path="/services/tylv/{requestParam}" reply-channel="responseChannel"
error-channel="errorChannel">
</int-http:inbound-gateway>
<int:transformer ref="errorHandler"
input-channel="errorChannel" method="generateErrorResponse"
output-channel="responseChannel" />
<bean id="errorHandler"
class="com.csam.wsc.enabling.integration.transformer.ErrorHandler" />
In case of exception , com.csam.wsc.enabling.integration.transformer.ErrorHandler.generateErrorResponse(ErrorMessage) successfully called.This API handle exceptions, generate Error Response Packet but it is not being sent to client, just only HTTP Status Code 200 sent.
Ideally it should be sent because transformer's output-channel is reply-channel of inbound-gateway which is already sending response packet along with status code 200 in case of success (no any exception).
I think in case of error-channel , in-bound gateway reply-channel is not working, but I am not sure.
Please help me in configuring error-channel.
You should store the message's headers before the error reaches the error channel and then you should create a new message with the stored headers and route that new message to response channel.
MessageBuilder.fromMessage(errorResponseMessage).copyHeadersIfAbsent(storedHeaders).build();
I need to use the same SOAP request to be able to call the same implementation of a method but which is exposed by 2 different service endpoints:
Endpoint A - would be for synchronous access via SOAP
Endpoint B - would be for asynchronous access via JMS
Now what am seeing is that the SOAP request Message which works on the JMS and the SOAP webservice endpoint are structurally different.
I wanted to know whether with ApacheCXF it is possible to call the SOAP or JMS endpoints using the same SOAP request ?
In my case I was able to call both endpoints but the requests used is not the same for each
Below is an example of the SOAP message which works on Asynch Endpoint B but which does not work on Synch Endpoint A .. note that I've obtained the Asynch message by executing a Junit test and intercepted the generate message on ActiveMQ queue:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:create xmlns:ns1="http://service.ws.example/">
<CustomPartyModel>
<ns2:customerModel
xmlns:ns2="http://party.beans.commons.example">
<ns2:person>
<ns2:budgetPlanNumber>131484</ns2:budgetPlanNumber>
<ns2:clientSituationCode
xmlns:ns3="http://www.w3.org/2001/XMLSchema-instance" ns3:nil="true" />
<ns2:employeeReduction>J</ns2:employeeReduction>
<ns2:employeeNumber></ns2:employeeNumber>
<ns2:packageNumber>5</ns2:packageNumber>
<ns2:planIndicator xmlns:ns3="http://www.w3.org/2001/XMLSchema-instance"
ns3:nil="true" />
<ns2:privateRelationNumber
xmlns:ns3="http://www.w3.org/2001/XMLSchema-instance" ns3:nil="true" />
</ns2:person>
</ns2:customerModel>
</CustomPartyModel>
</ns1:create>
</soap:Body>
Here is the SOAP Request which works on Synchronous endpoint but not on the Asynch one .. this request was obtained from creating a request from the WSDL :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://service.ws.example/" xmlns:par="http://party.beans.commons.example">
<soapenv:Body>
<ser:CustomPartyModel>
<par:customerModel>
<par:person>
<par:budgetPlanNumber>131484</par:budgetPlanNumber>
<par:employeeReduction>J</par:employeeReduction>
<par:employeeNumber></par:employeeNumber>
<par:packageNumber>5</par:packageNumber>
<par:professionCodePartner></par:professionCodePartner>
<par:professionDescriptionPartner></par:professionDescriptionPartner>
</par:person>
</par:customerModel>
</ser:CustomPartyModel>
In both cases am using Aegis for data binding , I did try JAXB as well but with no futher success.
Given that its the same method with same method signature you would expect that the same request could be used in both asynch and synch but this does not seem to be the case .
Anybody has had similar issues or could possibly shed some light in regards to this ?
Note that am using the following dependencies:
cxf-api-2.2.2.jar ,
cxf-common-utilities-2.2.2.jar,
cxf-rt-databinding-aegis-2.2.2.jar,
XmlSchema-1.4.5.jar,
cxf-rt-transports-jms-2.2.2.jar,
spring-jms-2.5.5.jar,
acegi-security-1.0.7.jar
Ok I found the solution basically to be able to send Request through JMS and Synchronous SOAP as Document Literal the following is required to be defined on the interface
#WebService
#SOAPBinding(style=Style.DOCUMENT, use=Use.LITERAL,parameterStyle=ParameterStyle.BARE)
public interface ExampleAsyncService {
Without the Document / Literal / Bare configuration JMS will have a tendancy of sending RPC wrapped style request .