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

[exporter/azuremonitorexporter] fix: correct parent for span events #30659

Conversation

alaendle
Copy link
Contributor

Description: Corrected parent for exported span events.
For details please take a look at the corresponding issue.
I think the change is pretty straight forward - one line added.
However I'm not a go-expert - so there might exist a more elegant implementation.

Link to tracking Issue: #27233

Testing: Adapted existing units test.

Documentation: n/a

(fyi @pcwiese)

@alaendle alaendle requested review from a team and djaglowski January 18, 2024 05:39
Copy link

linux-foundation-easycla bot commented Jan 18, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@@ -133,6 +133,7 @@ func spanToEnvelopes(
}

spanEventEnvelope := newEnvelope(span, toTime(spanEvent.Timestamp()).Format(time.RFC3339Nano))
spanEventEnvelope.Tags[contracts.OperationParentId] = traceutil.SpanIDToHexOrEmptyString(span.SpanID())
Copy link
Contributor

Choose a reason for hiding this comment

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

newEnvelope method has the entry for envelope.Tags[contracts.OperationParentId], that seems to be correct.
envelope.Tags[contracts.OperationParentId] = traceutil.SpanIDToHexOrEmptyString(span.ParentSpanID())

spanEventEnvelope.Tags[contracts.OperationParentId] = traceutil.SpanIDToHexOrEmptyString(span.SpanID())

Setting the current span ID as the parent does not seem correct. Did you validate with an app that issue #27233 is resolved by this update?

Providing the .NET implementation here for reference - https://github.com/Azure/azure-sdk-for-net/blob/2d1996d14d430c541c5beabad612b98a01fb4a4e/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.cs#L19

Java Implementation - https://github.com/Azure/azure-sdk-for-java/blob/9e6bab9bb50d865ed8b4e5ab3198e3fc56d9e468/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/SpanDataMapper.java#L288

Copy link
Contributor Author

@alaendle alaendle Jan 19, 2024

Choose a reason for hiding this comment

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

To be honest I haven't validated the change in conjunction with AppInsights.

But I've made up for it now and the result looks correct:

Before the change:
grafik

Now:
grafik

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is correct in the context of logs. All logs will have the parent ID labeled as 'spanid.' However, you are modifying the trace envelope, which corresponds to spans. Logs are handled differently; therefore, the change should be applied to the log exporter file. The current proposed change might break the UI in other scenarios.

Copy link
Contributor

Choose a reason for hiding this comment

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

Moving your changes to log_to_envelope.go should resolve an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rajkumar-rangaraj - first huge sorry - with the LogDataMapperI've pointed you to the wrong direction. We are still and only talking about trace data. However I've found the more correct line that underpins my change also in the azure-sdk-for-java - https://github.com/Azure/azure-sdk-for-java/blob/9e6bab9bb50d865ed8b4e5ab3198e3fc56d9e468/sdk/monitor/azure-monitor-opentelemetry-exporter/src/main/java/com/azure/monitor/opentelemetry/exporter/implementation/SpanDataMapper.java#L779
For Events the parent span is the span of the current operation. That also makes sense, because the events are just annotations of the current operation/tracing span. So maybe we should take one step back, and find out how far we already agree.

  1. There is a problem with the original implementation (azuremonitorexporter assign wrong parentId to span events #27233) - the original behaviour could and should be improved?
  2. The provided PR solves this issue - and has no unintended side effects?
  3. Is the form of the changes okay, or should the patch be rephrased?

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. It makes sense for span events.

Copy link
Contributor

github-actions bot commented Feb 5, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 5, 2024
@github-actions github-actions bot removed the Stale label Feb 7, 2024
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 21, 2024
@rajkumar-rangaraj
Copy link
Contributor

@pcwiese, Could you please review this PR.

@rajkumar-rangaraj
Copy link
Contributor

CLA Not Signed

@alaendle Could you please fix this one?

@github-actions github-actions bot removed the Stale label Feb 25, 2024
@rajkumar-rangaraj
Copy link
Contributor

@open-telemetry/collector-contrib-approvers Could you please approve the pipeline and help merge this PR. It has got an approval from the code owner.

Copy link
Member

@songy23 songy23 left a comment

Choose a reason for hiding this comment

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

Please add a changelog

@alaendle alaendle force-pushed the exporter-azuremonitorexporter/fix-parent-of-span-events branch from 62185d2 to d4db28c Compare March 2, 2024 08:06
@alaendle alaendle requested a review from songy23 March 2, 2024 08:07
Copy link
Contributor

github-actions bot commented Apr 2, 2024

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 2, 2024
@alaendle
Copy link
Contributor Author

alaendle commented Apr 2, 2024

Pinging @djaglowski - maybe you could approve/merge this PR? Or is still something missing?

@github-actions github-actions bot removed the Stale label Apr 3, 2024
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Apr 18, 2024
@alaendle
Copy link
Contributor Author

This is becoming more and more of a frustrating experience. The PR is now 3 month old and I still can't predict whether or when he will make it to the finish line.

@bryan-aguilar bryan-aguilar added ready to merge Code review completed; ready to merge by maintainers and removed Stale labels Apr 18, 2024
@bryan-aguilar
Copy link
Contributor

Apologies @alaendle. I understand how this can be frustrating. I see we have codeowner and approver review already. I went ahead and stuck the ready to merge label which should give better visibility to the maintainers. Please just keep an eye out on the CI to make sure it stays green. You shouldn't need to continually update from main unless a merge conflict pops up.

@TylerHelmuth TylerHelmuth merged commit 08f31f4 into open-telemetry:main Apr 18, 2024
164 of 165 checks passed
@github-actions github-actions bot added this to the next release milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/azuremonitor ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants