Skip to content

Conversation

@markstory
Copy link
Member

On transaction events expose both the start and end timestamps. This will allow us to correctly display the transaction span length.

I've also added the transaction sample from my now closed tracing pull request. Having a sample transaction event should be useful when we have to do more endpoint and acceptance tests around transaction events.

Refs SEN-799

@markstory markstory requested review from a team and fpacifici July 15, 2019 17:15
# timestamp floats.
if obj.get_event_type() == 'transaction':
d['startTimestamp'] = obj.data.get('start_timestamp')
d['timestamp'] = obj.data.get('timestamp')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this ends up being the same as obj.datetime and the field dateCreated that is populated at line 272. Is there a reason to add a new one ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The dateCreated field is a string and lacks the ms precision.

Copy link
Contributor

Choose a reason for hiding this comment

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

then, since this is going to be there only for transacitons, I would advise to rename the two fields in such a way that make it clear what they mean like:
startTimestamp
endTimestamp

So people would not have to look into the code to understand what timestamp means in the context of the transaction.

@dashed dashed mentioned this pull request Jul 16, 2019
36 tasks
@dashed
Copy link
Member

dashed commented Jul 16, 2019

Is it possible to have a dedicated transaction object?

Something like

{
    // ...
    
    "transaction": {
        "name": "/country_by_code/",
        "start_timestamp": 1562681591.0,
        "end_timestamp": 1562681591.0,
    },

    // left alone for other parts of the frontend
    "timestamp": 1562681591.0,
}

@markstory
Copy link
Member Author

@dashed I'm reluctant to overload transaction as it means something different in the application internals. I could however add the name, start & end timestamps to metadata as that is a flex slot that varies by event type.

@dashed
Copy link
Member

dashed commented Jul 16, 2019

@markstory Yea the metadata slot may be suitable. As long as the transaction attributes are grouped together somewhere 😄 .

I feel like attributes start_timestamp don't really belong at the top level.

@markstory markstory force-pushed the sen-799-start-timestamp branch from 913a769 to 61522bd Compare July 16, 2019 17:38
@markstory
Copy link
Member Author

I've moved the start & end timestamps into the TransactionEvent metadata value. This resolves the structural issues in the API response, but has an impact on storage.

With timestamps in the metadata, the generated message that ends up in clickhouse contains both timestamps. An example of this is 1563298402.26 1563298402.24 /cities/

@dashed
Copy link
Member

dashed commented Jul 16, 2019

I don't think we want the message to be like that 😬

@markstory
Copy link
Member Author

@dashed I've done some refactoring in EventManager to move the message generation into the event types. This change will prevent the timestamps from being indexed in the message.

@fpacifici Do you think the timestamp names need to change if they are located in metadata? I'd like to avoid having different names between the transaction event and the spans if possible.

@markstory markstory force-pushed the sen-799-start-timestamp branch from 61522bd to e1e8cb6 Compare July 17, 2019 19:12
@dashed
Copy link
Member

dashed commented Jul 17, 2019

This looks pretty good to me. 👏

I'll leave the implementation details to @fpacifici since I don't have strong opinions on that front.

@fpacifici
Copy link
Contributor

Do you think the timestamp names need to change if they are located in metadata? I'd like to avoid having different names between the transaction event and the spans if possible.

meh .... ok. If we are end up being inconsistent either way feel free to ignore my comment.


data = CanonicalKeyDict(data)
if platform in ('csp', 'hkpk', 'expectct', 'expectstaple'):
if platform in ('transaction', 'csp', 'hkpk', 'expectct', 'expectstaple'):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this change needed ? It was not here in the previous version if I remember correctly

Copy link
Member Author

Choose a reason for hiding this comment

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

Without this the sample transaction event gets data added to the extra, modules and request interfaces which are generally not going to be present on a transaction event payload.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, but "transaction" should not be a platform. By doing this we are overloading the meaning and behavior of a parameter. Also you are skipping line 145 where the "platform" field is added to data. Is this intentional.
If you need a different behavior for different event types, I would suggest to pass the event type as an optional parameter, or, better pass a parameter that tells which interfaces to pass.

Copy link
Member Author

Choose a reason for hiding this comment

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

The variable name platform is an awkward name as it is used to locate a sample/fixture file in src/sentry/data/samples. The files there are a mixture of both sample SDK events and special scenarios like empty-exception or python-omittedbody.

On transaction events expose both the start and end timestamps. This
will allow us to correctly display the transaction span length.

Refs SEN-799
Move logic to serialize transaction only events into a separate method.
This also allows error/default only logic to be moved as well. I've
elected to not emit `dateCreated` on transaction events as it is
redundant given the start/end timestamps.
@markstory markstory force-pushed the sen-799-start-timestamp branch from eb1cb2f to 0c40d72 Compare July 24, 2019 17:12
@markstory
Copy link
Member Author

I've removed the metadata attribute. I talked with @jan-auer and event metadata is intended to capture data that needs to be persisted to the 'group'. Since transaction events don't have groups using this doesn't follow the original intent.

I've gone back to exposing timestamps on the root level of the event and using startTimestamp and endTimestamp to be more clear. While this creates some dissimilarity with how spans represent ending timestamp, I'm open to renaming those properties as well.

I've also shifted some of the properties that will only appear on error events around so that those keys are never populated on transaction events.

Copy link
Member

@dashed dashed left a comment

Choose a reason for hiding this comment

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

Looks good to me. 👍

I'll let either @fpacifici or Vienna give their feedback (cc @jan-auer )

'metadata': obj.get_event_metadata(),
'tags': tags,
'platform': obj.platform,
'dateCreated': obj.datetime,
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed a few dependencies on dateCreated

src/sentry/static/sentry/app/views/organizationEventsV2/eventModalContent.jsx: date={getDynamicText({value: event.dateCreated, fixed: 'Dummy timestamp'})}
src/sentry/static/sentry/app/views/organizationEventsV2/modalLineGraph.jsx: const eventTime = +new Date(currentEvent.dateCreated);
src/sentry/static/sentry/app/views/organizationGroupDetails/eventToolbar.jsx: const dateCreated = moment(evt.dateCreated);

Are these going to be ok if you remove the field? I suspect there is no acceptance test that go through transaction event.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good finds. The modal graph and content component do need to be updated. The GroupDetailsToolbar should be fine as transaction events won't have groups.

@fpacifici
Copy link
Contributor

I am ok with this now. @dashed you may want to have a look at the UI change.

@markstory markstory merged commit b5a0a68 into master Jul 25, 2019
@joshuarli joshuarli deleted the sen-799-start-timestamp branch August 27, 2019 20:11
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants