Skip to content

Commit

Permalink
Incremental
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchda committed Apr 30, 2024
1 parent 5093943 commit 3b805e3
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern "C"
void ddup_config_runtime(std::string_view runtime);
void ddup_config_runtime_version(std::string_view runtime_version);
void ddup_config_profiler_version(std::string_view profiler_version);
void ddup_config_host(std::string_view host);
void ddup_config_url(std::string_view url);
void ddup_config_max_nframes(int max_nframes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Datadog {
#define EXPORTER_TAGS(X) \
X(language, "language") \
X(dd_env, "env") \
X(host, "host") \
X(service, "service") \
X(version, "version") \
X(runtime_version, "runtime_version") \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UploaderBuilder
static inline std::string runtime_version;
static inline std::string runtime_id;
static inline std::string profiler_version; // TODO: get this at build time
static inline std::string host{ "localhost" };
static inline std::string url{ "http://localhost:8126" };
static inline ExporterTagset user_tags{};

Expand All @@ -38,6 +39,7 @@ class UploaderBuilder
static void set_runtime_version(std::string_view _runtime_version);
static void set_runtime_id(std::string_view _runtime_id);
static void set_profiler_version(std::string_view _profiler_version);
static void set_host(std::string_view _host);
static void set_url(std::string_view _url);
static void set_tag(std::string_view _key, std::string_view _val);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ ddup_config_profiler_version(std::string_view profiler_version) // cppcheck-supp
Datadog::UploaderBuilder::set_profiler_version(profiler_version);
}

void
ddup_config_host(std::string_view host) // cppcheck-suppress unusedFunction
{
Datadog::UploaderBuilder::set_host(host);
}

void
ddup_config_url(std::string_view url) // cppcheck-suppress unusedFunction
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Datadog::UploaderBuilder::set_profiler_version(std::string_view _profiler_versio
profiler_version = _profiler_version;
}
}
void Datadog::UploaderBuilder::set_host(std::string_view _host)
{
if (!_host.empty()) {
host = _host;
}
}
void
Datadog::UploaderBuilder::set_url(std::string_view _url)
{
Expand Down Expand Up @@ -105,6 +111,7 @@ Datadog::UploaderBuilder::build()
std::vector<std::string> reasons{};
const std::vector<std::pair<ExportTagKey, std::string_view>> tag_data = {
{ ExportTagKey::dd_env, dd_env },
{ ExportTagKey::host, host },
{ ExportTagKey::service, service },
{ ExportTagKey::version, version },
{ ExportTagKey::language, language },
Expand Down
10 changes: 5 additions & 5 deletions ddtrace/internal/datadog/profiling/dd_wrapper/test/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void
single_sample_noframe()
{

configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 256);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", "ultranano", 256);

// Collect and flush one sample
auto h = ddup_start_sample();
Expand All @@ -33,7 +33,7 @@ TEST(UploadDeathTest, SingleSample)
void
single_oneframe_sample()
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 256);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 256);

// Collect and flush one sample with one frame
auto h = ddup_start_sample();
Expand All @@ -57,7 +57,7 @@ TEST(UploadDeathTest, SingleSampleOneFrame)
void
single_manyframes_sample()
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 512);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 512);

// Collect and flush one sample with one frame
auto h = ddup_start_sample();
Expand Down Expand Up @@ -89,7 +89,7 @@ TEST(UploadDeathTest, SingleSampleManyFrames)
void
single_toomanyframes_sample()
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 512);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 512);

// Collect and flush one sample with one frame
auto h = ddup_start_sample();
Expand Down Expand Up @@ -121,7 +121,7 @@ TEST(UploadDeathTest, SingleSampleTooManyFrames)
void
lotsa_frames_lotsa_samples()
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 512);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 512);

// 60 seconds @ 100 hertz
for (int i = 0; i < 60 * 100; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ is_exit_normal(int status)
void
sample_in_threads_and_fork(unsigned int num_threads, unsigned int sleep_time_ns)
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 256);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 256);
std::atomic<bool> done(false);
std::vector<std::thread> threads;
std::vector<unsigned int> ids;
Expand Down Expand Up @@ -75,7 +75,7 @@ sample_in_threads_and_fork(unsigned int num_threads, unsigned int sleep_time_ns)
void
fork_stress_test(unsigned int num_threads, unsigned int sleep_time_ns, unsigned int num_children)
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 256);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 256);
std::atomic<bool> done(false);
std::vector<std::thread> threads;
std::vector<unsigned int> ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
void
simple_init()
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 256);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 256);
std::exit(0);
}

Expand All @@ -21,7 +21,7 @@ TEST(InitDeathTest, TestInit)
void
empty_init()
{
configure("", "", "", "", "", "", "", 0);
configure("", "", "", "", "", "", "", "", 0);
std::exit(0);
}

Expand Down Expand Up @@ -55,6 +55,7 @@ short_lifetime_init()
std::string runtime("cpython");
std::string runtime_version("3.10.6");
std::string profiler_version("3.100");
std::string host("my_really_cool_host");

ddup_config_service(service.c_str());
ddup_config_env(env.c_str());
Expand All @@ -63,6 +64,7 @@ short_lifetime_init()
ddup_config_runtime(runtime.c_str());
ddup_config_runtime_version(runtime_version.c_str());
ddup_config_profiler_version(profiler_version.c_str());
ddup_config_host(host.c_str());
}

ddup_init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ configure(const char* service,
const char* runtime,
const char* runtime_version,
const char* profiler_version,
const char* host,
int max_nframes)
{
ddup_config_service(service);
Expand All @@ -25,6 +26,7 @@ configure(const char* service,
ddup_config_runtime(runtime);
ddup_config_runtime_version(runtime_version);
ddup_config_profiler_version(profiler_version);
ddup_config_host(host);
ddup_config_max_nframes(max_nframes);
ddup_init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ generic_launch_sleep_upload(int n, unsigned int sleep_time_ns)
void
emulate_profiler(unsigned int num_threads, unsigned int sample_ns)
{
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", 256);
configure("my_test_service", "my_test_env", "0.0.1", "https://localhost:8126", "cpython", "3.10.6", "3.100", "ultranano", 256);
generic_launch_sleep_upload(num_threads, sample_ns);

// Assumed to execute within a thread
Expand Down

0 comments on commit 3b805e3

Please sign in to comment.