feat(common): add current thread id API#1569
feat(common): add current thread id API#1569gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit intomainfrom
Conversation
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
3085ed2 to
4ec810b
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1569 +/- ##
==========================================
- Coverage 70.83% 70.82% -0.02%
==========================================
Files 423 424 +1
Lines 61862 61865 +3
==========================================
- Hits 43823 43818 -5
- Misses 18039 18047 +8
🚀 New features to boost your workflow:
|
BenchmarksComparisonBenchmark execution time: 2026-02-17 18:54:43 Comparing candidate commit 69f24d8 in PR branch Found 0 performance improvements and 3 performance regressions! Performance is the same for 54 metrics, 2 unstable metrics. scenario:profile_add_sample2_frames_x1000
scenario:profile_add_sample_frames_x1000
scenario:tags/replace_trace_tags
CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
Group 14
Group 15
Group 16
Group 17
Group 18
Group 19
BaselineOmitted due to size. |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
gyuheon0h
left a comment
There was a problem hiding this comment.
Neat helper! Any chance this could go in common? I think we have some usecases of getting TID for crashtracker also. Not sure what is the protocol for sharing code between crates but it would be nice to have a shared helper for the smae functionality.
Ah, I see that this is i64 profiling specific :) |
Yes but it's mostly a 64-bit number. If other people are interested in this, I suppose that's fine, as long as we can keep our But first I need feedback from Windows folks to make sure the Win stuff is good. |
4ec810b to
89bfdbc
Compare
|
@gyuheon0h I got a review from .NET folks in Slack, and I've moved it to common. |
Add libdd_common::threading::get_current_thread_id() and update the profiling add_samples benchmark to use the shared helper. Co-authored-by: Cursor <[email protected]>
89bfdbc to
69f24d8
Compare
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
# Release proposal for libdd-data-pipeline and its dependencies This PR contains version bumps based on public API changes and commits since last release. ## libdd-common **Next version:** `2.0.0` **Semver bump:** `major` **Tag:** `libdd-common-v2.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - feat!: enable non-blocking DNS for reqwest (#1558) - feat: unify Azure tags (#1553) - feat(common): add current thread id API (#1569) - refactor!: switch from multipart to multer to resolve deprecation warnings and dependabot alerts (#1540) - feat: single source of truth for headers (fixes issue in profiling with missing headers) (#1493) - refactor!: make reqwest available in common (#1504) ## libdd-ddsketch **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-ddsketch-v1.0.1` ### Commits - chore: remove manual changelog modifications (#1472) - build: update `prost` crates (#1426) - chore: add changelog for every published crate (#1396) ## libdd-trace-protobuf **Next version:** `1.1.0` **Semver bump:** `minor` **Tag:** `libdd-trace-protobuf-v1.1.0` ### Commits - chore: remove manual changelog modifications (#1472) - build: update `prost` crates (#1426) - chore: add changelog for every published crate (#1396) - Handle null span tag values (#1394) ## libdd-dogstatsd-client **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-dogstatsd-client-v1.0.1` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - chore: release libddcommon-v1.1.0 (#1456) - chore: add changelog for every published crate (#1396) - style: fix recent clippy warnings (#1346) ## libdd-telemetry **Next version:** `3.0.0` **Semver bump:** `major` **Tag:** `libdd-telemetry-v3.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - chore(deps): bump tracing-subscriber to remove regex dep duplicate (#1608) - feat(telemetry)!: add process_tags to Application in telemetry (#1459) - fix(telemetry)!: fix logs payload format [APMSP-2590] (#1498) - feat(appsec): add endpoints collection (#1182) ## libdd-trace-normalization **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-trace-normalization-v1.0.1` ### Commits - Prevent span start overflow panic (#1373) - [CHAOSPLT-932] Add support for internal fuzzing infra (#1372) - chore: add changelog for every published crate (#1396) ## libdd-trace-utils **Next version:** `2.0.0` **Semver bump:** `major` **Tag:** `libdd-trace-utils-v2.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - feat: unify Azure tags (#1553) - fix(serverless): set hostname on stats from tracer to empty string (#1530) - chore: remove manual changelog modifications (#1472) - feat(sidecar)!: introduce TraceData to unify text and binary data (#1247) - chore: release libddcommon-v1.1.0 (#1456) - fix(test-agent): undo commenting arg in docker cmd (#1439) - [SLES-2652] Log error details when trace request fails (2) (#1441) - build: update `prost` crates (#1426) - chore(trace-utils): bump the test agent version used for integration tests (#1417) - [Serverless] Skip AAS metadata tagging when span is from API Management (#1409) - chore: add changelog for every published crate (#1396) - Handle null span tag values (#1394) - [SVLS-7934] Log error details when trace request fails (#1392) - Fix trace utils clippy warning (#1397) - feat(trace_utils): Allow sending trace stats using custom HTTP client (#1345) ## libdd-trace-stats **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-trace-stats-v1.0.1` ### Commits - feat(sidecar)!: introduce TraceData to unify text and binary data (#1247) - chore: add changelog for every published crate (#1396) ## libdd-data-pipeline **Next version:** `2.0.0` **Semver bump:** `major` **Tag:** `libdd-data-pipeline-v2.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - refactor(trace_exporter)!: remove Proxy TraceExporter input mode (#1583) - refactor(libdd-data-pipeline): health metrics (#1433) - feat(data-pipeline)!: include reason for chunks dropped telemetry (#1449) - feat(sidecar)!: introduce TraceData to unify text and binary data (#1247) - chore: release libddcommon-v1.1.0 (#1456) - chore: prepare libdd-telemetry-v2.0.0 (#1457) - Allow submitting Vec<Vec<Span>> asynchronously (#1302) - test(data-pipeline): handle EINTR in test_health_metrics_disabled (#1430) - chore: add changelog for every published crate (#1396) [APMSP-2590]: https://datadoghq.atlassian.net/browse/APMSP-2590?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: dd-octo-sts[bot] <200755185+dd-octo-sts[bot]@users.noreply.github.com>
# Release proposal for libdd-data-pipeline and its dependencies This PR contains version bumps based on public API changes and commits since last release. ## libdd-common **Next version:** `2.0.0` **Semver bump:** `major` **Tag:** `libdd-common-v2.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - feat!: enable non-blocking DNS for reqwest (#1558) - feat: unify Azure tags (#1553) - feat(common): add current thread id API (#1569) - refactor!: switch from multipart to multer to resolve deprecation warnings and dependabot alerts (#1540) - feat: single source of truth for headers (fixes issue in profiling with missing headers) (#1493) - refactor!: make reqwest available in common (#1504) ## libdd-ddsketch **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-ddsketch-v1.0.1` ### Commits - chore: remove manual changelog modifications (#1472) - build: update `prost` crates (#1426) - chore: add changelog for every published crate (#1396) ## libdd-trace-protobuf **Next version:** `1.1.0` **Semver bump:** `minor` **Tag:** `libdd-trace-protobuf-v1.1.0` ### Commits - chore: remove manual changelog modifications (#1472) - build: update `prost` crates (#1426) - chore: add changelog for every published crate (#1396) - Handle null span tag values (#1394) ## libdd-dogstatsd-client **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-dogstatsd-client-v1.0.1` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - chore: release libddcommon-v1.1.0 (#1456) - chore: add changelog for every published crate (#1396) - style: fix recent clippy warnings (#1346) ## libdd-telemetry **Next version:** `3.0.0` **Semver bump:** `major` **Tag:** `libdd-telemetry-v3.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - chore(deps): bump tracing-subscriber to remove regex dep duplicate (#1608) - feat(telemetry)!: add process_tags to Application in telemetry (#1459) - fix(telemetry)!: fix logs payload format [APMSP-2590] (#1498) - feat(appsec): add endpoints collection (#1182) ## libdd-trace-normalization **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-trace-normalization-v1.0.1` ### Commits - Prevent span start overflow panic (#1373) - [CHAOSPLT-932] Add support for internal fuzzing infra (#1372) - chore: add changelog for every published crate (#1396) ## libdd-trace-utils **Next version:** `2.0.0` **Semver bump:** `major` **Tag:** `libdd-trace-utils-v2.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - feat: unify Azure tags (#1553) - fix(serverless): set hostname on stats from tracer to empty string (#1530) - chore: remove manual changelog modifications (#1472) - feat(sidecar)!: introduce TraceData to unify text and binary data (#1247) - chore: release libddcommon-v1.1.0 (#1456) - fix(test-agent): undo commenting arg in docker cmd (#1439) - [SLES-2652] Log error details when trace request fails (2) (#1441) - build: update `prost` crates (#1426) - chore(trace-utils): bump the test agent version used for integration tests (#1417) - [Serverless] Skip AAS metadata tagging when span is from API Management (#1409) - chore: add changelog for every published crate (#1396) - Handle null span tag values (#1394) - [SVLS-7934] Log error details when trace request fails (#1392) - Fix trace utils clippy warning (#1397) - feat(trace_utils): Allow sending trace stats using custom HTTP client (#1345) ## libdd-trace-stats **Next version:** `1.0.1` **Semver bump:** `patch` **Tag:** `libdd-trace-stats-v1.0.1` ### Commits - feat(sidecar)!: introduce TraceData to unify text and binary data (#1247) - chore: add changelog for every published crate (#1396) ## libdd-data-pipeline **Next version:** `2.0.0` **Semver bump:** `major` **Tag:** `libdd-data-pipeline-v2.0.0` ### Commits - refactor(ddcommon)!: remove direct dependency on hyper client everywhere in common (#1604) - refactor(trace_exporter)!: remove Proxy TraceExporter input mode (#1583) - refactor(libdd-data-pipeline): health metrics (#1433) - feat(data-pipeline)!: include reason for chunks dropped telemetry (#1449) - feat(sidecar)!: introduce TraceData to unify text and binary data (#1247) - chore: release libddcommon-v1.1.0 (#1456) - chore: prepare libdd-telemetry-v2.0.0 (#1457) - Allow submitting Vec<Vec<Span>> asynchronously (#1302) - test(data-pipeline): handle EINTR in test_health_metrics_disabled (#1430) - chore: add changelog for every published crate (#1396) [APMSP-2590]: https://datadoghq.atlassian.net/browse/APMSP-2590?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --------- Co-authored-by: dd-octo-sts[bot] <200755185+dd-octo-sts[bot]@users.noreply.github.com>
What does this PR do?
Adds a new public helper API,
libdd_common::threading::get_current_thread_id() -> i64,with platform-specific implementations for Linux, macOS, and Windows.
It updates
libdd-profiling'sadd_samplesbenchmark to always include a numeric"thread id"label in both
try_add_sampleandtry_add_sample2paths.Motivation
This PR improves the
add_samplesbenchmark because in the future I want to modify theinternals of our implementation, and I want labels to be represented in the benchmark.
@gyuheon0h asked for it to be in common so it could be used in other places as well. This is fine with me, as long as we keep the i64 representation for profiling.
Additional Notes
Supported implementations:
syscall(SYS_gettid), sincegettid()does not exist on older glibc versions.pthread_threadid_npGetCurrentThreadIdviawindows-sysUnsupported platforms fail at compile time via
compile_error!.How to test the change?
pr1/add-samples-benchmark.cargo check -p libdd-commoncargo check -p libdd-profilingcargo check -p libdd-profiling --benchescargo bench -p libdd-profiling --bench main -- add_sample --noplotadd_samplesincludes"thread id"labels for both legacy and api2 benchmark loops