CORE/FFI/GO - SpanFromContext implementation#4507
Merged
Conversation
88e262a to
226094f
Compare
226094f to
422919b
Compare
jonathanl-bq
reviewed
Aug 6, 2025
Contributor
jonathanl-bq
left a comment
There was a problem hiding this comment.
Can you add MIRI tests as well? We need coverage for the new functions you added to the FFI layer.
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
…I functions including: -Enhanced error handling tests for invalid inputs (null pointers, oversized names, invalid request types) -Comprehensive integration tests covering span creation, parent-child relationships, and memory safety -Batch span functionality tests with hierarchy validation -Concurrent access testing and boundary condition validation -Memory safety tests for span cleanup operations Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
- integration tests - Unit tests - Base client modifications to support the new parent/child span Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
- Simplify SpanFromContext function signature from (uint64, bool) to uint64 - Remove redundant 'found' boolean return value - Functions now return 0 to indicate no parent span available - Update DefaultSpanFromContext and all related implementations - Improve error handling and panic recovery logic - Add mock-logger-core package for miri tests - Create no-op implementations of log functions (error, warn, debug, info) - Add proper Cargo.toml configuration and dependency integration - Ensure miri tests can run without complex logging infrastructure - Enhance mock-telemetry for better miri test coverage - Implement Display trait for TraceError - Add concrete implementations for GlideOpenTelemetry methods - Replace todo!() placeholders with working mock implementations - Add span_from_pointer method for completeness - Update Go client span extraction logic - Simplify parent span detection from context - Remove unnecessary tuple unpacking in executeCommandWithRoute and executeBatch - Maintain backward compatibility while improving code clarity - Add comprehensive OpenTelemetry examples and documentation - Create opentelemetry_examples_test.go with runnable examples - Update examples.md to reference new OpenTelemetry examples - Move extensive documentation from inline comments to dedicated examples - Provide clear usage patterns for span context management This change improves the developer experience by simplifying the OpenTelemetry integration API while maintaining full functionality and backward compatibility. The miri test improvements ensure better test coverage in memory-safe environments. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
- Remove ExampleWithSpan and ExampleDefaultSpanFromContext functions - Rename ExampleOpenTelemetry_CreateSpan to ExampleOpenTelemetry - Focus example on demonstrating parent-child span relationships - Add clearer comments explaining span context usage with Valkey commands - Clean up formatting and remove redundant content Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
…t, Del, etc.) - Implement enhanced Cmd struct with command_bytes field and default implementation - Add comprehensive Miri tests for all OTEL span creation functions - Fix function signatures to properly mark unsafe extern "C" functions - Improve error handling and fallback behavior for invalid parent spans - Add extensive test coverage for span hierarchies and concurrent access - Clean up code formatting and organize imports consistently - Strengthen memory safety validation in FFI boundary functions Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
bdcdbfc to
a467e34
Compare
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
jonathanl-bq
approved these changes
Aug 6, 2025
Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
prateek-kumar-improving
approved these changes
Aug 8, 2025
Contributor
|
Changelog is updated for this PR in #4567 |
zarkash-aws
pushed a commit
to zarkash-aws/valkey-glide
that referenced
this pull request
Aug 10, 2025
* Core: Added span pointer conversion and validation Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * ffi: The changes add extensive test coverage for the OpenTelemetry FFI functions including: -Enhanced error handling tests for invalid inputs (null pointers, oversized names, invalid request types) -Comprehensive integration tests covering span creation, parent-child relationships, and memory safety -Batch span functionality tests with hierarchy validation -Concurrent access testing and boundary condition validation -Memory safety tests for span cleanup operations Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * go: New OpenTelemetry functionality - integration tests - Unit tests - Base client modifications to support the new parent/child span Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fixing ffi tests failing on github actions Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * Change glide-core function to be unsafe Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * Simplify OpenTelemetry span context API and improve miri test mocks - Simplify SpanFromContext function signature from (uint64, bool) to uint64 - Remove redundant 'found' boolean return value - Functions now return 0 to indicate no parent span available - Update DefaultSpanFromContext and all related implementations - Improve error handling and panic recovery logic - Add mock-logger-core package for miri tests - Create no-op implementations of log functions (error, warn, debug, info) - Add proper Cargo.toml configuration and dependency integration - Ensure miri tests can run without complex logging infrastructure - Enhance mock-telemetry for better miri test coverage - Implement Display trait for TraceError - Add concrete implementations for GlideOpenTelemetry methods - Replace todo!() placeholders with working mock implementations - Add span_from_pointer method for completeness - Update Go client span extraction logic - Simplify parent span detection from context - Remove unnecessary tuple unpacking in executeCommandWithRoute and executeBatch - Maintain backward compatibility while improving code clarity - Add comprehensive OpenTelemetry examples and documentation - Create opentelemetry_examples_test.go with runnable examples - Update examples.md to reference new OpenTelemetry examples - Move extensive documentation from inline comments to dedicated examples - Provide clear usage patterns for span context management This change improves the developer experience by simplifying the OpenTelemetry integration API while maintaining full functionality and backward compatibility. The miri test improvements ensure better test coverage in memory-safe environments. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fix lint Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * simplify OpenTelemetry examples and improve span relationship demo - Remove ExampleWithSpan and ExampleDefaultSpanFromContext functions - Rename ExampleOpenTelemetry_CreateSpan to ExampleOpenTelemetry - Focus example on demonstrating parent-child span relationships - Add clearer comments explaining span context usage with Valkey commands - Clean up formatting and remove redundant content Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fix linter Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * - Add proper RequestType enum with concrete command variants (Get, Set, Del, etc.) - Implement enhanced Cmd struct with command_bytes field and default implementation - Add comprehensive Miri tests for all OTEL span creation functions - Fix function signatures to properly mark unsafe extern "C" functions - Improve error handling and fallback behavior for invalid parent spans - Add extensive test coverage for span hierarchies and concurrent access - Clean up code formatting and organize imports consistently - Strengthen memory safety validation in FFI boundary functions Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * ffi lint fixes Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * removed (current behavior) from the comment Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> --------- Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com>
alexr-bq
pushed a commit
that referenced
this pull request
Aug 25, 2025
* Core: Added span pointer conversion and validation Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * ffi: The changes add extensive test coverage for the OpenTelemetry FFI functions including: -Enhanced error handling tests for invalid inputs (null pointers, oversized names, invalid request types) -Comprehensive integration tests covering span creation, parent-child relationships, and memory safety -Batch span functionality tests with hierarchy validation -Concurrent access testing and boundary condition validation -Memory safety tests for span cleanup operations Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * go: New OpenTelemetry functionality - integration tests - Unit tests - Base client modifications to support the new parent/child span Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fixing ffi tests failing on github actions Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * Change glide-core function to be unsafe Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * Simplify OpenTelemetry span context API and improve miri test mocks - Simplify SpanFromContext function signature from (uint64, bool) to uint64 - Remove redundant 'found' boolean return value - Functions now return 0 to indicate no parent span available - Update DefaultSpanFromContext and all related implementations - Improve error handling and panic recovery logic - Add mock-logger-core package for miri tests - Create no-op implementations of log functions (error, warn, debug, info) - Add proper Cargo.toml configuration and dependency integration - Ensure miri tests can run without complex logging infrastructure - Enhance mock-telemetry for better miri test coverage - Implement Display trait for TraceError - Add concrete implementations for GlideOpenTelemetry methods - Replace todo!() placeholders with working mock implementations - Add span_from_pointer method for completeness - Update Go client span extraction logic - Simplify parent span detection from context - Remove unnecessary tuple unpacking in executeCommandWithRoute and executeBatch - Maintain backward compatibility while improving code clarity - Add comprehensive OpenTelemetry examples and documentation - Create opentelemetry_examples_test.go with runnable examples - Update examples.md to reference new OpenTelemetry examples - Move extensive documentation from inline comments to dedicated examples - Provide clear usage patterns for span context management This change improves the developer experience by simplifying the OpenTelemetry integration API while maintaining full functionality and backward compatibility. The miri test improvements ensure better test coverage in memory-safe environments. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fix lint Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * simplify OpenTelemetry examples and improve span relationship demo - Remove ExampleWithSpan and ExampleDefaultSpanFromContext functions - Rename ExampleOpenTelemetry_CreateSpan to ExampleOpenTelemetry - Focus example on demonstrating parent-child span relationships - Add clearer comments explaining span context usage with Valkey commands - Clean up formatting and remove redundant content Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fix linter Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * - Add proper RequestType enum with concrete command variants (Get, Set, Del, etc.) - Implement enhanced Cmd struct with command_bytes field and default implementation - Add comprehensive Miri tests for all OTEL span creation functions - Fix function signatures to properly mark unsafe extern "C" functions - Improve error handling and fallback behavior for invalid parent spans - Add extensive test coverage for span hierarchies and concurrent access - Clean up code formatting and organize imports consistently - Strengthen memory safety validation in FFI boundary functions Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * ffi lint fixes Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * removed (current behavior) from the comment Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> --------- Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> Signed-off-by: Alex Rehnby-Martin <alex.rehnby-martin@improving.com>
2 tasks
alexr-bq
pushed a commit
that referenced
this pull request
Sep 3, 2025
* Core: Added span pointer conversion and validation Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * ffi: The changes add extensive test coverage for the OpenTelemetry FFI functions including: -Enhanced error handling tests for invalid inputs (null pointers, oversized names, invalid request types) -Comprehensive integration tests covering span creation, parent-child relationships, and memory safety -Batch span functionality tests with hierarchy validation -Concurrent access testing and boundary condition validation -Memory safety tests for span cleanup operations Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * go: New OpenTelemetry functionality - integration tests - Unit tests - Base client modifications to support the new parent/child span Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fixing ffi tests failing on github actions Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * Change glide-core function to be unsafe Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * Simplify OpenTelemetry span context API and improve miri test mocks - Simplify SpanFromContext function signature from (uint64, bool) to uint64 - Remove redundant 'found' boolean return value - Functions now return 0 to indicate no parent span available - Update DefaultSpanFromContext and all related implementations - Improve error handling and panic recovery logic - Add mock-logger-core package for miri tests - Create no-op implementations of log functions (error, warn, debug, info) - Add proper Cargo.toml configuration and dependency integration - Ensure miri tests can run without complex logging infrastructure - Enhance mock-telemetry for better miri test coverage - Implement Display trait for TraceError - Add concrete implementations for GlideOpenTelemetry methods - Replace todo!() placeholders with working mock implementations - Add span_from_pointer method for completeness - Update Go client span extraction logic - Simplify parent span detection from context - Remove unnecessary tuple unpacking in executeCommandWithRoute and executeBatch - Maintain backward compatibility while improving code clarity - Add comprehensive OpenTelemetry examples and documentation - Create opentelemetry_examples_test.go with runnable examples - Update examples.md to reference new OpenTelemetry examples - Move extensive documentation from inline comments to dedicated examples - Provide clear usage patterns for span context management This change improves the developer experience by simplifying the OpenTelemetry integration API while maintaining full functionality and backward compatibility. The miri test improvements ensure better test coverage in memory-safe environments. Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fix lint Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * simplify OpenTelemetry examples and improve span relationship demo - Remove ExampleWithSpan and ExampleDefaultSpanFromContext functions - Rename ExampleOpenTelemetry_CreateSpan to ExampleOpenTelemetry - Focus example on demonstrating parent-child span relationships - Add clearer comments explaining span context usage with Valkey commands - Clean up formatting and remove redundant content Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * fix linter Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * - Add proper RequestType enum with concrete command variants (Get, Set, Del, etc.) - Implement enhanced Cmd struct with command_bytes field and default implementation - Add comprehensive Miri tests for all OTEL span creation functions - Fix function signatures to properly mark unsafe extern "C" functions - Improve error handling and fallback behavior for invalid parent spans - Add extensive test coverage for span hierarchies and concurrent access - Clean up code formatting and organize imports consistently - Strengthen memory safety validation in FFI boundary functions Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * ffi lint fixes Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> * removed (current behavior) from the comment Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> --------- Signed-off-by: affonsov <67347924+affonsov@users.noreply.github.com> Signed-off-by: Alex Rehnby-Martin <alex.rehnby-martin@improving.com>
2 tasks
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenTelemetry Span Context Attachment Enhancement
Overview
This PR significantly enhances the OpenTelemetry integration by implementing comprehensive span context attachment functionality, enabling proper parent-child span relationships and improved tracing capabilities across the Glide client library.
Key Features Added
🔧 FFI Layer Enhancements
New FFI Functions:
create_named_otel_span()- Creates spans with custom names for user operationscreate_otel_span_with_parent()- Creates child spans with parent-child relationshipscreate_batch_otel_span_with_parent()- Creates batch spans with parent contextEnhanced Error Handling:
🎯 Go Client API Improvements
Public Span Management APIs:
CreateSpan(name string)- Create named spans for user operationsEndSpan(spanPtr uint64)- Properly clean up spansWithSpan(ctx, spanPtr)- Attach span context to Go contextsDefaultSpanFromContext(ctx)- Extract span pointers from contextsContext Integration:
context.Context🔗 Span Hierarchy Support
Backward Compatibility
Issue link
This Pull Request is linked to issue (URL): #4243
Checklist
Before submitting the PR make sure the following are checked: