-
Notifications
You must be signed in to change notification settings - Fork 375
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
feat: add span metrics for traces #3787
Conversation
WalkthroughThe changes introduce new metrics collection capabilities using OpenTelemetry in the Rust project. This includes adding new structures and functions for tracing metrics, new configurations, and exporting mechanisms. The focus is on collecting and recording span metrics for traces, initializing and shutting down meter providers, and logging enhancements. Changes
sequenceDiagram
participant User
participant Application
participant TraceService
participant MetricsProvider
participant Exporter
User ->> Application: Send trace data
Application ->> TraceService: Handle trace request
TraceService ->> MetricsProvider: Record span metrics
MetricsProvider ->> Exporter: Export metrics
Exporter ->> MetricsProvider: Acknowledge export
MetricsProvider ->> TraceService: Metrics recorded
TraceService ->> Application: Trace request handled
Application ->> User: Response
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 (
|
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: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- src/config/src/config.rs (1 hunks)
- src/config/src/metrics.rs (2 hunks)
- src/service/traces/mod.rs (4 hunks)
Additional context used
Path-based instructions (3)
src/service/traces/mod.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/config/src/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/config/src/config.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (4)
src/service/traces/mod.rs (2)
125-125
: Initialization ofspan_metrics
is well-implemented.This line correctly initializes
span_metrics
with a capacity equal to the number of resource spans, which is efficient memory management.
249-266
: Implementation of span metrics recording logic.The logic to build and push span metrics is implemented correctly. However, ensure that the removal of "o2_span_metrics_name" from
v
(line 256-257) does not affect other parts of the system that might expect this key to exist.Verification successful
The search results indicate that the variable
v
is used later in the code, but not in a way that would be affected by the removal of the "o2_span_metrics_name" key. Specifically,v
is used as part of a match arm at line 267, and it is not directly referenced in any subsequent logic that would require the "o2_span_metrics_name" key.Based on this analysis, the removal of the "o2_span_metrics_name" key from
v
does not seem to impact other parts of the system.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify if 'o2_span_metrics_name' is used elsewhere in the system. # Test: Search for 'o2_span_metrics_name' in the codebase. Expect: No other usage. rg 'o2_span_metrics_name'Length of output: 115
Script:
#!/bin/bash # Description: Check if `v` is used after the removal of "o2_span_metrics_name". # Test: Search for usage of `v` after line 257 in the file src/service/traces/mod.rs. rg 'v' -n -A 20 src/service/traces/mod.rs | awk '$1 > 257'Length of output: 13573
src/config/src/metrics.rs (2)
567-586
: Definition of theSPAN_DURATION_MILLISECONDS
metric.The metric is defined with appropriate buckets and labels that align with the PR objectives. The labels include all necessary dimensions to provide detailed insights into span metrics.
736-737
: Registration of theSPAN_DURATION_MILLISECONDS
metric.The registration of the new metric is correctly implemented. This ensures that the metric is available for recording in the monitoring system.
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- Cargo.toml (1 hunks)
- src/job/metrics.rs (2 hunks)
- src/job/mod.rs (1 hunks)
- src/main.rs (2 hunks)
- src/service/traces/mod.rs (4 hunks)
Files skipped from review due to trivial changes (1)
- Cargo.toml
Files skipped from review as they are similar to previous changes (1)
- src/service/traces/mod.rs
Additional context used
Path-based instructions (3)
src/job/mod.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/main.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (8)
src/job/mod.rs (1)
35-35
: Public Access Granted tometrics
ModuleMaking the
metrics
module public allows broader access to the new metrics functionalities. Ensure that this change aligns with the intended access control and architecture of the project.src/job/metrics.rs (5)
49-58
: Introduction ofTraceMetricsItem
StructThe newly introduced
TraceMetricsItem
struct is well-defined with appropriate field types. Ensure all fields are necessary and consider adding documentation comments to explain each field's role in trace metrics.
60-63
: Type Alias forTraceMetricsChan
The type alias for
TraceMetricsChan
uses Rust's async primitives effectively. This setup is appropriate for handling asynchronous message passing in metrics collection.
65-68
: Initialization ofTRACE_METRICS_CHAN
The static variable
TRACE_METRICS_CHAN
is initialized correctly usingLazy::new
. This ensures thread safety and lazy initialization which is suitable for performance-sensitive applications.
288-329
: Initialization of Meter ProviderThe function
init_meter_provider
is well-structured and uses OpenTelemetry's OTLP configuration effectively. The use of metadata and credentials is secure, but ensure that sensitive information like credentials is handled securely throughout the system.
331-347
: Trace Metrics Collection FunctionalityThe function
traces_metrics_collect
is designed to handle trace metrics asynchronously. The use ofTRACE_METRICS_SPAN_HISTOGRAM
for recording metrics is appropriate. Ensure that error handling is robust, especially in production environments.src/main.rs (2)
207-209
: Meter Provider InitializationThe initialization of the meter provider in the main function is correctly implemented. This setup is crucial for enabling the newly added metrics functionalities.
240-242
: Meter Provider ShutdownProperly shutting down the meter provider is essential for releasing resources. The implementation here ensures that resources are cleaned up, which is good practice.
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 (2)
- src/job/metrics.rs (2 hunks)
- src/service/traces/mod.rs (4 hunks)
Files skipped from review as they are similar to previous changes (2)
- src/job/metrics.rs
- src/service/traces/mod.rs
/ok-to-test sha=ba43e60 |
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- src/config/src/metrics.rs (3 hunks)
- src/job/metrics.rs (2 hunks)
- src/service/traces/mod.rs (4 hunks)
Files skipped from review as they are similar to previous changes (2)
- src/config/src/metrics.rs
- src/service/traces/mod.rs
Additional context used
Path-based instructions (1)
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (7)
src/job/metrics.rs (7)
52-61
: Struct definition forTraceMetricsItem
is well-defined.This struct is crucial for handling trace metrics data. It's well-structured to include all necessary fields for the metrics.
63-66
: Type alias forTraceMetricsChan
is correctly defined.The use of a tuple for the sender and receiver wrapped in a
RwLock
is appropriate for thread-safe asynchronous message passing.
68-71
: Initialization ofTRACE_METRICS_CHAN
usingLazy
.The use of
Lazy
for initializing theTRACE_METRICS_CHAN
is appropriate to ensure it's thread-safe and only initialized once.
73-80
: Histogram initialization inTRACE_METRICS_SPAN_HISTOGRAM
.The histogram is correctly initialized with appropriate units and description. This aligns with the previous comment about ensuring the unit matches the variable name.
294-336
: Initialization of the OpenTelemetry meter provider is robust.The configuration for the exporter and meter provider is detailed and appropriately set up with error handling and metadata management. This setup is crucial for ensuring accurate metrics reporting.
338-356
: Metrics collection logic intraces_metrics_collect
.The function correctly handles the asynchronous receipt of metrics data and records it using the histogram. This is a key part of the metrics pipeline.
16-46
: Ensure consistent use of imports and namespaces.Imports from
opentelemetry
and related crates are expanded, which is good for clarity. However, ensure that all necessary imports are included, especially given the extensive use of metrics and async functionalities.Verification successful
Ensure consistent use of imports and namespaces.
The imports in
src/job/metrics.rs
appear to cover a wide range of necessary functionalities, including metrics, async operations, and other utilities. Here are the key points:
- Imports from
opentelemetry
,opentelemetry_otlp
, andopentelemetry_sdk
cover metrics and tracing functionalities.- Imports from
tokio
cover async functionalities.- Other imports (
std
,config
,hashbrown
,infra
,once_cell
,tonic
) provide necessary utilities and configurations.Based on the provided context, all necessary imports seem to be included. However, ensure to double-check the functions and types used in the file to confirm that no imports are missing.
No further action required.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Ensure all necessary imports for metrics and async functionalities are included. rg --type rust 'use' src/job/metrics.rsLength of output: 719
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/job/metrics.rs (2 hunks)
Additional context used
Path-based instructions (1)
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (6)
src/job/metrics.rs (6)
16-22
: Consider optimizing imports.There seems to be a redundancy in the
use
statements for themetrics
module. This could be streamlined for better clarity and reduced verbosity.
[REFACTOR_Suggestion]- use config::{cluster, get_config, meta::{cluster::Role, stream::StreamType}, metrics}; - use config::metrics::{NAMESPACE, SPAN_METRICS_BUCKET}; + use config::{cluster, get_config, meta::{cluster::Role, stream::StreamType}, metrics::{self, NAMESPACE, SPAN_METRICS_BUCKET}};
52-61
: New structTraceMetricsItem
looks good.The struct
TraceMetricsItem
is well-defined with appropriate field types. Good job on keeping the fields public for easy access where necessary.
68-71
: Initialization ofTRACE_METRICS_CHAN
is correct.The use of
Lazy
for the static variableTRACE_METRICS_CHAN
ensures thread-safe initialization. The channel size of 2048 seems reasonable, but consider documenting why this specific size was chosen.
73-80
: Histogram setup inTRACE_METRICS_SPAN_HISTOGRAM
.The setup of the histogram for span duration metrics is correctly implemented. The unit of measurement and description are accurately set.
340-355
: Metrics collection logic intraces_metrics_collect
.The logic to collect metrics and record them using the histogram instrument is implemented correctly. The use of key-value pairs for labeling the histogram is a good practice.
295-338
: Initialization of the meter provider ininit_meter_provider
.The configuration for the meter provider is correctly set with appropriate metadata, exporter settings, and interval. However, ensure that the endpoint and token are not hardcoded in production environments.
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: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/config/src/config.rs (1 hunks)
- src/job/metrics.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/config/src/config.rs
Additional context used
Path-based instructions (1)
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (4)
src/job/metrics.rs (4)
16-16
: Review imports for unused elements.It seems like there are multiple imports under the
metrics
namespace. Ensure that all imported elements are actually used to prevent clutter.Also applies to: 22-22
53-61
: Ensure proper documentation forTraceMetricsItem
.The struct
TraceMetricsItem
is central to the metrics functionality but lacks documentation. Consider adding comments to explain the role of each field, especially how they interact with the metrics system.
68-71
: Initialization ofTRACE_METRICS_CHAN
is thread-safe and efficient.Using
Lazy::new
ensures that the channel is initialized in a thread-safe manner, and the buffer size of 2048 seems reasonable given the context. However, consider documenting why this specific size was chosen.
73-80
: Correct unit of measurement forTRACE_METRICS_SPAN_HISTOGRAM
.The unit is correctly set to milliseconds (
ms
). This aligns with the previous suggestion to correct the unit from microseconds (us
).
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: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/config/src/config.rs (1 hunks)
- src/service/traces/mod.rs (4 hunks)
Additional context used
Path-based instructions (2)
src/service/traces/mod.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/config/src/config.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (1)
src/service/traces/mod.rs (1)
126-126
: Initialization of span metrics vector is efficient.The use of
Vec::with_capacity
is a good practice for performance optimization when the expected size is known.
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)
- src/job/metrics.rs (2 hunks)
Additional context used
Path-based instructions (1)
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (3)
src/job/metrics.rs (3)
16-22
: Review of imports andTraceMetricsItem
structure.The imports and the
TraceMetricsItem
struct are appropriately defined for the functionality of trace metrics collection. The struct fields align with the data needed for tracing.Also applies to: 52-61
68-91
: Initialization of static variables and error handling in therun
function.The static variables
TRACE_METRICS_CHAN
andTRACE_METRICS_SPAN_HISTOGRAM
are initialized correctly. However, the error handling in therun
function could be improved by adding retry mechanisms, as previously suggested in past comments.
The suggestions from past comments still apply here.
293-338
: Initialization of the meter provider.The meter provider is initialized with appropriate settings. However, ensure the metadata keys such as "authorization" and "organization" are correctly used and that error handling is robust, especially for potential parsing errors.
/ok-to-test sha=1118ad9 |
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: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- src/job/metrics.rs (2 hunks)
- src/service/exporter/mod.rs (1 hunks)
- src/service/exporter/otlp_o2_metrics_exporter.rs (1 hunks)
- src/service/mod.rs (1 hunks)
Files skipped from review due to trivial changes (1)
- src/service/mod.rs
Additional context used
Path-based instructions (3)
src/service/exporter/mod.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/service/exporter/otlp_o2_metrics_exporter.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (10)
src/service/exporter/mod.rs (1)
1-1
: Module Addition ApprovedAdding the
otlp_o2_metrics_exporter
module aligns with the PR's objectives to enhance metrics exporting capabilities.src/service/exporter/otlp_o2_metrics_exporter.rs (5)
16-21
: New Trait Definition: MetricsClientThe
MetricsClient
trait is well-defined with appropriate async signatures and debug constraints. This is crucial for integration with the metrics exporting functionality.
23-28
: Structure Definition: O2MetricsExporterThe
O2MetricsExporter
struct is appropriately defined with necessary components for metrics exporting. Ensure the components liketemporality_selector
andaggregation_selector
are properly initialized and used.
48-62
: Implementation of PushMetricsExporter for O2MetricsExporterThis implementation is crucial for integrating the custom metrics exporter with the OpenTelemetry SDK. The use of delegation to the
MetricsClient
for theexport
method is a good design choice, promoting modularity.
64-77
: Constructor for O2MetricsExporterThe constructor method
new
is well-implemented. It properly boxes the provided implementations, which is necessary for dynamic dispatch.
79-112
: New Struct and Trait Implementation: O2MetricsClientThe
O2MetricsClient
struct and its implementation ofMetricsClient
are correctly set up. The error handling within theexport
method logs errors appropriately, which is crucial for debugging and monitoring.src/job/metrics.rs (4)
51-60
: New Struct Definition: TraceMetricsItemThe
TraceMetricsItem
struct is well-defined with fields that align with the PR's objectives to enhance trace metrics. This struct will facilitate the structured handling of trace data.
67-70
: Initialization of TRACE_METRICS_CHANThe static variable
TRACE_METRICS_CHAN
is initialized correctly using a Lazy pattern, ensuring thread safety and initialization on first use.
72-79
: Initialization of TRACE_METRICS_SPAN_HISTOGRAMThe histogram is set up correctly to measure span durations. The use of a namespace and proper units (
ms
) aligns with best practices.
292-319
: Initialization of Meter ProviderThe setup of the meter provider and the OTLP exporter is well-implemented. The use of default selectors and proper intervals for metric export is appropriate.
/ok-to-test sha=3d3b1d8 |
/ok-to-test sha=52b5c41 |
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: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/config/src/config.rs (1 hunks)
- src/job/metrics.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/config/src/config.rs
Additional context used
Path-based instructions (1)
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (3)
src/job/metrics.rs (3)
16-22
: Ensure necessary imports for tracing and metrics.The imports appear appropriate for the functionalities being implemented, especially with the use of OpenTelemetry and Tokio. Ensure that all these modules are used effectively throughout the file to avoid any unused imports.
51-60
: Review ofTraceMetricsItem
structure.The structure is well-defined with appropriate data types for handling trace metrics. Ensure that all fields are necessary and used within the metrics collection logic.
67-80
: Initialization ofTRACE_METRICS_SPAN_HISTOGRAM
.The histogram is initialized with the correct unit of measurement and description, aligning with the metric's purpose. Ensure that the histogram setup follows the best practices of OpenTelemetry and matches the expected metric granularity.
src/job/metrics.rs
Outdated
async fn traces_metrics_collect() -> Result<(), anyhow::Error> { | ||
let mut receiver = TRACE_METRICS_CHAN.1.write().await; | ||
|
||
while let Some(item) = receiver.recv().await { | ||
// Record measurements using the histogram instrument. | ||
TRACE_METRICS_SPAN_HISTOGRAM.record( | ||
item.duration, | ||
&[ | ||
KeyValue::new("organization", item.organization), | ||
KeyValue::new("traces_stream_name", item.traces_stream_name), | ||
KeyValue::new("service_name", item.service_name), | ||
KeyValue::new("operation_name", item.span_name), | ||
KeyValue::new("status_code", item.span_status), | ||
KeyValue::new("span_kind", item.span_kind), | ||
], | ||
); | ||
} | ||
|
||
Ok(()) |
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.
Optimize the traces_metrics_collect
function.
The function efficiently collects and records metrics. Consider adding error handling for cases where recv
might fail, such as when the channel is closed, to ensure robustness.
+ if receiver.is_closed() {
+ return Err(anyhow::Error::new(std::io::Error::new(std::io::ErrorKind::BrokenPipe, "Channel closed")));
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
async fn traces_metrics_collect() -> Result<(), anyhow::Error> { | |
let mut receiver = TRACE_METRICS_CHAN.1.write().await; | |
while let Some(item) = receiver.recv().await { | |
// Record measurements using the histogram instrument. | |
TRACE_METRICS_SPAN_HISTOGRAM.record( | |
item.duration, | |
&[ | |
KeyValue::new("organization", item.organization), | |
KeyValue::new("traces_stream_name", item.traces_stream_name), | |
KeyValue::new("service_name", item.service_name), | |
KeyValue::new("operation_name", item.span_name), | |
KeyValue::new("status_code", item.span_status), | |
KeyValue::new("span_kind", item.span_kind), | |
], | |
); | |
} | |
Ok(()) | |
async fn traces_metrics_collect() -> Result<(), anyhow::Error> { | |
let mut receiver = TRACE_METRICS_CHAN.1.write().await; | |
if receiver.is_closed() { | |
return Err(anyhow::Error::new(std::io::Error::new(std::io::ErrorKind::BrokenPipe, "Channel closed"))); | |
} | |
while let Some(item) = receiver.recv().await { | |
// Record measurements using the histogram instrument. | |
TRACE_METRICS_SPAN_HISTOGRAM.record( | |
item.duration, | |
&[ | |
KeyValue::new("organization", item.organization), | |
KeyValue::new("traces_stream_name", item.traces_stream_name), | |
KeyValue::new("service_name", item.service_name), | |
KeyValue::new("operation_name", item.span_name), | |
KeyValue::new("status_code", item.span_status), | |
KeyValue::new("span_kind", item.span_kind), | |
], | |
); | |
} | |
Ok(()) | |
} |
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)
- src/config/src/config.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/config/src/config.rs
/ok-to-test sha=297f6c3 |
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)
- src/config/src/config.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/config/src/config.rs
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)
- src/config/src/config.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/config/src/config.rs
/ok-to-test sha=624ec32 |
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: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/job/metrics.rs (2 hunks)
- src/service/traces/mod.rs (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/service/traces/mod.rs
Additional context used
Path-based instructions (1)
src/job/metrics.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (4)
src/job/metrics.rs (4)
74-81
: Verify the unit of measurement forTRACE_METRICS_SPAN_HISTOGRAM
.Ensure that the unit "ms" aligns with the actual measurements being recorded.
51-61
: LGTM!The struct
TraceMetricsItem
is well-defined and covers all necessary fields for trace metrics.
68-72
: Verify the buffer size forTRACE_METRICS_CHAN
.Ensure that the buffer size from the configuration is appropriate for the expected load.
294-320
: Fix the typo in the metadata insertion.There is a typo in the metadata insertion. "organizatlianion" should be "organization".
- metadata.insert("organizatlianion", "default".parse().unwrap()); + metadata.insert("organization", "default".parse().unwrap());Likely invalid or redundant comment.
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)
- src/handler/grpc/request/traces.rs (1 hunks)
Additional context used
Path-based instructions (1)
src/handler/grpc/request/traces.rs (1)
Pattern
**/*.rs
: You are a smart rustlang pull request reviewer.
You are going to review all the rustlang files.
Be concise, and add a brief explanation to your suggestionsMake sure the responses are not too verbose and keep the suggestions to the point i.e. actionable.
Additional comments not posted (1)
src/handler/grpc/request/traces.rs (1)
66-68
: Confirm the error logging and handling.The error is correctly logged before returning the internal status. Ensure that the log level
error
is appropriate for this context.
/ok-to-test sha=c68be91 |
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 (7)
- Cargo.toml (1 hunks)
- src/config/src/config.rs (1 hunks)
- src/config/src/metrics.rs (3 hunks)
- src/job/mod.rs (1 hunks)
- src/main.rs (2 hunks)
- src/service/mod.rs (1 hunks)
- src/service/traces/mod.rs (4 hunks)
Files skipped from review due to trivial changes (1)
- src/service/mod.rs
Files skipped from review as they are similar to previous changes (6)
- Cargo.toml
- src/config/src/config.rs
- src/config/src/metrics.rs
- src/job/mod.rs
- src/main.rs
- src/service/traces/mod.rs
/ok-to-test sha=a3928df |
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)
- src/config/src/config.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/config/src/config.rs
/ok-to-test sha=e007134 |
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 (6)
- Cargo.toml (1 hunks)
- src/config/src/config.rs (1 hunks)
- src/job/metrics.rs (2 hunks)
- src/job/mod.rs (1 hunks)
- src/main.rs (2 hunks)
- src/service/traces/mod.rs (4 hunks)
Files skipped from review as they are similar to previous changes (5)
- src/config/src/config.rs
- src/job/metrics.rs
- src/job/mod.rs
- src/main.rs
- src/service/traces/mod.rs
Additional comments not posted (1)
Cargo.toml (1)
106-106
: Approved addition of the "metrics" feature toopentelemetry_sdk
.The change aligns with the PR's objectives to enhance metric collection. Ensure that this new feature integrates well with existing functionalities and does not introduce any regressions.
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)
- src/job/metrics.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/job/metrics.rs
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)
- src/config/src/config.rs (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/config/src/config.rs
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 (2)
- src/config/src/config.rs (1 hunks)
- src/config/src/metrics.rs (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- src/config/src/config.rs
- src/config/src/metrics.rs
add Histogram span_duration_milliseconds for traces, and it has "service_name", "operation_name", "status_code", "span_kind" labels .
to enable metrics, set ZO_TRACES_SPAN_METRICS_ENABLED : true
and in case operation_name will be too many to query, we can add a vrl function to convert operation_name to a cusmtom name, such as:
Summary by CodeRabbit
New Features
Updates
Cargo.toml
to include OpenTelemetry metrics feature.metrics
module for broader use.Bug Fixes