Skip to content

Commit 1d245aa

Browse files
refactor: do not keep internal_metadata_json
1 parent 24ad01a commit 1d245aa

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

ddtrace/internal/datadog/profiling/dd_wrapper/include/profiler_stats.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <cstddef>
44

55
#include <string>
6-
#include <string_view>
76

87
namespace Datadog {
98

@@ -17,8 +16,6 @@ a mutex to protect access to the data.
1716
class ProfilerStats
1817
{
1918
private:
20-
std::string internal_metadata_json;
21-
2219
// Number of samples collected (one per thread)
2320
size_t sample_count = 0;
2421

@@ -37,9 +34,7 @@ class ProfilerStats
3734

3835
// Returns a JSON string containing relevant Profiler Stats to be included
3936
// in the libdatadog payload.
40-
// The function returned a string_view to a statically allocated string that
41-
// is updated every time the function is called.
42-
std::string_view get_internal_metadata_json();
37+
std::string get_internal_metadata_json();
4338

4439
void reset_state();
4540
};

ddtrace/internal/datadog/profiling/dd_wrapper/src/profiler_stats.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "profiler_stats.hpp"
22

33
#include <charconv>
4-
#include <string>
54

65
namespace {
76

@@ -46,12 +45,13 @@ Datadog::ProfilerStats::reset_state()
4645
sampling_event_count = 0;
4746
}
4847

49-
std::string_view
48+
std::string
5049
Datadog::ProfilerStats::get_internal_metadata_json()
5150
{
51+
std::string internal_metadata_json;
5252
internal_metadata_json.reserve(128);
5353

54-
internal_metadata_json = "{";
54+
internal_metadata_json += "{";
5555

5656
internal_metadata_json += R"("sample_count": )";
5757
append_to_string(internal_metadata_json, sample_count);

0 commit comments

Comments
 (0)