sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

Make Access Modifier To Public For UpdateStartDate

Open sentryadam0000345 opened this issue 1 year ago • 3 comments

Problem Statement

In some rare cases we aren't ready to use sentry yet but would like to start a trace. Updating end date is enough right now, can still construct whatever length we want though it would be nice to be able to set the start/end to the actual times something happened.

Specifically, this is in regards to overriding the duration value of an event. In particular, overriding the duration value for a custom Performance Span.

Solution Brainstorm

It seems like the change here should be fairly easy. Just change the access modifier to public from private like it is set for updateEndDate.

Here are the relevant lines in the SDK that I found that would need to be looked at/changed:

https://github.com/getsentry/sentry-java/blob/9762f09afa51944b40a9b77e116a55e54636e6c5/sentry/src/main/java/io/sentry/Span.java#L393

https://github.com/getsentry/sentry-java/blob/9762f09afa51944b40a9b77e116a55e54636e6c5/sentry/src/main/java/io/sentry/Span.java#L420

┆Issue is synchronized with this Jira Improvement by Unito

sentryadam0000345 avatar Aug 14 '24 21:08 sentryadam0000345

We'll discuss implications and update here.

adinauer avatar Aug 23 '24 07:08 adinauer

Would it also suffice, if we allow setting the start date when starting a span?

adinauer avatar Aug 23 '24 09:08 adinauer

Yes that would work too!

zsperske avatar Aug 23 '24 17:08 zsperske

In the meantime this could be solved using beforeSendTransaction.

markushi avatar Sep 04 '24 13:09 markushi

In v8 of the Java SDK SpanOptions.setStartTimestamp can be used to set the start time of a span or transaction when creating it.

adinauer avatar Sep 30 '24 07:09 adinauer