Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W3C Integration #782

Merged
merged 20 commits into from
Dec 13, 2018
Merged

W3C Integration #782

merged 20 commits into from
Dec 13, 2018

Conversation

dhaval24
Copy link
Contributor

@dhaval24 dhaval24 commented Dec 7, 2018

Fix #716

This PR is super set of all previous PRs which completes the integration of W3C for both incoming and outbound calls.

Non Goals of this PR: Backward Compatibility with AI proprietary correlation protocol.

Related #776 #775

Enable W3C:

Incoming Side -

J2EE Apps add the following to the <TelemetryModules> tag inside ApplicationInsights.xml

<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModul>
   <Param name = "  W3CEnabled" value ="true"/>
</Add>

Springboot apps add the following property:
azure.application-insights.web.w3c=true

Outgoing Side -

Add the following to AI-Agent.xml

<Instrumentation>
        <BuiltIn enabled="true">
            <HTTP enabled="true" W3C="true"/>
        </BuiltIn>
    </Instrumentation>

Remember : you need both inbound and outbound settings to be the same for correlation to work properly.

@dhaval24
Copy link
Contributor Author

dhaval24 commented Dec 7, 2018

Results of W3C Test harness on sample service

image

Copy link
Member

@lmolkova lmolkova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to report id and parent id in the |traceid.spanid. format. otherwise, there will be no correlation with .NET and python and go

@dhaval24
Copy link
Contributor Author

dhaval24 commented Dec 8, 2018

Test harness results

image

@reyang test_tracestate_member_count_limit fails because you are using 32 as an argument in LinkedHashMap. That is not something that limits the size of the map. But instead it is the initial size of hashmap.

https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html#LinkedHashMap-int-

@dhaval24
Copy link
Contributor Author

dhaval24 commented Dec 8, 2018

@lmolkova could you please approve the changes. I believe I addressed all your concerns.

@@ -286,6 +286,10 @@ public void testCrossComponentCorrelationHeadersAreCapturedWhenW3CTurnedOn() {

}

private String formatedID(String id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need

@@ -248,4 +248,9 @@ public static String getRequestSourceValue(String appId) {

return String.format("cid-v1:%s", appId);
}

private String formatedID(String id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need

@dhaval24
Copy link
Contributor Author

@lmolkova I refactored resolveCorrelation() method to be more readable and debugable. The test harness results still hold. Though, I am trying to test E2E with a .NET app and I am finding hard time to enable W3C even after following all the docs. https://docs.microsoft.com/en-us/azure/application-insights/application-insights-correlation?toc=/azure/azure-monitor/toc.json

*
* @author Dhaval Doshi
*/
public class TraceContextCorrelation {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, why it is in web packge? it's needed for outgoing requests as well that have nothing to do with web.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, Java SDK has tried to blur the distinction within core and web sdk and make the life simpler for users. If you look at ApplicationInsights-SpringBoot-Starter, it usually pulls down both core and web jars, and then smartly detect if the app is MVC type than only enable web modules. But classes are generally available on classpath. So this is okay I think. Also correlation has a primary relationship with requests in general and how they propogate in distributed systems.

However, I think Tracecontext classes can be well placed in core and implementation in web. However, I am aware that this classes will eventually go out of sdk and be replaced with a library so I won't worry about this atm.

@dhaval24
Copy link
Contributor Author

image

@lmolkova @littleaj with above all possible issues are fixed. I can see correlation working completely with W3C. Can you both sign off so I can merge this PR today?

@dhaval24
Copy link
Contributor Author

@dhaval24 dhaval24 merged commit b04fd64 into W3CImplementation Dec 13, 2018
dhaval24 added a commit that referenced this pull request Dec 15, 2018
* W3C : Tracecontext classes  (#775)

* W3C Tracecontext

* adding comments

* addressing PR comments

* Implement W3C tracestate

* address review feedbacks

* address review comments

* W3C Integration (#782)

* Initial integration of W3C protocol for incoming request

* refactoring header name

* updating the verbosity level when correlation fails

* Fix bugs in correlation found via tests, implement more unit tests and address partial PR comments

* improve createOutboundTracestate()

* create tracestate when header not available

* fix test

* enable outbout w3c

* Refactering code to use Helper methods with TraceContext classes

*  fix tracestate integration, fix outbound tracestate injection, fix tests, propogate traceflags

* add property to turn on W3C in springboot starter, remove debug logs

* adopt internal storage of id's to legacy AI format for backport, update tests

* address PR comments

* Fix an incorrect assert

* refactor resolveCorrelation() method to be more readable and debuggable

* rename method names, create outbound traceparent for http if there is no incoming request too

* fixing a bug in w3c config for agent

* fix the dependency type name, fix target to be host+port | target

* update changelog and readme

* Minor changes, add log trace to check W3C enabled on agent

* adding support for backport with AI-Legacy-Correlation-Headers

* adding tests for backward compatibility

* address PR comments

* add few tests, comments

* add backport switch turn off test

* reset after tests, to fix the build

* adding tracing to understand when W3C is turned on for debugging

* fix format string

* fix a bug in creating correct target for dependencies
@trask trask deleted the W3CIntegration/OutboundRequest branch September 21, 2020 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants