Setting a traceId with an existing value in Spring Sleuth - spring-cloud

We have an application and where we are tracing the whole logs using a custom correlation header i.e. X-CID with a value as for example, 615b7eea-6d4c-4efb-9431-fcbba084ea3f. Recently we have integrated the Spring Sleuth with the train version as Greenwich.BUILD-SNAPSHOT in our application and using brave's Span and tracer to create trace and span ad sending it to Zipkin.
What we are looking for a mechanism where we can use or set the CID value as a traceId rather than using the auto generated one from Sleuth.
The rational behind is, we would like to make it uniform CID value to use or search in Zipkin UI rather than two different values i.e. CID value and Spring Sleuth traceId to trace the complete API calls.
Please note that, we would like to reuse the X-CID from request which is already supplied in the request header.
Are there any APIs to override this behavior or any alternate way to achieve this ?

Related

How do I add at runtime an https header to a Power App custom connector

In PowerApps, custom connector, I need to define the entire structure of the call when I create the custom connector. I know I can mark certain fields (query params) as parameters that can be filled during run time.
What I try to do is to set the value of one of my security http headers at run time.
My connector, with an API key, makes a call to the /extra/auth end point
/extra/auth returns another key value.
I need to use this new key value in any consecutive calls to my APIs in the HEADER of the request.
I can use two separate connectors for the auth and for the application logic (which seems logic to me).
How would you go to set an http header value at run time for a custom connector - REST api?

"winning-configuration-property" algorithm : spring configuration properties run time determination based on application specific qualifiers

I need to implement a "winning-configuration-property" algorithm in my application.
For example:
for property: dashboard_material
i would create a file (I am planning to represent each property as a file. This is slightly negotiable)dashboard_material.yml , with the following value
(which format i believe presents a consolidated view of the variants of the property and is more suitable for impact analysis when someone changes values in a particular scenario) :
car_type=luxury&car_subtype=luxury_sedan&special_features=none : leather
car_type=luxury&car_subtype=luxury_sedan&special_features=limited_edition : premium_leather
car_type=economy : pseudo_leather
default : pseudo_leather
I need the closest match. A luxury car can be a sedan or a compact.
I am assuming these are "decorators" of a car in object oriented terms, but not finding any useful implementation for the above problem from sample decorator patterns.
For example an API:
GET /configurations/dashboard_material should return the following values based on input parameters:
car_type=economy : pseudo_leather
car_type=luxury & car_subtype=luxury_sedan : leather
car_type=luxury : pseudo_leather (from default. Error or null if value does not exist)
This looks very similiar to the "specifications" or "queryDSL" problem with GetAPIs - in terms of slicing and dicing based on criteria.
but basically i am looking for a run-time determination of a config value from a single microservice
(which is a spring config client. I use git2consul to push values from git into consul KV. The spring config client is tied into the consul KV. I am open to any equivalent or better alternatives).
I would ideally like to do all the processing as a post-processing after the configuration is read (from either a spring config server or consul KV),
so that no real processing happens after the query is recieved. The same post processing will also have to happen after every spring config client "refresh" interval based
on configuration property updates.
I have previously seen such an implementation (as an ops engineer) with netflix archaius implementation, but not again finding any suitable text on the archaius pages.
My trivial/naive solution would be to create multiple maps/trees to store the data and then consolidate them into a single map based on the API request effectively overriding some of the values from the lower priority maps.
I am looking for any open-source implementations or references and avoid having to create new code.

Jmeter recorded script is not added data on frontend side

I recorded my jmeter script on server x and make it dynamic after that run that same script on server y - it fetch all data by post processor and did not give any error but data is not added on fronted . how can I solve it any reason behind it? (website is same just change the server for testing)
expected-Data should add on fronted like create lead on server y (successfully create on server x)
actual -data not added on server y
Most probably you need to correlate your script as it is not doing what it is supposed to be doing.
You can run your test with 1 virtual user and 1 iteration configured in the Thread Group and inspect request and response details using View Results Tree listener
My expectation is that you either not getting logged in (you have added HTTP Cookie Manager to your Test Plan, haven't you?) or fail to provide valid dynamic parameters. Modern web applications widely use dynamic parameters for example for client side state tracking or for CSRF protection
You can easily detect dynamic parameters by recording the same scenario one more time and compare the generated scripts. All the values which differ need to be correlated, to wit extracted from the previous response using a suitable Post-Processor and stored into a JMeter Variable. Once done you will need to replace recorded hard-coded value with the aforementioned JMeter Variable.
Check out How to Handle Correlation in JMeter article for comprehensive information with examples.

Is there a way to prevent Spring Cloud Gateway from reordering query parameters?

Spring Cloud Gateway appears to be reordering my query parameters to put duplicate parameters together.
I'm trying to route some requests to one of our end points to a third party system. These requests include some query parameters that need to be in a specific order (including some duplicate parameters), or the third party system returns a 500 error, but upon receiving the initial request with the parameters in the proper order, the Spring Cloud Gateway reorders these parameters to put the duplicates together by the first instance of the parameter.
Example:
http://some-url.com/a/path/here?foo=bar&anotherParam=paramValue2&aThirdParam=paramValue3&foo=bar
Becomes:
http://some-url.com/a/path/here?foo=bar&foo=bar&anotherParam=paramValue2&aThirdParam=paramValue3
Where the last parameter was moved to be by the first parameter because they had the same name.
The actual request output I need is for the query parameters to be passed through without change.
The issue lays in the UriComponentsBuilder which is used in RouteToRequestFilter.
UriComponentsBuilder.fromUri(uri) is going to build up a map of query params. Because this is a LinkedMultiValueMap you see the reordering of the used query params.
Note that RFC3986 contains the following
The query component contains non-hierarchical data that, along with data in the path component (Section 3.3), serves to identify a resource within the scope of the URI’s scheme and naming authority (if any).
Therefor I don’t think there needs to be a fix in Spring Cloud Gateway.
In order to fix this in your gateway, you'll need to add a custom filter which kicks in after the RouteToRequestFilter by setting the order to RouteToRequestUrlFilter.ROUTE_TO_URL_FILTER_ORDER + 1.
Take a look at the RouteToRequestUrlFilter how the exchange is adapted to go to the downstream URI.
Hope that helps! :)

Infinispan communication using rest when values are placed using Hotrod

scenario : in Infinispan 5.3 server , application putting value in cache using Hotrod(address1:port) , but not able to get same value using infinispan rest interface(using same address1:port and same key).
e.g. put "x"="y" in infinispan cache using hotrod . trying to fetch same cached value using address1:port/rest/cachename/x but not able to get value.
Please provide input as I am new to it, also please provide example if any.
In order to store data via one interface (e.g. HotRod) and retrieve it via a different interface (e.g. REST), you need to enable compatibility/interoperability mode.