-
-
Notifications
You must be signed in to change notification settings - Fork 277
Telemetry Processor (3): Envelope builder #3414
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
base: feat/span-first
Are you sure you want to change the base?
Conversation
…rs and logging - Introduced `EnvelopeBuilder` interface and implementations for log and span items, facilitating structured telemetry data handling. - Updated `InMemoryTelemetryBuffer` to utilize envelope builders for encoding and sending telemetry items, improving data transmission efficiency. - Enhanced logging capabilities within `InMemoryTelemetryBuffer` to capture encoding errors and buffer flushing events. - Added comprehensive tests for `InMemoryTelemetryBuffer`, ensuring correct behavior for item addition, flushing, and error handling.
- Updated the TelemetryBuffer interface and its implementations to rename the `clear` method to `flush`, aligning with its functionality of sending buffered items. - Adjusted the InMemoryTelemetryBuffer and DefaultTelemetryProcessor classes to reflect this change, ensuring consistent terminology across the codebase. - Modified related tests to use the new `flush` method, maintaining test integrity and clarity.
…TelemetryBuffer - Added a new `TelemetryBufferPolicy` class to define flushing behavior with configurable parameters such as `flushTimeout`, `maxBufferSizeBytes`, and `maxItemCount`. - Updated `InMemoryTelemetryBuffer` to utilize `TelemetryBufferPolicy`, allowing for more flexible buffer management based on item count and size. - Enhanced the SentryClient initialization to include a maximum item count for telemetry buffering, improving data handling efficiency.
…itialization - Updated SentryClient to utilize the new TelemetryBufferPolicy for managing telemetry item count, enhancing buffer management. - This change improves the efficiency of telemetry data handling by allowing for configurable item limits during client setup.
- Updated the initialization of defaultMaxBufferSizeBytes in TelemetryBufferPolicy to use a more concise expression, improving code clarity and consistency.
- Removed the policy parameter from InMemoryTelemetryBuffer initialization in SentryClient, streamlining the constructor and improving code clarity. - This change prepares for future enhancements related to telemetry processing.
…onfig - Renamed the TelemetryBufferPolicy class to TelemetryBufferConfig for improved clarity and consistency in naming. - Updated references in InMemoryTelemetryBuffer and related tests to reflect the new class name, ensuring seamless integration and functionality.
…ufferConfig - Replaced references to TelemetryBufferPolicy with TelemetryBufferConfig in InMemoryTelemetryBuffer and its tests, ensuring consistent naming and improved clarity. - Adjusted the constructor and internal logic to utilize the new configuration class for buffer management parameters.
…nhance telemetry context handling - Added DefaultTelemetryProcessorIntegration to set up the telemetry processor after Hub initialization, improving trace context extraction. - Enhanced PropagationContext with methods for managing trace context headers, ensuring better integration with telemetry processing. - Updated SentryClient to include the new integration, streamlining telemetry management during client setup. - Refactored envelope builders to support structured telemetry data handling for spans and logs, improving data transmission efficiency.
* feat(telemetry): Enhance InMemoryTelemetryBuffer with envelope builders and logging - Introduced `EnvelopeBuilder` interface and implementations for log and span items, facilitating structured telemetry data handling. - Updated `InMemoryTelemetryBuffer` to utilize envelope builders for encoding and sending telemetry items, improving data transmission efficiency. - Enhanced logging capabilities within `InMemoryTelemetryBuffer` to capture encoding errors and buffer flushing events. - Added comprehensive tests for `InMemoryTelemetryBuffer`, ensuring correct behavior for item addition, flushing, and error handling. * refactor(telemetry): Rename clear method to flush for consistency - Updated the TelemetryBuffer interface and its implementations to rename the `clear` method to `flush`, aligning with its functionality of sending buffered items. - Adjusted the InMemoryTelemetryBuffer and DefaultTelemetryProcessor classes to reflect this change, ensuring consistent terminology across the codebase. - Modified related tests to use the new `flush` method, maintaining test integrity and clarity. * feat(telemetry): Introduce TelemetryBufferPolicy and enhance InMemoryTelemetryBuffer - Added a new `TelemetryBufferPolicy` class to define flushing behavior with configurable parameters such as `flushTimeout`, `maxBufferSizeBytes`, and `maxItemCount`. - Updated `InMemoryTelemetryBuffer` to utilize `TelemetryBufferPolicy`, allowing for more flexible buffer management based on item count and size. - Enhanced the SentryClient initialization to include a maximum item count for telemetry buffering, improving data handling efficiency. * feat(telemetry): Integrate TelemetryBufferPolicy into SentryClient initialization - Updated SentryClient to utilize the new TelemetryBufferPolicy for managing telemetry item count, enhancing buffer management. - This change improves the efficiency of telemetry data handling by allowing for configurable item limits during client setup. * fix(telemetry): Correct defaultMaxBufferSizeBytes initialization - Updated the initialization of defaultMaxBufferSizeBytes in TelemetryBufferPolicy to use a more concise expression, improving code clarity and consistency. * refactor(telemetry): Simplify InMemoryTelemetryBuffer initialization - Removed the policy parameter from InMemoryTelemetryBuffer initialization in SentryClient, streamlining the constructor and improving code clarity. - This change prepares for future enhancements related to telemetry processing. * refactor(telemetry): Rename TelemetryBufferPolicy to TelemetryBufferConfig - Renamed the TelemetryBufferPolicy class to TelemetryBufferConfig for improved clarity and consistency in naming. - Updated references in InMemoryTelemetryBuffer and related tests to reflect the new class name, ensuring seamless integration and functionality. * refactor(telemetry): Update InMemoryTelemetryBuffer to use TelemetryBufferConfig - Replaced references to TelemetryBufferPolicy with TelemetryBufferConfig in InMemoryTelemetryBuffer and its tests, ensuring consistent naming and improved clarity. - Adjusted the constructor and internal logic to utilize the new configuration class for buffer management parameters. * feat(telemetry): Reject items exceeding max buffer size in InMemoryTelemetryBuffer - Implemented a check in InMemoryTelemetryBuffer to drop items that exceed the maximum buffer size, preventing oversized items from being added. - Updated tests to verify that items exceeding the buffer size are correctly rejected and not sent to the transport.
…TelemetryBuffer - Added a new `TelemetryBufferPolicy` class to define flushing behavior with configurable parameters such as `flushTimeout`, `maxBufferSizeBytes`, and `maxItemCount`. - Updated `InMemoryTelemetryBuffer` to utilize `TelemetryBufferPolicy`, allowing for more flexible buffer management based on item count and size. - Enhanced the SentryClient initialization to include a maximum item count for telemetry buffering, improving data handling efficiency.
…onfig - Renamed the TelemetryBufferPolicy class to TelemetryBufferConfig for improved clarity and consistency in naming. - Updated references in InMemoryTelemetryBuffer and related tests to reflect the new class name, ensuring seamless integration and functionality.
…ufferConfig - Replaced references to TelemetryBufferPolicy with TelemetryBufferConfig in InMemoryTelemetryBuffer and its tests, ensuring consistent naming and improved clarity. - Adjusted the constructor and internal logic to utilize the new configuration class for buffer management parameters.
…y processor - Updated `getOrCreateTraceContextHeader` method in `PropagationContext` to accept parameters for public key, segment name, release, environment, and traces sample rate, enhancing flexibility in trace context creation. - Introduced `DefaultTelemetryProcessorIntegration` to manage telemetry processing setup, ensuring proper integration with the Hub and enabling structured telemetry data handling. - Refactored envelope builders to utilize the new trace context handling, improving data transmission efficiency for spans and logs. - Added comprehensive tests for the new functionality, ensuring correct behavior and integration within the telemetry processing framework.
…st suite - Deleted the group of tests related to the telemetryProcessor in the SentryClient test suite, as they are no longer necessary. - This change simplifies the test suite and focuses on relevant functionality.
- Introduced a single instance of SampleRateFormat in PropagationContext to improve efficiency and readability. - Removed unnecessary imports from SimpleSpan and telemetry_processor_integration.dart, streamlining the codebase. - This change enhances clarity and reduces redundancy in the telemetry processing components.
packages/dart/lib/src/telemetry_processing/telemetry_processor_integration.dart
Outdated
Show resolved
Hide resolved
- Added new `SentrySpanV2` interface and implementations including `RecordingSentrySpanV2`, `NoOpSentrySpanV2`, and `UnsetSentrySpanV2` to support advanced span management. - Updated existing classes to utilize the new span API, ensuring compatibility with the telemetry processing framework. - Refactored related methods in `Hub`, `Scope`, and telemetry components to integrate the new span functionality, improving overall telemetry data handling. - Removed deprecated span classes and cleaned up imports to streamline the codebase.
- Introduced `SentrySpanContextV2` to encapsulate span dependencies, improving separation from the Hub. - Updated `RecordingSentrySpanV2` to utilize the new context for managing span lifecycle and telemetry processing. - Refactored `Hub` to create spans with the new context, enhancing telemetry data handling and span management. - Cleaned up related imports and adjusted method signatures for better clarity and maintainability.
…related tests - Eliminated the `getOrCreateTraceContextHeader` method from `PropagationContext`, simplifying trace context management. - Updated `RecordingSentrySpanV2` to adjust trace ID assignment logic for better clarity. - Removed associated tests from `propagation_context_test.dart`, streamlining the test suite and focusing on relevant functionality.
…lemetry processing - Added `SentrySpanContextV2` to enhance span lifecycle management and telemetry data handling. - Updated `RecordingSentrySpanV2` to utilize the new context for improved span creation and management. - Refactored `Hub` and telemetry processing components to support the new context, ensuring better separation of concerns. - Enhanced tests to validate the integration of `SentrySpanContextV2` across various components.
- Replaced instances of NoOpSentrySpanV2 with SentrySpanV2.noop for consistency and clarity. - Refactored parent span resolution logic in Hub to utilize a switch statement for improved readability. - Updated NoOpHub to return SentrySpanV2.noop in span creation method, aligning with new span API structure.
- Updated the Hub class to consistently return NoOpSentrySpanV2 instead of SentrySpanV2.noop for clarity. - Refactored span creation logic in NoOpHub to align with the new span API structure. - Removed the SentrySpanContextV2 class as it is no longer needed, simplifying span management. - Enhanced the RecordingSentrySpanV2 constructor to improve clarity and maintainability. - Updated tests to reflect changes in span creation and context handling.
|
cursor review |
| transaction: span.segmentSpan.name, | ||
| sampleRate: formatRate(hub.options.tracesSampleRate), | ||
| sampleRand: hub.scope.propagationContext.sampleRand.toString(), | ||
| sampled: hub.scope.propagationContext.sampled.toString(), |
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.
Bug: Nullable values converted to string "null" instead of null
The sampleRand (double?) and sampled (bool?) values from PropagationContext are converted using .toString() without null-aware operators. When these values are null, calling .toString() produces the literal string "null" instead of actual null. This causes incorrect JSON serialization in toJson() where these fields would be included as "sampled": "null" rather than being omitted. The fix is to use ?.toString() for both values, consistent with how sampleRate is handled via formatRate() which properly returns null when the input is null.
📜 Description
Adds the envelope builder implementation to the buffer
#skip-changelog
💡 Motivation and Context
Part of #3333
💚 How did you test it?
Unit test
📝 Checklist
sendDefaultPiiis enabled🔮 Next steps