cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

x-dynatrace header tagging

rick_boyd
Mentor

Hi! Due to an unsupported client (Java + OKHTTP) we have broken purepaths from service a to service b. service b is just a typical Jax-RS application, so I'm looking for information on how to custom construct an x-dynatrace header which i can define in the request from the client side. I have no control of the code in service b.


I see documentation about the tagging ADK but can't find information around just adding the tag in Java such that servlets on the other end picks it up natively. Any link/tips would be super helpful

Thanks,

Rick B

6 REPLIES 6

olivier_weinst2
Newcomer

Hi Rick, we are facing the same problem . did you find a solution?

According to our devs I have to write this myself, haha, so I don't think it's going to be done for another month or two, but I think shortly after I wrote this I found something that essentially said if you use the Tagging ADK and just set the tag value as the value of the "x-dynatrace" header that it should work

eduard_van_der1
Dynatrace Participant
Dynatrace Participant

Hi Rick,

I ran into the same issue (also with OKHTTP).

You can use the ADK to create the x-dynatrace header: https://community.dynatrace.com/community/display/...

Then create an "x-dynatrace" header in the request with the created tag as string value. No changes necessary on service b.

Thanks Eduard! awesome to hear. Is the only way, to your knowledge, to parse/set this in the OKHttp attributes on the method? do you have code examples?

Code example below:

private static void sendTaggedRequest() throws IOException {
DynaTraceADKFactory.initialize();
Tagging x = DynaTraceADKFactory.createTagging();
String tag = x.getTagAsString();
x.linkClientPurePath(false,tag);

Request request = new Request.Builder()
.url("http://localhost:7999")
.header("X-dynatrace", tag)
.build();

Response response = client.newCall(request).execute();
System.out.println(response.body().string());
DynaTraceADKFactory.uninitialize();
}

thanks! I think our implementation is slightly different but i will float this by some smart people here to see what we can do. In any case it's a super straightforward example of getting it into the http header just generically