Skip to content

Commit

Permalink
Add env DD_TAGS support
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyi committed Jan 20, 2025
1 parent bdbf3c2 commit 2f22ac3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ Error Arguments::parse(const char* args) {
CASE("dd_version")
_dd_version = value;

CASE("dd_tags")
_dd_tags = value;

DEFAULT()
if (_unknown_arg == NULL) _unknown_arg = arg;
}
Expand Down
2 changes: 2 additions & 0 deletions src/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class Arguments {
const char *_dd_service;
const char *_dd_env;
const char *_dd_version;
const char *_dd_tags;

Arguments() :
_buf(NULL),
Expand Down Expand Up @@ -265,6 +266,7 @@ class Arguments {
_dd_service(""),
_dd_env(""),
_dd_version(""),
_dd_tags(""),
_httpcli(NULL),
_http_out(false) {
}
Expand Down
3 changes: 3 additions & 0 deletions src/flightRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ class Recording {
gethostname(hostname, sizeof(hostname));
ss << "process_id:" << getpid() << ",host:" << hostname << ",profiler_version:" << PROFILER_VERSION << ",service:" << _global_args._dd_service;
ss << ",env:" << _global_args._dd_env << ",version:" << _global_args._dd_version << ",language:jvm";
if (_global_args._dd_tags != NULL && _global_args._dd_tags[0] != 0) {
ss << "," << _global_args._dd_tags;
}
j["tags_profiler"] = ss.str();
time_t start_time = Profiler::instance()->start_time();
time_t stop_time = Profiler::instance()->stop_time();
Expand Down
5 changes: 5 additions & 0 deletions src/launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static const char USAGE_STRING[] =
"\n"
" --loop time run profiler in a loop\n"
" --ttl duration total duration the profiler will run, which is useful in the loop (continuous profiling) model\n"
" --http-out send the profiling output to a remote server via http, additional ENVs DD_AGENT_HOST/DD_TRACE_AGENT_PORT/DD_SERVICE/DD_ENV/DD_VERSION/DD_TAGS are supported\n"
" --alloc bytes allocation profiling interval in bytes\n"
" --live build allocation profile from live objects only\n"
" --lock duration lock profiling threshold in nanoseconds\n"
Expand Down Expand Up @@ -416,6 +417,10 @@ int main(int argc, const char** argv) {
if (dd_version != NULL && dd_version[0] != 0) {
params << ",dd_version=" << dd_version;
}
char *dd_tags = getenv("DD_TAGS");
if (dd_tags != NULL && dd_tags[0] != 0) {
params << ",dd_tags=" << dd_tags;
}

} else if (arg == "-o") {
output = args.next();
Expand Down
4 changes: 2 additions & 2 deletions src/zInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class LateInitializer {
_global_args._preloaded = true;

Log::open(_global_args);
Log::info("_http_out: %d, _dd_agent_host: %s, _dd_trace_agent_port: %d, _dd_service: %s, _dd_env: %s, _dd_version: %s",
_global_args._http_out, _global_args._dd_agent_host, _global_args._dd_trace_agent_port, _global_args._dd_service, _global_args._dd_env, _global_args._dd_version);
Log::info("_http_out: %d, _dd_agent_host: %s, _dd_trace_agent_port: %d, _dd_service: %s, _dd_env: %s, _dd_version: %s, _dd_tags: %s",
_global_args._http_out, _global_args._dd_agent_host, _global_args._dd_trace_agent_port, _global_args._dd_service, _global_args._dd_env, _global_args._dd_version, _global_args._dd_tags);

if (error || (error = Profiler::instance()->run(_global_args))) {
Log::error("%s", error.message());
Expand Down

0 comments on commit 2f22ac3

Please sign in to comment.