-
Notifications
You must be signed in to change notification settings - Fork 77
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
Introduce an observability crate using opentelemetry-rust #2535
Conversation
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Important Review skippedReview was skipped due to path filters Files ignored due to path filters (1)
You can disable this status message by setting the WalkthroughWalkthroughThis update introduces a new observability library to a Rust workspace, enhancing monitoring and tracing capabilities. Key additions include a Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Config as Config
participant Tracer as Tracer Provider
participant Meter as Meter Provider
participant Observability as Observability Manager
App->>Config: Create configuration
Config->>Observability: Build observability
Observability->>Tracer: Initialize tracer if enabled
Observability->>Meter: Initialize meter if enabled
Observability->>App: Ready for telemetry
App->>Observability: Shutdown observability
Observability->>Tracer: Shutdown tracer
Observability->>Meter: Shutdown meter
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
Signed-off-by: hlts2 <[email protected]>
[CHATOPS:HELP] ChatOps commands.
|
Signed-off-by: hlts2 <[email protected]>
Deploying vald with Cloudflare Pages
|
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
rust/Cargo.lock
is excluded by!**/*.lock
Files selected for processing (6)
- rust/Cargo.toml (1 hunks)
- rust/libs/observability/Cargo.toml (1 hunks)
- rust/libs/observability/src/config.rs (1 hunks)
- rust/libs/observability/src/lib.rs (1 hunks)
- rust/libs/observability/src/macros.rs (1 hunks)
- rust/libs/observability/src/observability.rs (1 hunks)
Files skipped from review due to trivial changes (3)
- rust/Cargo.toml
- rust/libs/observability/Cargo.toml
- rust/libs/observability/src/lib.rs
Additional comments not posted (18)
rust/libs/observability/src/config.rs (9)
22-27
: LGTM!The
Config
struct is well-defined with fields for enabling observability, attributes, tracer, and meter.
43-77
: LGTM!The
Config
struct methods use the builder pattern effectively for configuration.
79-93
: LGTM!The
Default
implementation forConfig
is straightforward, and theFrom<&Config> for Resource
implementation correctly converts config attributes to OpenTelemetry resources.
30-34
: LGTM!The
Tracer
struct is well-defined with fields for enabling tracing and specifying the endpoint.
96-107
: LGTM!The
Tracer
struct methods use the builder pattern effectively for configuration.
110-114
: LGTM!The
Default
implementation forTracer
is straightforward.
36-41
: LGTM!The
Meter
struct is well-defined with fields for enabling metrics, specifying the endpoint, and export duration.
116-133
: LGTM!The
Meter
struct methods use the builder pattern effectively for configuration.
136-140
: LGTM!The
Default
implementation forMeter
is straightforward.rust/libs/observability/src/observability.rs (5)
28-31
: LGTM!The
Observability
trait is well-defined with methods for building and shutting down observability.
33-37
: LGTM!The
ObservabilityImpl
struct is well-defined with fields for config, meter provider, and tracer provider.
39-50
: LGTM!The
ObservabilityImpl
struct methods for accessing config are well-structured.
53-92
: LGTM!The
build
method initializes the meter and tracer providers based on the configuration.
95-116
: LGTM!The
shutdown
method ensures proper shutdown of the meter and tracer providers.rust/libs/observability/src/macros.rs (4)
17-24
: LGTM!The
tracer
macro is well-defined and provides a convenient way to obtain a tracer instance.
28-41
: LGTM!The
ctx_span
macro is well-defined and provides a convenient way to create a span within a given context.
28-41
: LGTM!The
meter
macro is well-defined and provides a convenient way to obtain a meter instance.
63-149
: LGTM!The
instrument
macro is well-defined and provides a convenient way to create various types of instruments.
Signed-off-by: hlts2 <[email protected]>
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- rust/libs/observability/src/observability.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- rust/libs/observability/src/observability.rs
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
rust/Cargo.lock
is excluded by!**/*.lock
Files selected for processing (1)
- rust/libs/observability/src/config.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- rust/libs/observability/src/config.rs
Signed-off-by: hlts2 <[email protected]>
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- rust/libs/observability/src/observability.rs (1 hunks)
Additional comments not posted (7)
rust/libs/observability/src/observability.rs (7)
1-15
: LGTM! License header is correct.The license header is consistent with the Apache License, Version 2.0.
16-24
: LGTM! Import statements are appropriate.The import statements include necessary modules and seem appropriate for the functionality provided.
27-27
: LGTM! Constant declaration is appropriate.The constant
SERVICE_NAME
is declared usingopentelemetry_semantic_conventions
and seems appropriate.
29-31
: LGTM! Trait definition is appropriate.The
Observability
trait includes ashutdown
method, which is essential for graceful shutdown.
33-37
: LGTM! Struct definition is appropriate.The
ObservabilityImpl
struct includes fields for configuration, meter provider, and tracer provider, which are necessary for observability.
101-123
: LGTM! Method implementation is appropriate.The
shutdown
method correctly shuts down meter and tracer providers if enabled.
39-94
: LGTM! Method implementation is appropriate.The
new
method initializes theObservabilityImpl
struct and sets up meter and tracer providers if enabled.However, ensure that the
config
method is correctly used in the codebase.Verification successful
The
config
method is correctly defined and used.The
config
method is implemented in therust/libs/observability/src/observability.rs
file and returns a reference to theConfig
struct. It is used within the same file to access configuration values.
rust/libs/observability/src/observability.rs
: Definition and usage of theconfig
method.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `config` method in the codebase. # Test: Search for the method usage. Expect: Correct usage of the method. rg --type rust -A 5 $'fn config(&self) -> &Config'Length of output: 51
Script:
#!/bin/bash # Description: Verify the definition and usage of the `config` method in the codebase. # Search for the definition of the `config` method. rg --type rust 'fn config(&self) -> &Config' # Search for the usage of the `config` method. rg --type rust '.config()'Length of output: 15831
* feat: add observability crate Signed-off-by: hlts2 <[email protected]> * fix: fix crate name Signed-off-by: hlts2 <[email protected]> * feat: add module files Signed-off-by: hlts2 <[email protected]> * feat: create config Signed-off-by: hlts2 <[email protected]> * fix: implement from trait Signed-off-by: hlts2 <[email protected]> * feat: add tracer and meter macro Signed-off-by: hlts2 <[email protected]> * feat: add license Signed-off-by: hlts2 <[email protected]> * fix: use full module path Signed-off-by: hlts2 <[email protected]> * fix: add shutdown method Signed-off-by: hlts2 <[email protected]> * feat: add build method to crate tracer provider and meter provider Signed-off-by: hlts2 <[email protected]> * fix: module path Signed-off-by: hlts2 <[email protected]> * fix: add export timeout duration and comment Signed-off-by: hlts2 <[email protected]> * feat: update interface Signed-off-by: hlts2 <[email protected]> * feat: add endpint configuration to root configuration Signed-off-by: hlts2 <[email protected]> * fix: update deps Signed-off-by: hlts2 <[email protected]> * fix: small refactor Signed-off-by: hlts2 <[email protected]> * fix: deleted build method to create trace and metrics provider Signed-off-by: hlts2 <[email protected]> --------- Signed-off-by: hlts2 <[email protected]>
* feat: add observability crate Signed-off-by: hlts2 <[email protected]> * fix: fix crate name Signed-off-by: hlts2 <[email protected]> * feat: add module files Signed-off-by: hlts2 <[email protected]> * feat: create config Signed-off-by: hlts2 <[email protected]> * fix: implement from trait Signed-off-by: hlts2 <[email protected]> * feat: add tracer and meter macro Signed-off-by: hlts2 <[email protected]> * feat: add license Signed-off-by: hlts2 <[email protected]> * fix: use full module path Signed-off-by: hlts2 <[email protected]> * fix: add shutdown method Signed-off-by: hlts2 <[email protected]> * feat: add build method to crate tracer provider and meter provider Signed-off-by: hlts2 <[email protected]> * fix: module path Signed-off-by: hlts2 <[email protected]> * fix: add export timeout duration and comment Signed-off-by: hlts2 <[email protected]> * feat: update interface Signed-off-by: hlts2 <[email protected]> * feat: add endpint configuration to root configuration Signed-off-by: hlts2 <[email protected]> * fix: update deps Signed-off-by: hlts2 <[email protected]> * fix: small refactor Signed-off-by: hlts2 <[email protected]> * fix: deleted build method to create trace and metrics provider Signed-off-by: hlts2 <[email protected]> --------- Signed-off-by: hlts2 <[email protected]>
) * feat: add observability crate * fix: fix crate name * feat: add module files * feat: create config * fix: implement from trait * feat: add tracer and meter macro * feat: add license * fix: use full module path * fix: add shutdown method * feat: add build method to crate tracer provider and meter provider * fix: module path * fix: add export timeout duration and comment * feat: update interface * feat: add endpint configuration to root configuration * fix: update deps * fix: small refactor * fix: deleted build method to create trace and metrics provider --------- Signed-off-by: hlts2 <[email protected]>
Description
I Introduced an observability crate using opentelemetry-rust.
Important aspects of design
Since opentelemetry-rust is still under development, interface changes may occur in the future.
Therefore, this crate is designed to make the user as unaware of opentelemetry-rust as possible.
If the interface is changed in the future, only the macro needs to be modified.
Related Issue
Versions
Checklist
Special notes for your reviewer
Summary by CodeRabbit
Summary by CodeRabbit
New Features
observability
package for enhanced monitoring and tracing in Rust applications.Documentation