-
Notifications
You must be signed in to change notification settings - Fork 19
refactor(libdd-crashtracker)!: avoid leaking Endpoint through the public API #1705
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
Merged
gh-worker-dd-mergequeue-cf854d
merged 8 commits into
main
from
julio/remove-common-as-external-dependency
Mar 13, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f73e8c9
fix(libdd-crashtracker): avoid leaking Endpoint through the public API
hoolioh 913c7d9
chore(datadog-sidecar): use crastracker configuration builder
hoolioh ff68810
fix: don't build option if url is empty so Endpoint is not instantiated.
hoolioh b74e52a
chore(bin-tests): use builder
hoolioh 312a29c
fix(libdd-crashtracker): use builder on benches
hoolioh f510db7
fix: pass charslice to crashtracker configuration on ffi layer
hoolioh a15aa94
chore(libdd-crashtracker): add builder unit tests
hoolioh f1e7d11
chore: solve PR comments
hoolioh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ mod unix { | |
| use std::process; | ||
| use std::time::Duration; | ||
|
|
||
| use libdd_common::{tag, Endpoint}; | ||
| use libdd_common::tag; | ||
| use libdd_crashtracker::{ | ||
| self as crashtracker, CrashtrackerConfiguration, CrashtrackerReceiverConfig, Metadata, | ||
| StackFrame, StackTrace, | ||
|
|
@@ -73,12 +73,6 @@ mod unix { | |
| let stdout_filename = format!("{output_dir}/out.stdout"); | ||
| let output_dir: &Path = output_dir.as_ref(); | ||
|
|
||
| let endpoint = if output_url.is_empty() { | ||
| None | ||
| } else { | ||
| Some(Endpoint::from_slice(output_url)) | ||
| }; | ||
|
|
||
| // The configuration can be modified by a Behavior (testing plan), so it is mut here. | ||
| // Unlike a normal harness, in this harness tests are run in individual processes, so race | ||
| // issues are avoided. | ||
|
|
@@ -97,17 +91,16 @@ mod unix { | |
| Err(_) => crashtracker::StacktraceCollection::WithoutSymbols, | ||
| }; | ||
|
|
||
| let mut config = CrashtrackerConfiguration::new( | ||
| vec![], | ||
| true, | ||
| true, | ||
| endpoint, | ||
| stacktrace_collection, | ||
| crashtracker::default_signals(), | ||
| Some(TEST_COLLECTOR_TIMEOUT), | ||
| Some("".to_string()), | ||
| true, | ||
| )?; | ||
| let mut config = CrashtrackerConfiguration::builder() | ||
| .create_alt_stack(true) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ❤️ how there are in alphabetical order |
||
| .demangle_names(true) | ||
| .endpoint_url(output_url) | ||
| .resolve_frames(stacktrace_collection) | ||
| .signals(crashtracker::default_signals()) | ||
| .timeout(TEST_COLLECTOR_TIMEOUT) | ||
| .unix_socket_path("".to_string()) | ||
| .use_alt_stack(true) | ||
| .build()?; | ||
|
|
||
| let metadata = Metadata { | ||
| library_name: "libdatadog".to_owned(), | ||
|
|
||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| // Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| use libdd_common::Endpoint; | ||
| use libdd_common_ffi::slice::{AsBytes, CharSlice}; | ||
| use libdd_common_ffi::{Error, Slice}; | ||
| pub use libdd_crashtracker::{OpTypes, StacktraceCollection}; | ||
|
|
@@ -61,7 +60,7 @@ pub struct Config<'a> { | |
| pub demangle_names: bool, | ||
| /// The endpoint to send the crash report to (can be a file://). | ||
| /// If None, the crashtracker will infer the agent host from env variables. | ||
| pub endpoint: Option<&'a Endpoint>, | ||
| pub endpoint: CharSlice<'a>, | ||
| /// Optional filename for a unix domain socket if the receiver is used asynchonously | ||
| pub optional_unix_socket_filename: CharSlice<'a>, | ||
| pub resolve_frames: StacktraceCollection, | ||
|
|
@@ -88,29 +87,23 @@ impl<'a> TryFrom<Config<'a>> for libdd_crashtracker::CrashtrackerConfiguration { | |
| } | ||
| vec | ||
| }; | ||
| let create_alt_stack = value.create_alt_stack; | ||
| let use_alt_stack = value.use_alt_stack; | ||
| let endpoint = value.endpoint.cloned(); | ||
| let resolve_frames = value.resolve_frames; | ||
| let signals = value.signals.iter().copied().collect(); | ||
| let timeout = if value.timeout_ms == 0 { | ||
| None | ||
| } else { | ||
| Some(Duration::from_millis(value.timeout_ms as u64)) | ||
| }; | ||
| let unix_socket_path = value.optional_unix_socket_filename.try_to_string_option()?; | ||
| let demangle_names = value.demangle_names; | ||
| Self::new( | ||
| additional_files, | ||
| create_alt_stack, | ||
| use_alt_stack, | ||
| endpoint, | ||
| resolve_frames, | ||
| signals, | ||
| timeout, | ||
| unix_socket_path, | ||
| demangle_names, | ||
| ) | ||
| let mut builder = Self::builder() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in other places we sort these |
||
| .additional_files(additional_files) | ||
| .create_alt_stack(value.create_alt_stack) | ||
| .demangle_names(value.demangle_names) | ||
| .resolve_frames(value.resolve_frames) | ||
| .signals(value.signals.iter().copied().collect()) | ||
| .use_alt_stack(value.use_alt_stack); | ||
| if let Some(url) = value.endpoint.try_to_string_option()? { | ||
| builder = builder.endpoint_url(&url); | ||
| } | ||
| if value.timeout_ms != 0 { | ||
| builder = builder.timeout(Duration::from_millis(value.timeout_ms as u64)); | ||
| } | ||
| if let Some(path) = value.optional_unix_socket_filename.try_to_string_option()? { | ||
| builder = builder.unix_socket_path(path); | ||
| } | ||
| builder.build() | ||
| } | ||
| } | ||
|
|
||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
This is surprising