feat: [Geneva Exporter] Add error message parameters to FFI functions for better diagnostics #474
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.
Summary
Adds optional error message parameters to all FFI functions to provide rich diagnostic
information for debugging and troubleshooting. Error codes alone are insufficient for
diagnosing issues in production - callers need actual error details (e.g., "Invalid UTF-8
in field 'endpoint'" vs just
GENEVA_INVALID_CONFIG
).Changes
Rust (
src/lib.rs
)InvalidHandle
error code (104) for magic number mismatchwrite_error_if_provided()
helper for zero-cost error reportingvalidate_handle()
to returnInvalidHandle
instead ofInvalidData
(err_msg_out, err_msg_len)
parameters to:geneva_client_new()
geneva_encode_and_compress_logs()
geneva_encode_and_compress_spans()
geneva_upload_batch_sync()
Err(_e)
toErr(e)
to capture actual error context{:?}
) to Display for stabilityC Headers
geneva_errors.h
withGENEVA_ERR_INVALID_HANDLE
geneva_ffi.h
function signatures with error message parametersExamples
logs_example.c
andspans_example.c
to demonstrate error handlingUsage
Without error details (zero-cost):
With detailed diagnostics:
Buffer Handling
Error messages are always safe and NUL-terminated when buffer provided. Recommended
buffer size: ≥256 bytes for full diagnostics. Thread-safe: no shared state, caller
controls buffer lifetime.
Performance
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial, user-facing changes