Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0e050b6
Import process context reference implementation
ivoanjo Jun 4, 2026
2db7a35
feat: [PROF-14789] Publish OTel process context
ivoanjo Jun 4, 2026
6813769
Make autoformatter happy
ivoanjo Jun 5, 2026
35bb013
Tweak to make CI happy
ivoanjo Jun 5, 2026
76267e5
Another try at making CI happy
ivoanjo Jun 5, 2026
71d7825
More small tweaks to make CI happy
ivoanjo Jun 5, 2026
bcda89d
More CI fixes
ivoanjo Jun 5, 2026
38359e2
More making CI happy
ivoanjo Jun 5, 2026
1690f10
Add links to where `otel_process_ctx.h/.cpp
ivoanjo Jun 8, 2026
4f6916d
Introduce new constant with library name, rather than hardcoding in r…
ivoanjo Jun 18, 2026
afddc6d
Minor: Remove redundant includes
ivoanjo Jun 18, 2026
8b9a8a3
Minor: Use references when building up metadata
ivoanjo Jun 18, 2026
c191436
Minor: Don't compare unordered maps as it can easily break
ivoanjo Jun 18, 2026
9d050df
Tweak behavior when report_hostname is disabled + add test
ivoanjo Jun 19, 2026
ab0b053
Add missing `static` declaration
ivoanjo Jun 19, 2026
2984054
Minor: Fix wording in comment to use infinitive
ivoanjo Jun 19, 2026
c561524
Introduce move-only RAII guard and mutex to ensure correctness
ivoanjo Jun 19, 2026
0575cde
Tighten tests for moving the tracer instance
ivoanjo Jun 19, 2026
e2ab668
Merge branch 'main' into ivoanjo/prof-14789-otel-process-ctx
ivoanjo Jun 22, 2026
b588e2f
Merge remote-tracking branch 'origin/main' into ivoanjo/prof-14789-ot…
ivoanjo Jul 21, 2026
b3ed966
Avoid using auto to improve readibility
ivoanjo Jul 21, 2026
58da92f
Use compound namespaces
ivoanjo Jul 21, 2026
e7b0121
Improve naming
ivoanjo Jul 21, 2026
363eb3e
More naming improvements
ivoanjo Jul 21, 2026
a3eaa6d
More naming improvements
ivoanjo Jul 21, 2026
2195685
Make test code stricter
ivoanjo Jul 21, 2026
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
4 changes: 4 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ cc_library(
"src/datadog/msgpack.cpp",
"src/datadog/msgpack.h",
"src/datadog/null_logger.h",
"src/datadog/otel_process_ctx.cpp",
"src/datadog/otel_process_ctx.h",
"src/datadog/otel_process_ctx_guard.cpp",
"src/datadog/otel_process_ctx_guard.h",
"src/datadog/parse_util.cpp",
"src/datadog/parse_util.h",
"src/datadog/platform_util.h",
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ target_sources(dd-trace-cpp-objects
src/datadog/limiter.cpp
src/datadog/logger.cpp
src/datadog/msgpack.cpp
src/datadog/otel_process_ctx.cpp
src/datadog/otel_process_ctx_guard.cpp
src/datadog/parse_util.cpp
src/datadog/propagation_style.cpp
src/datadog/random.cpp
Expand Down
13 changes: 13 additions & 0 deletions include/datadog/tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class TraceSampler;
class SpanSampler;
class IDGenerator;
class InMemoryFile;
class OtelCtxGuard;

class Tracer {
std::shared_ptr<Logger> logger_;
Expand All @@ -51,6 +52,8 @@ class Tracer {
// read to determine if the process is instrumented with a tracer and to
// retrieve relevant tracing information.
std::shared_ptr<InMemoryFile> metadata_file_;
// Owns the published OpenTelemetry process context, if any.
std::unique_ptr<OtelCtxGuard> otel_context_guard_;
Baggage::Options baggage_opts_;
bool baggage_injection_enabled_;
bool baggage_extraction_enabled_;
Expand All @@ -65,6 +68,16 @@ class Tracer {
Tracer(const FinalizedTracerConfig& config,
const std::shared_ptr<const IDGenerator>& generator);

~Tracer();
Comment thread
xlamorlette-datadog marked this conversation as resolved.

// Move-only. The otel context guarded by OtelCtxGuard is a process-wide
// singleton; duplicating ownership would lead to spurious drops, so copies
// are disallowed.
Tracer(Tracer&&) noexcept;
Tracer& operator=(Tracer&&) noexcept;
Tracer(const Tracer&) = delete;
Tracer& operator=(const Tracer&) = delete;

// Create a new trace and return the root span of the trace. Optionally
// specify a `config` indicating the attributes of the root span.
Span create_span();
Expand Down
3 changes: 3 additions & 0 deletions include/datadog/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace datadog::tracing {

// This library's name
extern const char *const tracer_library_name;

// The release version at or before this code revision, e.g. "v0.1.12".
// That is, this code is at least as recent as `tracer_version`, but may be
// more recent.
Expand Down
5 changes: 3 additions & 2 deletions src/datadog/error.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include <datadog/error.h>
#include <datadog/version.h>

#include <ostream>

namespace datadog {
namespace tracing {

std::ostream& operator<<(std::ostream& stream, const Error& error) {
return stream << "[dd-trace-cpp error code " << int(error.code) << "] "
<< error.message;
return stream << "[" << tracer_library_name << " error code "
<< int(error.code) << "] " << error.message;
}

Error Error::with_prefix(StringView prefix) const {
Expand Down
Loading
Loading