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

fix(backend): matching trigger span duration and trigger time durations #2740

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented Jun 15, 2023

This PR fixes the trigger trace span duration calculation to have the same value as the test run trigger duration

Changes

  • Updates startTime and endTime to use the same value as the test run trigger time
  • Uses same time diff

Fixes

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

https://www.loom.com/share/1e0dac6d5af94a1ebeca443863fa5677

@xoscar xoscar marked this pull request as ready for review June 16, 2023 14:24
@xoscar xoscar self-assigned this Jun 16, 2023
@xoscar xoscar added the backend label Jun 16, 2023
Copy link
Collaborator

@schoren schoren left a comment

Choose a reason for hiding this comment

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

LGTM! I would remove that very tiny function but it's not critical

timeDifference := span.EndTime.Sub(span.StartTime)
return fmt.Sprintf("%d", int64(timeDifference))
timeDifference := timeDiff(span.StartTime, span.EndTime)
return fmt.Sprintf("%d", durationInNanoseconds(timeDifference))
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this durationInNanoseconds needed? you need to follow an extra indirection that is only a single line.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, you don't even need to cast to int, %d can handle int64 correctly: https://go.dev/play/p/8Vth4PCiQyO

Suggested change
return fmt.Sprintf("%d", durationInNanoseconds(timeDifference))
return fmt.Sprintf("%d", timeDifference.Nanoseconds())

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Shoot sorry, I didn't see this. I'll add them in my next PR

@xoscar xoscar merged commit cc74056 into main Jun 16, 2023
24 checks passed
@xoscar xoscar deleted the 2709-triggertime-does-not-match-tracetestspanduration-in-tracetest-trigger-span branch June 16, 2023 14:53
danielbdias added a commit that referenced this pull request Jun 16, 2023
* Adding initial APIs for the example

* Adding code for payment-executor-api

* Adding full example

* Adding trace-based tests

* Updating README

* Apply suggestions from code review

Co-authored-by: Adnan Rahić <adnan@kubeshop.io>

* Adding documentation to the example

* fix(backend): matching trigger span duration and trigger time durations (#2740)

* fix(frontend): adding default value for data store connection types (#2742)

* fix(backend): fixing response status code for grpc request (#2741)

* feat: add upsert method and enable it for environments (#2746)

* add upsert method and enable it for environments

* handle error when getting entity

* PR suggestions

---------

Co-authored-by: Adnan Rahić <adnan@kubeshop.io>
Co-authored-by: Oscar Reyes <oscar-rreyes1@hotmail.com>
Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>
mathnogueira added a commit that referenced this pull request Jun 19, 2023
* Adding initial APIs for the example

* Adding code for payment-executor-api

* Adding full example

* Adding trace-based tests

* Updating README

* Apply suggestions from code review

Co-authored-by: Adnan Rahić <adnan@kubeshop.io>

* Adding documentation to the example

* fix(backend): matching trigger span duration and trigger time durations (#2740)

* fix(frontend): adding default value for data store connection types (#2742)

* fix(backend): fixing response status code for grpc request (#2741)

* feat: add upsert method and enable it for environments (#2746)

* add upsert method and enable it for environments

* handle error when getting entity

* PR suggestions

---------

Co-authored-by: Adnan Rahić <adnan@kubeshop.io>
Co-authored-by: Oscar Reyes <oscar-rreyes1@hotmail.com>
Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>
mathnogueira added a commit that referenced this pull request Jun 19, 2023
* Adding initial APIs for the example

* Adding code for payment-executor-api

* Adding full example

* Adding trace-based tests

* Updating README

* Apply suggestions from code review

Co-authored-by: Adnan Rahić <adnan@kubeshop.io>

* Adding documentation to the example

* fix(backend): matching trigger span duration and trigger time durations (#2740)

* fix(frontend): adding default value for data store connection types (#2742)

* fix(backend): fixing response status code for grpc request (#2741)

* feat: add upsert method and enable it for environments (#2746)

* add upsert method and enable it for environments

* handle error when getting entity

* PR suggestions

---------

Co-authored-by: Adnan Rahić <adnan@kubeshop.io>
Co-authored-by: Oscar Reyes <oscar-rreyes1@hotmail.com>
Co-authored-by: Matheus Nogueira <matheus.nogueira2008@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

triggerTime does not match tracetest.span.duration in "Tracetest trigger" span
3 participants