Skip to content

Conversation

@vasantteja
Copy link
Contributor

This Change

I promoted both the interface and implementation to data package adhering to the package structure inside the internal implementation. Let me know your thoughts. Sorry for opening another pr when we have another pr. This resolves 6630

@vasantteja vasantteja requested a review from a team as a code owner October 16, 2024 01:38

/**
* Returns a new immutable {@link ExceptionEventData}.
* Returns a new immutable {@link io.opentelemetry.sdk.trace.data.ExceptionEventData}.
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't require being fully qualified, I don't think. I'd revert the fully-qualified classname changes here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dang it, sorry I will just use the class name and remove the fully-qualified classname.

@Immutable
abstract class ImmutableExceptionEventData implements ExceptionEventData {
abstract class ImmutableExceptionEventData
implements io.opentelemetry.sdk.trace.data.ExceptionEventData {
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be importable, and not need to be fully-qualified

@codecov
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 90.49%. Comparing base (b1cd30e) to head (18c2578).
Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
.../main/java/io/opentelemetry/sdk/trace/SdkSpan.java 92.30% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@ Coverage Diff @@ ## main #6795 +/- ## ============================================ + Coverage 90.12% 90.49% +0.37%  - Complexity 6546 6598 +52  ============================================ Files 728 731 +3 Lines 19702 19735 +33 Branches 1935 1938 +3 ============================================ + Hits 17756 17859 +103  + Misses 1347 1283 -64  + Partials 599 593 -6 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jkwatson
jkwatson previously approved these changes Oct 16, 2024
Copy link
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Few discussion points

+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW INTERFACE: io.opentelemetry.sdk.trace.data.EventData
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.data.ExceptionEventData create(io.opentelemetry.sdk.trace.SpanLimits, long, java.lang.Throwable, io.opentelemetry.api.common.Attributes)
Copy link
Member

Choose a reason for hiding this comment

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

@jkwatson its odd for the create method to accept SpanLimits as an argument. Normally the application of limits is handled in SDK internals. We can see this pattern play out in the EventData.create contract:

static EventData create( long epochNanos, String name, Attributes attributes, int totalAttributeCount) 

The attributes are provided with an additional totalAttributeCount indicating how many attributes were originally present.

The reason we do it differently for ExceptionEventData appears to be because ImmutableExceptionEvent#getAttributes() doesn't compute the attributes until it is called (and then it memoizes them), preventing additional allocations on the hot path.

Not sure there's a way to avoid SpanLimits being passed as an argument if we stick with that argument.

+++ NEW INTERFACE: io.opentelemetry.sdk.trace.data.EventData
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.data.ExceptionEventData create(io.opentelemetry.sdk.trace.SpanLimits, long, java.lang.Throwable, io.opentelemetry.api.common.Attributes)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.api.common.Attributes getAdditionalAttributes()
Copy link
Member

Choose a reason for hiding this comment

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

Upon closer inspection, I find this method strange. The resulting ExceptionEventData interface has the following methods:

  • getAttributes(): default implementation returns getAdditionalAttributes() provided by user + exception.* attributes following semconv.
  • getAdditionalAttributes(): default implementation returns only additional attributes provided by the user.

Seems odd to have a special accessor for getAdditionalAttributes(). I assume that consumers of this want to do something like: if(event instanceOf ExceptionEventData) serialize(((ExceptionEventData) event).getException())

If they want o split out the exception attributes from additional attributes, can do so with getAttributes().toBuilder().removeIf(attributeKey -> attributeKey.getKey().startsWith("exception")).build().

Do we really need the special getAdditionalAttributes() accessor?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm. good eye on double checking the original API for this. Maybe we're not quite ready to stabilize, if we're unsure of the final API? I agree the creational patterns for this are currently strange and not user-friendly. 🤔

Copy link
Member

Choose a reason for hiding this comment

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

I think we can still stabilize, but cut out the getAdditionalAttributes() method. The point I make here about SpanLimits as a constructor argument is an implementation detail. We can remove it as a parameter with the only difference being that we compute the exception.* attributes on the calling thread instead of on a background thread, which seems pretty reasonable / expected.

Copy link
Member

Choose a reason for hiding this comment

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

If you agree, I can either push some commits to this PR, or provide some more complete guidance to @vasantteja on how to proceed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm totally ok with your suggestion

Copy link
Member

Choose a reason for hiding this comment

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

You've got it.

The exception.* attributes will need to be computed in SdkSpan, rather than in ImmutableExceptionEventData.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jack-berg I finally wrapped my head around this and have an implementation. I cut out the attribute computation in the ImmutableExceptionEventData and I moved them to SdkSpan. I added a little bit of logic to shrink the exception messages if maxLength attribute is turned on in SpanLimits. Let me know if this aligns with your thinking.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wish I had noticed this PR earlier. Unfortunately moving the rendering of the exception back into SdkSpan makes it unavoidable and doing so is incredibly expensive. In our Spring WebFlux services not only are the stack traces absolutely massive, but the rendering of the traceback creates resource contention due to synchronization. It causes a noticeable impact on the performance of our services. I would like to revisit this decision and at least provide a means to make it optional.

Copy link
Member

Choose a reason for hiding this comment

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

@HaloFour I'd suggest opening a new issue where this can be discussed, thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Opened this issue: #7129

vasantteja and others added 2 commits October 21, 2024 21:33
Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
@jkwatson jkwatson self-requested a review October 22, 2024 20:10
@jkwatson jkwatson dismissed their stale review October 24, 2024 23:53

things change

vasantteja and others added 5 commits October 28, 2024 18:58
…bleExceptionEventData.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
…bleExceptionEventData.java Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
Co-authored-by: jack-berg <34418638+jack-berg@users.noreply.github.com>
@jack-berg
Copy link
Member

I pushed a small commit to capture the total number of attributes added (in case any were filtered to conform to SpanLimits), and to remove unused methods. Looks good to merge to me!

@jack-berg jack-berg merged commit fcae15e into open-telemetry:main Oct 29, 2024
20 checks passed
Comment on lines +2 to +7
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.sdk.trace.data.ExceptionEventData (not serializable)
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
+++ NEW INTERFACE: io.opentelemetry.sdk.trace.data.EventData
+++ NEW SUPERCLASS: java.lang.Object
+++ NEW METHOD: PUBLIC(+) STATIC(+) io.opentelemetry.sdk.trace.data.ExceptionEventData create(long, java.lang.Throwable, io.opentelemetry.api.common.Attributes, int)
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Throwable getException()
Copy link
Member

Choose a reason for hiding this comment

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

👍

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

Labels

None yet

5 participants