Skip to content

Conversation

@stevejgordon
Copy link
Contributor

@stevejgordon stevejgordon commented Sep 30, 2024

This ensures that the Azure SDK instrumentation doesn't use the existing Activity span ID, which, when combined with the OTel bridge, can lead to spans being parented by themselves.

This also enhances the logic of the OTel bridge so that we skip span creation for activities coming from the Azure SDK libraries if our Azure instrumentation assemblies are loaded. This ensures we don't create essentially repeated child spans.

Fixes #2452

@stevejgordon stevejgordon force-pushed the fix-servicebus-instrumentation branch from 81c9681 to 7854d2d Compare October 1, 2024 14:12
@stevejgordon stevejgordon requested a review from Mpdreamz October 2, 2024 09:47
Mpdreamz
Mpdreamz previously approved these changes Oct 2, 2024
Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +32 to +37
// This simply ensures our transaction activity is always created.
internal static readonly ActivityListener Listener = new()
{
ShouldListenTo = s => s.Name == ElasticApmActivitySource.Name,
Sample = (ref ActivityCreationOptions<ActivityContext> _) => ActivitySamplingResult.AllData
};
Copy link
Contributor

Choose a reason for hiding this comment

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

@stevejgordon @Mpdreamz Sorry to revive this, but the Listener is never registered via ActivitySource.AddActivityListener(Listener);, so the intended behavior (per the comment) isn't actually correct.

This issue (activities not being created) is hidden when OpenTelemetryBridgeEnabled is true (the default), since ElasticActivityListener registers a listener for all ActivitySources. But if the bridge is disabled then no activity is created.

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 for highlighting this @aheubusch. Is this manifesting in an error or issue for you? I think the intent was focused on the scenario where the bridge is in use, but it's complex code and there may be knock on effects we didn't consider.

Copy link
Contributor

Choose a reason for hiding this comment

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

No error or issue in my application (bridge is enabled). One of my unit tests (bridge is disabled) started failing after an update from 1.28 to 1.34 because it assumed that StartTransaction always creates an Activity (except when ignoreActivity=true).
In general this change in behavior appears to be unintentional, so I wanted to raise it.

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.

[BUG] Azure ServiceBus traces are broken in some situations

4 participants