-
Notifications
You must be signed in to change notification settings - Fork 437
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
Move Logs and Metrics error constructs to SDK #2266
Conversation
…elemetry-rust into remove-global-error-handler
#[cfg(feature = "trace")] | ||
use opentelemetry::trace::TraceError; | ||
|
||
/// Wrapper for error from both tracing and metrics part of open telemetry. |
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.
Though this is moving from just one crate to another, I'd like to first confirm that these are indeed required. I understand that it is desirable to return specialized errors from user-facing APIs, but most of the errors here are only for internal logging only. Is there any additional value provided by this?
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.
See #2241 (comment) for prior discussion.
If we don't plan to keep this, then its best to just remove it, instead of moving from api to sdk and then removing it again.
(Note: These are still public APIs in the sdk crate)
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.
See https://github.com/open-telemetry/opentelemetry-rust/pull/2266/files#r1826889942
It maybe better off removing them altogether than moving from api to sdk crate.
I am not sure if we agreed on removing this based on that comment. This needs some more discussions. These error constructs were always used in the SDK, so it's logical to first move their definition to SDK. This would also enable us to proceed with the RC for the API and then make a decision regarding the SDK. |
Please use this PR to drive a decision for the same. |
Why do we need to do that here? The API cleanup is logical, and this PR make sense to go first without any breaking anything. We can have separate issue/PR to discuss the breaking changes in terms of removing the constructs altogether. |
Because, as mentioned here, this PR is introducing new public API to the sdk crate, that we may need to remove in future again. Totally agree with removing it from |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2266 +/- ##
=======================================
- Coverage 79.4% 79.4% -0.1%
=======================================
Files 121 122 +1
Lines 20787 20795 +8
=======================================
+ Hits 16512 16514 +2
- Misses 4275 4281 +6 ☔ View full report in Codecov by Sentry. |
The Result/Error are used within SDK in these public APIs:
Similarly for Metrics, probably also while returning the error from View creation. The question is - if we want to remove the Result/Error, what are we instead looking for - returning bool as status, or just the error string? Returning structured error is in general better instead of letting user rely on doing string match to identify the error type. Result enum is already part of rust std lib, and idiomatic. If the goal is to maintain a minimal public surface for the SDK, we can still achieve this using the result/error construct as needed, as shown below. However, once they are removed, reintroducing them later could be challenging without causing breaking changes. /// Describe the result of operations in log SDK.
pub type LogResult<T> = Result<T, LogError>;
#[derive(Error, Debug)]
#[non_exhaustive]
/// Errors returned by the log SDK.
pub enum LogError {
/// A generic error message for errors in the log SDK.
#[error("{0}")]
Message(String),
} |
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.
From Community Meeting:
- This is mandatory to declare opentelemetry as RC.
- The APIs being moved to SDK might need a re-review in the future, but that is okay.
- Make changelog as this is user breaking change.
- Must merge for 0.27, so not worth trying to split into shorter ones.
- Traces is untouched, lets leave it for a future release.
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.
Thanks for cleaning up the API crate!
Lets follow up in the future to review these to make everything is needed in sdk also as public.
Fixes #1042
Changes
Needs #2256 and #2260 to be merged first. Also the PR is on top of #2260, so better to review this once that PR is merged.Summary of changes:
ExportError
trait:opentelemetry/src/common.rs
toopentelemetry-sdk/src/export/mod.rs
opentelemetry/src/trace/mod.rs
. This will be eventually consolidated within SDK once we work on traces.LogError
enum andLogResult
type alias :opentelemetry/src/logs/mod.rs
toopentelemetry-sdk/src/logs/error.rs
MetricError
enum andMetricResult
type alias:opentelemetry/src/metrics/mod.rs
toopentelemetry-sdk/src/metrics/error.rs
TraceError
enum andTraceResult
type alias:Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes