Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove sending a metric as part of auto-instrumentation #3482

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 4 additions & 7 deletions instrumentation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ obj/logger.o: obj src/logger.c src/logger.h
obj/config.o: obj src/config.c src/config.h
gcc -c -Wall -Werror -fpic -o obj/config.o src/config.c

obj/metrics_client.o: obj src/metrics_client.c src/metrics_client.h
gcc -c -Wall -Werror -fpic -o obj/metrics_client.o src/metrics_client.c

obj/splunk.o: obj src/splunk.c src/splunk.h
gcc -c -Wall -Werror -fpic -o obj/splunk.o src/splunk.c

Expand All @@ -36,12 +33,12 @@ obj/args.o: obj src/args.c src/args.h
obj/cmdline_reader.o: obj src/cmdline_reader.c src/cmdline_reader.h
gcc -c -Wall -Werror -fpic -o obj/cmdline_reader.o src/cmdline_reader.c

so/libsplunk.so: obj so obj/logger.o obj/config.o obj/metrics_client.o obj/cmdline_reader.o obj/args.o obj/splunk.o
gcc -shared -o so/libsplunk.so obj/logger.o obj/config.o obj/metrics_client.o obj/cmdline_reader.o obj/args.o obj/splunk.o
so/libsplunk.so: obj so obj/logger.o obj/config.o obj/cmdline_reader.o obj/args.o obj/splunk.o
gcc -shared -o so/libsplunk.so obj/logger.o obj/config.o obj/cmdline_reader.o obj/args.o obj/splunk.o

tests: src/test_main.h src/test_main.c src/test_utils.h src/test_utils.c src/logger.h src/test_logger.c \
src/metrics_client.h src/cmdline_reader.h src/cmdline_reader_test.c obj/config.o obj/metrics_client.o obj/args.o obj/splunk.o
gcc -g -o tests src/test_main.c src/test_utils.c src/test_logger.c src/cmdline_reader_test.c obj/config.o obj/metrics_client.o obj/args.o obj/splunk.o
src/cmdline_reader.h src/cmdline_reader_test.c obj/config.o obj/args.o obj/splunk.o
gcc -g -o tests src/test_main.c src/test_utils.c src/test_logger.c src/cmdline_reader_test.c obj/config.o obj/args.o obj/splunk.o

.PHONY: test
test: tests
Expand Down
5 changes: 0 additions & 5 deletions instrumentation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ variable will then be picked up by the Java instrumentation jar. Typically, it w

to set the deployment environment for the Splunk backend.

#### `disable_telemetry` (optional)

Set this value to `true` to disable the preloader from sending the `splunk.linux-autoinstr.executions` metric to the
local collector. Default: `false`.

#### `generate_service_name` (optional)

Set this value to `false` to prevent the preloader from setting the `OTEL_SERVICE_NAME` environment variable. If this
Expand Down
1 change: 0 additions & 1 deletion instrumentation/install/instrumentation.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ java_agent_jar=/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar
#service_name=hardcoded.service

# note: any of the the following lines may be uncommented to override defaults
#disable_telemetry=true
#generate_service_name=false
#enable_profiler=true
#enable_profiler_memory=true
Expand Down
6 changes: 0 additions & 6 deletions instrumentation/src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ void load_config(logger log, struct config *cfg, char *file_name) {
log_config_field(log, "service_name", cfg->service_name);
log_config_field(log, "java_agent_jar", cfg->java_agent_jar);
log_config_field(log, "resource_attributes", cfg->resource_attributes);
log_config_field(log, "disable_telemetry", cfg->disable_telemetry);
log_config_field(log, "generate_service_name", cfg->generate_service_name);
log_config_field(log, "enable_profiler", cfg->enable_profiler);
log_config_field(log, "enable_profiler_memory", cfg->enable_profiler_memory);
Expand Down Expand Up @@ -69,8 +68,6 @@ void read_lines(struct config *cfg, FILE *fp) {
cfg->service_name = strdup(pair.v);
} else if (streq(pair.k, "resource_attributes")) {
cfg->resource_attributes = strdup(pair.v);
} else if (streq(pair.k, "disable_telemetry")) {
cfg->disable_telemetry = strdup(pair.v);
} else if (streq(pair.k, "generate_service_name")) {
cfg->generate_service_name = strdup(pair.v);
} else if (streq(pair.k, "enable_profiler")) {
Expand Down Expand Up @@ -108,9 +105,6 @@ void free_config(struct config *cfg) {
if (cfg->resource_attributes != NULL) {
free(cfg->resource_attributes);
}
if (cfg->disable_telemetry != NULL) {
free(cfg->disable_telemetry);
}
if (cfg->generate_service_name != NULL) {
free(cfg->generate_service_name);
}
Expand Down
1 change: 0 additions & 1 deletion instrumentation/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ struct config {
char *java_agent_jar;
char *service_name;
char *resource_attributes;
char *disable_telemetry;
char *generate_service_name;
char *enable_profiler;
char *enable_profiler_memory;
Expand Down
133 changes: 0 additions & 133 deletions instrumentation/src/metrics_client.c

This file was deleted.

10 changes: 0 additions & 10 deletions instrumentation/src/metrics_client.h

This file was deleted.

13 changes: 2 additions & 11 deletions instrumentation/src/splunk.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "splunk.h"
#include "config.h"
#include "metrics_client.h"
#include "args.h"

#include <stdlib.h>
Expand Down Expand Up @@ -49,7 +48,7 @@ void __attribute__((constructor)) splunk_instrumentation_enter() {
if (cr == NULL) {
return;
}
auto_instrument(l, has_read_access, program_invocation_short_name, load_config, cr, send_otlp_metric);
auto_instrument(l, has_read_access, program_invocation_short_name, load_config, cr);
cmdline_reader_close(cr);
free_logger(l);
}
Expand All @@ -59,8 +58,7 @@ void auto_instrument(
has_access_func_t has_access,
const char *program_name,
load_config_func_t load_config_func,
cmdline_reader cr,
send_otlp_metric_func_t send_otlp_metric_func
cmdline_reader cr
) {
if (!streq(program_name, "java")) {
return;
Expand All @@ -78,7 +76,6 @@ void auto_instrument(
.java_agent_jar = NULL,
.resource_attributes = NULL,
.service_name = NULL,
.disable_telemetry = NULL,
.generate_service_name = NULL,
.enable_profiler = NULL,
.enable_profiler_memory = NULL,
Expand Down Expand Up @@ -111,12 +108,6 @@ void auto_instrument(

set_env_var_from_attr(log, "resource_attributes", resource_attributes_var, cfg.resource_attributes);

if (str_to_bool(cfg.disable_telemetry, 0)) {
log_info(log, "disabling telemetry as per config");
} else {
send_otlp_metric_func(log, service_name);
}

free_config(&cfg);
}

Expand Down
4 changes: 1 addition & 3 deletions instrumentation/src/splunk.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "logger.h"
#include "config.h"
#include "cmdline_reader.h"
#include "metrics_client.h"

static char *const disable_env_var = "DISABLE_SPLUNK_AUTOINSTRUMENTATION";
static char *const java_tool_options_var = "JAVA_TOOL_OPTIONS";
Expand All @@ -20,8 +19,7 @@ void auto_instrument(
has_access_func_t has_access,
const char *program_name,
load_config_func_t load_config_func,
cmdline_reader cr,
send_otlp_metric_func_t send_otlp_metric_func
cmdline_reader cr
);

int streq(const char *expected, const char *actual);
Expand Down
Loading