Skip to content

feat(logging): logging in libdatadog #1018

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
merged 4 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
comment:
layout: "condensed_header, diff, flags, components"

component_management:
individual_components:
- component_id: crashtracker # this is an identifier that should not be changed
Expand Down Expand Up @@ -87,3 +87,7 @@ component_management:
name: datadog-trace-utils # this is a display name, and can be changed freely
paths:
- datadog-trace-utils
- component_id: datadog-log
name: datadog-log
paths:
- datadog-log
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ jobs:
env:
RUSTFLAGS: "${{ matrix.flags }}"
run: |
cargo run --bin release --features profiling,telemetry,data-pipeline,symbolizer,crashtracker,library-config --release -- --out $LIBDD_OUTPUT_FOLDER
cargo run --bin release --features profiling,telemetry,data-pipeline,symbolizer,crashtracker,library-config,log --release -- --out $LIBDD_OUTPUT_FOLDER

- name: 'Publish libdatadog'
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # 4.6.1
Expand Down
68 changes: 56 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ members = [
"ddsketch",
"tinybytes",
"dogstatsd-client",
"datadog-log",
"datadog-log-ffi"
]

# https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2
Expand Down
74 changes: 69 additions & 5 deletions LICENSE-3rdparty.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root_name: builder, build_common, tools, datadog-alloc, datadog-crashtracker, ddcommon, ddtelemetry, datadog-ddsketch, datadog-crashtracker-ffi, ddcommon-ffi, datadog-ipc, datadog-ipc-macros, tarpc, tarpc-plugins, tinybytes, spawn_worker, cc_utils, datadog-library-config, datadog-library-config-ffi, datadog-live-debugger, datadog-live-debugger-ffi, datadog-profiling, datadog-profiling-protobuf, datadog-profiling-ffi, data-pipeline-ffi, data-pipeline, datadog-trace-protobuf, datadog-trace-utils, datadog-trace-normalization, dogstatsd-client, ddtelemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, datadog-remote-config, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, datadog-trace-obfuscation, datadog-tracer-flare, sidecar_mockgen, test_spawn_from_lib
root_name: builder, build_common, tools, datadog-alloc, datadog-crashtracker, ddcommon, ddtelemetry, datadog-ddsketch, datadog-crashtracker-ffi, ddcommon-ffi, datadog-ipc, datadog-ipc-macros, tarpc, tarpc-plugins, tinybytes, spawn_worker, cc_utils, datadog-library-config, datadog-library-config-ffi, datadog-live-debugger, datadog-live-debugger-ffi, datadog-profiling, datadog-profiling-protobuf, datadog-profiling-ffi, data-pipeline-ffi, data-pipeline, datadog-trace-protobuf, datadog-trace-utils, datadog-trace-normalization, dogstatsd-client, datadog-log-ffi, datadog-log, ddtelemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, datadog-remote-config, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, datadog-trace-obfuscation, datadog-tracer-flare, sidecar_mockgen, test_spawn_from_lib
third_party_libraries:
- package_name: addr2line
package_version: 0.24.2
Expand Down Expand Up @@ -32012,7 +32012,39 @@ third_party_libraries:
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: tracing
package_version: 0.1.40
package_version: 0.1.41
repository: https://github.com/tokio-rs/tracing
license: MIT
licenses:
- license: MIT
text: |
Copyright (c) 2019 Tokio Contributors

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: tracing-appender
package_version: 0.2.3
repository: https://github.com/tokio-rs/tracing
license: MIT
licenses:
Expand Down Expand Up @@ -32044,7 +32076,7 @@ third_party_libraries:
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: tracing-attributes
package_version: 0.1.27
package_version: 0.1.28
repository: https://github.com/tokio-rs/tracing
license: MIT
licenses:
Expand Down Expand Up @@ -32076,7 +32108,7 @@ third_party_libraries:
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: tracing-core
package_version: 0.1.32
package_version: 0.1.33
repository: https://github.com/tokio-rs/tracing
license: MIT
licenses:
Expand Down Expand Up @@ -32139,8 +32171,40 @@ third_party_libraries:
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: tracing-serde
package_version: 0.2.0
repository: https://github.com/tokio-rs/tracing
license: MIT
licenses:
- license: MIT
text: |
Copyright (c) 2019 Tokio Contributors

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
- package_name: tracing-subscriber
package_version: 0.3.18
package_version: 0.3.19
repository: https://github.com/tokio-rs/tracing
license: MIT
licenses:
Expand Down
3 changes: 2 additions & 1 deletion build-profiling-ffi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ FEATURES=(
"datadog-profiling-ffi/ddtelemetry-ffi"
"datadog-profiling-ffi/demangler"
"datadog-library-config-ffi"
"datadog-log-ffi"
)
if [[ "$symbolizer" -eq 1 ]]; then
FEATURES+=("symbolizer")
Expand Down Expand Up @@ -236,7 +237,7 @@ echo "Generating $destdir/include/libdatadog headers..."
rm -r $destdir/include/datadog/
mkdir $destdir/include/datadog/

CBINDGEN_HEADERS="common.h profiling.h telemetry.h crashtracker.h data-pipeline.h library-config.h"
CBINDGEN_HEADERS="common.h profiling.h telemetry.h crashtracker.h data-pipeline.h library-config.h log.h"
# When optional features are added, don't forget to also include the headers here
case $ARG_FEATURES in
esac
Expand Down
1 change: 1 addition & 0 deletions builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ telemetry = []
data-pipeline = []
symbolizer = []
library-config = []
log = []

[lib]
bench = false
Expand Down
2 changes: 2 additions & 0 deletions builder/src/bin/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ pub fn main() {
f.push("symbolizer".to_string());
#[cfg(feature = "library-config")]
f.push("datadog-library-config-ffi".to_string());
#[cfg(feature = "log")]
f.push("datadog-log-ffi".to_string());
f
};

Expand Down
2 changes: 2 additions & 0 deletions builder/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ impl Profiling {
headers.push("blazesym.h");
#[cfg(feature = "library-config")]
headers.push("library-config.h");
#[cfg(feature = "log")]
headers.push("log.h");

let mut origin_path: PathBuf = [&self.source_include, "dummy.h"].iter().collect();
let mut target_path: PathBuf = [&self.target_include, "dummy.h"].iter().collect();
Expand Down
2 changes: 1 addition & 1 deletion data-pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ hyper = { version = "1.6", features = ["http1", "client"] }
hyper-util = { version = "0.1", features = ["client", "client-legacy"] }
http = "1.0"
http-body-util = "0.1"
log = "0.4"
tracing = { version = "0.1", default-features = false }
rmp-serde = "1.1.1"
serde = "1.0.209"
serde_json = "1.0.127"
Expand Down
4 changes: 2 additions & 2 deletions data-pipeline/src/agent_info/fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use ddcommon::hyper_migration;
use ddcommon::Endpoint;
use http_body_util::BodyExt;
use hyper::{self, body::Buf, header::HeaderName};
use log::{error, info};
use std::sync::Arc;
use std::time::Duration;
use tokio::time::sleep;
use tracing::{error, info};

#[allow(clippy::declare_interior_mutable_const)]
const DATADOG_AGENT_STATE: HeaderName = HeaderName::from_static("datadog-agent-state");
Expand Down Expand Up @@ -157,7 +157,7 @@ impl AgentInfoFetcher {
info!("Agent info is up-to-date")
}
Err(err) => {
error!("Error while fetching /info: {}", err);
error!(?err, "Error while fetching /info");
}
}
sleep(self.refresh_interval).await;
Expand Down
Loading
Loading