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

Add DisableSkipErrMetrics to disable ErrSkip metrics #389

Merged
merged 3 commits into from
Dec 12, 2024

Conversation

ncthompson
Copy link
Contributor

@ncthompson ncthompson commented Nov 28, 2024

DisableSkipErrMetrics will skip the recoding of any SkipErr metric if enabled.
Since SkipErr results in a retry, the actual database interaction will still be recorded.

Closes #386

@ncthompson ncthompson requested a review from XSAM as a code owner November 28, 2024 07:23
Copy link

codecov bot commented Nov 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.2%. Comparing base (5b7f647) to head (9e09094).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##            main    #389     +/-   ##
=======================================
+ Coverage   83.0%   83.2%   +0.1%     
=======================================
  Files         13      13             
  Lines        750     758      +8     
=======================================
+ Hits         623     631      +8     
  Misses       103     103             
  Partials      24      24             

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

@ncthompson ncthompson force-pushed the add-disable-skip-err-metrics branch from d0e9a0c to c070d6e Compare November 28, 2024 07:24
Copy link
Owner

@XSAM XSAM left a comment

Choose a reason for hiding this comment

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

@ncthompson, thanks for the PR!

It looks good. I only have a naming issue. BTW, do you think skipping the entire measurement creation when encountering ErrSkip is better than recording a measurement with status OK?

config.go Outdated Show resolved Hide resolved
option.go Outdated Show resolved Hide resolved
option_test.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@ncthompson
Copy link
Contributor Author

@ncthompson, thanks for the PR!

It looks good. I only have a naming issue. BTW, do you think skipping the entire measurement creation when encountering ErrSkip is better than recording a measurement with status OK?

I was debating this myself when creating this. From looking at the lib itself, it always retries on a ErrSkip. So it feels like you will have "duplicate" measurements if you log both. I am open to change it if you feel like this will hide measurements that should rather be logged.

@ncthompson ncthompson force-pushed the add-disable-skip-err-metrics branch from c070d6e to 2c9c905 Compare December 3, 2024 07:27
@XSAM
Copy link
Owner

XSAM commented Dec 4, 2024

@ncthompson, thanks for the PR!
It looks good. I only have a naming issue. BTW, do you think skipping the entire measurement creation when encountering ErrSkip is better than recording a measurement with status OK?

I was debating this myself when creating this. From looking at the lib itself, it always retries on a ErrSkip. So it feels like you will have "duplicate" measurements if you log both. I am open to change it if you feel like this will hide measurements that should rather be logged.

I took some time to think about this, and I prefer the way to keep the "duplicate" measurement. Here are my reasons:

  • This keeps the consistent behavior of DisableErrSkip on the span part. I am concerned that having different behaviors can cause confusion to users.

    otelsql/config.go

    Lines 98 to 99 in e9f8e31

    // DisableErrSkip, if set to true, will suppress driver.ErrSkip errors in spans.
    DisableErrSkip bool

    otelsql/utils.go

    Lines 44 to 48 in e9f8e31

    case driver.ErrSkip:
    if !opts.DisableErrSkip {
    span.RecordError(err)
    span.SetStatus(codes.Error, "")
    }

  • The "duplicate" measurement records the actual invoke of the method even if it returned early.

  • Long term fix

DisableSkipErrMeasurement will suppress the recoding of any SkipErr metric if enabled.
The measurement will be recorded as status=ok.
See XSAM#386
@ncthompson ncthompson force-pushed the add-disable-skip-err-metrics branch from 2c9c905 to bbfef15 Compare December 5, 2024 09:07
@ncthompson
Copy link
Contributor Author

@ncthompson, thanks for the PR!
It looks good. I only have a naming issue. BTW, do you think skipping the entire measurement creation when encountering ErrSkip is better than recording a measurement with status OK?

I was debating this myself when creating this. From looking at the lib itself, it always retries on a ErrSkip. So it feels like you will have "duplicate" measurements if you log both. I am open to change it if you feel like this will hide measurements that should rather be logged.

I took some time to think about this, and I prefer the way to keep the "duplicate" measurement. Here are my reasons:

  • This keeps the consistent behavior of DisableErrSkip on the span part. I am concerned that having different behaviors can cause confusion to users.

    otelsql/config.go

    Lines 98 to 99 in e9f8e31

    // DisableErrSkip, if set to true, will suppress driver.ErrSkip errors in spans.
    DisableErrSkip bool

    otelsql/utils.go

    Lines 44 to 48 in e9f8e31

    case driver.ErrSkip:
    if !opts.DisableErrSkip {
    span.RecordError(err)
    span.SetStatus(codes.Error, "")
    }

  • The "duplicate" measurement records the actual invoke of the method even if it returned early.

  • Long term fix

Thanks for the feedback! 😄

I have updated it so it suppresses the ErrSkip like in the tracing case. Have a look if that makes sense to you.

Copy link
Owner

@XSAM XSAM left a comment

Choose a reason for hiding this comment

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

Thanks for the update and contribution. Please merge the main branch and update the CHANGELOG as suggested, so I can merge this PR.

CHANGELOG.md Outdated Show resolved Hide resolved
@XSAM XSAM merged commit cc367ec into XSAM:main Dec 12, 2024
15 checks passed
@XSAM XSAM mentioned this pull request Dec 19, 2024
XSAM added a commit that referenced this pull request Dec 19, 2024
### Added

- `DisableSkipErrMeasurement` option suppresses `driver.ErrSkip` as an
error status in measurements if enabled. (#389)

### Changed

- Upgrade OTel to `v1.33.0/v0.55.0`. (#396)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not report ErrSkip in metrics as error
2 participants