-
Notifications
You must be signed in to change notification settings - Fork 851
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
Stabilize ExceptionEventData #6795
Changes from 2 commits
219ae6f
e7c0a03
015a707
b6e5816
9700e01
661fc17
b89292a
7cc7162
e5e686c
131062a
b084f01
d2e0cea
aefe947
18c2578
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
Comparing source compatibility of opentelemetry-sdk-trace-1.44.0-SNAPSHOT.jar against opentelemetry-sdk-trace-1.43.0.jar | ||
No changes. | ||
+++ 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(io.opentelemetry.sdk.trace.SpanLimits, long, java.lang.Throwable, io.opentelemetry.api.common.Attributes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upon closer inspection, I find this method strange. The resulting
Seems odd to have a special accessor for If they want o split out the exception attributes from additional attributes, can do so with Do we really need the special There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can still stabilize, but cut out the There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm totally ok with your suggestion There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jack-berg I understand that we should remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You've got it. The There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.api.common.Attributes getAdditionalAttributes() | ||
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Throwable getException() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,10 @@ | |
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.trace.internal.data; | ||
package io.opentelemetry.sdk.trace.data; | ||
|
||
import io.opentelemetry.api.common.Attributes; | ||
import io.opentelemetry.sdk.trace.SpanLimits; | ||
import io.opentelemetry.sdk.trace.data.EventData; | ||
|
||
/** | ||
* Data representation of an event for a recorded exception. | ||
|
@@ -18,13 +17,15 @@ | |
public interface ExceptionEventData extends EventData { | ||
|
||
/** | ||
* Returns a new immutable {@link ExceptionEventData}. | ||
* Returns a new immutable {@link io.opentelemetry.sdk.trace.data.ExceptionEventData}. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
* | ||
* @param spanLimits limits applied to {@link ExceptionEventData}. | ||
* @param epochNanos epoch timestamp in nanos of the {@link ExceptionEventData}. | ||
* @param spanLimits limits applied to {@link io.opentelemetry.sdk.trace.data.ExceptionEventData}. | ||
* @param epochNanos epoch timestamp in nanos of the {@link | ||
* io.opentelemetry.sdk.trace.data.ExceptionEventData}. | ||
* @param exception the {@link Throwable exception} of the {@code Event}. | ||
* @param additionalAttributes the additional attributes of the {@link ExceptionEventData}. | ||
* @return a new immutable {@link ExceptionEventData} | ||
* @param additionalAttributes the additional attributes of the {@link | ||
* io.opentelemetry.sdk.trace.data.ExceptionEventData}. | ||
* @return a new immutable {@link io.opentelemetry.sdk.trace.data.ExceptionEventData} | ||
*/ | ||
static ExceptionEventData create( | ||
SpanLimits spanLimits, | ||
|
@@ -36,16 +37,20 @@ static ExceptionEventData create( | |
} | ||
|
||
/** | ||
* Return the {@link Throwable exception} of the {@link ExceptionEventData}. | ||
* Return the {@link Throwable exception} of the {@link | ||
* io.opentelemetry.sdk.trace.data.ExceptionEventData}. | ||
* | ||
* @return the {@link Throwable exception} of the {@link ExceptionEventData} | ||
* @return the {@link Throwable exception} of the {@link | ||
* io.opentelemetry.sdk.trace.data.ExceptionEventData} | ||
*/ | ||
Throwable getException(); | ||
|
||
/** | ||
* Return the additional {@link Attributes attributes} of the {@link ExceptionEventData}. | ||
* Return the additional {@link Attributes attributes} of the {@link | ||
* io.opentelemetry.sdk.trace.data.ExceptionEventData}. | ||
* | ||
* @return the additional {@link Attributes attributes} of the {@link ExceptionEventData} | ||
* @return the additional {@link Attributes attributes} of the {@link | ||
* io.opentelemetry.sdk.trace.data.ExceptionEventData} | ||
*/ | ||
Attributes getAdditionalAttributes(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.sdk.trace.internal.data; | ||
package io.opentelemetry.sdk.trace.data; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.auto.value.extension.memoized.Memoized; | ||
|
@@ -16,10 +16,10 @@ | |
import java.io.StringWriter; | ||
import javax.annotation.concurrent.Immutable; | ||
|
||
/** An effectively immutable implementation of {@link ExceptionEventData}. */ | ||
@AutoValue | ||
@Immutable | ||
abstract class ImmutableExceptionEventData implements ExceptionEventData { | ||
abstract class ImmutableExceptionEventData | ||
implements io.opentelemetry.sdk.trace.data.ExceptionEventData { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be importable, and not need to be fully-qualified |
||
|
||
private static final AttributeKey<String> EXCEPTION_TYPE = | ||
AttributeKey.stringKey("exception.type"); | ||
|
This file was deleted.
There was a problem hiding this comment.
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 theEventData.create
contract: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 becauseImmutableExceptionEvent#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.