Skip to content

Conversation

@pavan-traceable
Copy link
Contributor

Mark span as APIBoundary if it is entry span and service name differs from parent span service name.

Description

Added one more condition to eligible span as APIBoundary type span if it is entry span and service name differs from Parent span.

Testing

Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

Documentation

Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.

@codecov
Copy link

codecov bot commented Jul 11, 2021

Codecov Report

Merging #221 (28b5880) into main (09ac77a) will decrease coverage by 0.05%.
The diff coverage is 40.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #221      +/-   ##
============================================
- Coverage     80.75%   80.70%   -0.06%     
- Complexity     1127     1128       +1     
============================================
  Files           101      101              
  Lines          4345     4349       +4     
  Branches        398      400       +2     
============================================
+ Hits           3509     3510       +1     
- Misses          650      653       +3     
  Partials        186      186              
Flag Coverage Δ
unit 80.70% <40.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nrichedspan/constants/utils/EnrichedSpanUtils.java 54.60% <0.00%> (-1.10%) ⬇️
...nt/enrichers/ApiBoundaryTypeAttributeEnricher.java 90.41% <100.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09ac77a...28b5880. Read the comment docs.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.


Event parentEvent = graph.getParentEvent(event);
if (!EnrichedSpanUtils.isEntrySpan(parentEvent)) {
if (!EnrichedSpanUtils.isEntrySpan(parentEvent)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here's a hypothetical: in scenarios where an envoy proxy is injected, usually there will be 2 entry spans back to back and for exits, 2 exit spans back to back. What happens then when the proxy labels the service as "test-service" and the in-app agent labels it with "test-service-foo". Technically, all these spans are in one service, given that a pod is considered as the service but now there will be 2 API boundaries instead of just one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @tim-mwangi. Is it not possible to fix this ? This change mainly because of multiple gateway spans like Kong, Istio etc which we don't have any control. @davexroth what should we do ?

Copy link
Contributor

@kotharironak kotharironak Jul 12, 2021

Choose a reason for hiding this comment

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

Do we have any attributes from Kong, Istio that indicate that span is proxySpan - e.g tracer.type?

Copy link
Contributor

@kotharironak kotharironak Jul 12, 2021

Choose a reason for hiding this comment

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

As the boundary between two services (which will have different service labels respectively) are based on (entry, exit) pair, is it safe to assume that two consecutive (entry, entry) or (exit, exit) pairs showing different service labels can possible due to proxy?

If, yes, we can consider the below logic for determining entry/exit proxySpan if tracer.type attribute (or some other attribute indicating proxySpan) is not available:

isEntryProxySpan(currentSpan):
    isEntrySpan(currentSpan AND (foreach child of (currentSpan) -> isEntrySpan(child.span) && child.service() != currentSpan.service()) 

isExitProxySpan():
    isExistSpan() AND (isParentSpanExitSpan() && parent.serviceName != this.span.serviceName())

Should we decorate at proxySpan level or inner service span level for entry API boundary?

  • Currently, on exit span, we are decorating at the proxy span level. So, for entry span, we can do the same, decorating at proxy span level.

we will need merging of spans (proxy + service span) as dependent enrichers eventually if we go with the above logic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed offline. I withdraw my concerns. I'm ok with multiple API boundaries if the service name changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kotharironak Had offline discussion with Dave and Tim, they have agreed with this change.

avinashkolluru
avinashkolluru previously approved these changes Jul 15, 2021
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

&& GraphBuilderUtil.areBothSpansFromDifferentService(
child, entryBoundaryEvent.get())) {
ApiNode<Event> destinationApiNode = entryApiBoundaryEventIdToApiNode.get(child);
LOGGER.debug(
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap this within if (LOGGER.isDebugEnabled()) {

HexUtils.getHex( could be expensive and shouldn't be done if debug logs are not enabled.

// 1. get all the exit boundary events from an api node
// 2. exit boundary events are the only ones which can call a different api node
// 3. find all the children of exit boundary events, which will be entry boundary nodes of
// 2. find all the children of exit boundary events, which will be entry boundary nodes of
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: find all the children of exit boundary events is not accurate since we check the children of entry boundary events too now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other case updated later in the method, this is the first case.

return false;
}

/** Check whether these spans belongs to different services. */
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this method should be in ApiBoundaryTypeAttributeEnricher itself, this class is housing utilities related rebuilding of ApiTraceGraph and StructuredTraceGraph

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used in ApiTraceGraph as well.

Copy link
Contributor

@findingrish findingrish Jul 15, 2021

Choose a reason for hiding this comment

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

I see its used in ApiTraceGraph as well, then the right place for it is utility for span/enriched span ig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't get it, which class is ideal for this ? In GraphQLBuilder util most of the methods are related to what i have added now, although name(GraphQLBuilderUtil) is not looking right

Copy link
Contributor

@findingrish findingrish Jul 15, 2021

Choose a reason for hiding this comment

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

I didn't get it, which class is ideal for this

EnrichedSpanUtils (most of the method for checking some property on span is present here)

In GraphBuilder util most of the methods are related to what

most of the method here is to check the existing event/trace has changed or not and is meant to support Graph caching logic, whereas the newly added method seems unrelated

yeah this class needs renaming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in fact i realised while doing changes in Traceable, moved to EnrichedSpanUtils.

avinashkolluru
avinashkolluru previously approved these changes Jul 15, 2021
@github-actions

This comment has been minimized.

for (Event child : children) {
// if the child of an entry boundary event is an entry api boundary type,
// which can happen if exit span missing and both belongs to different services.
if (EnrichedSpanUtils.isEntryApiBoundary(child)
Copy link
Contributor

Choose a reason for hiding this comment

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

if the exit span is missing how will these two span have parent and child relationship?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ignore this, I was assuming that an actual span is missing here which is not the case

@github-actions

This comment has been minimized.

@pavan-traceable pavan-traceable merged commit 39c6df1 into main Jul 15, 2021
@pavan-traceable pavan-traceable deleted the api-boundary-fix branch July 15, 2021 09:17
@github-actions
Copy link

Unit Test Results

  69 files  ±0    69 suites  ±0   52s ⏱️ ±0s
359 tests +1  359 ✔️ +1  0 💤 ±0  0 ❌ ±0 

Results for commit 39c6df1. ± Comparison against base commit 09ac77a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants