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

Centralized internal logging #364

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions modules/darwinosl/darwinosl-source.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ void darwinosl_sd_options_defaults(DarwinOSLogSourceOptions *self,

LogMessage *msg;
gsize msg_len = _log_message_from_string(log_string, self->options.format_options, &msg);
msg_set_context(msg);
log_msg_set_value_to_string(msg, LM_V_TRANSPORT, "local+darwinoslog");
LogThreadedFetchResult result = {THREADED_FETCH_SUCCESS, msg};
_log_reader_insert_msg_length_stats(self, msg_len);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ SourceWorker::run()
std::string random_choice = driver.choices[rand() % driver.choices.size()];

LogMessage *msg = log_msg_new_empty();
msg_set_context(msg);
log_msg_set_value(msg, LM_V_MESSAGE, random_choice.c_str(), -1);

log_threaded_source_worker_blocking_post(&super->super, msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ _worker_run(LogThreadedSourceWorker *w)
format_hex_string(random_bytes, control->bytes, random_hex_str, random_hex_str_size);

LogMessage *msg = log_msg_new_empty();
msg_set_context(msg);
log_msg_set_value(msg, LM_V_MESSAGE, random_hex_str, -1);

log_threaded_source_worker_blocking_post(w, msg);
Expand Down
1 change: 1 addition & 0 deletions modules/grpc/common/grpc-source-worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ SourceWorker::SourceWorker(GrpcSourceWorker *s, SourceDriver &d)
void
SourceWorker::post(LogMessage *msg)
{
msg_set_context(msg);
log_threaded_source_worker_blocking_post(&super->super, msg);
}

Expand Down
1 change: 1 addition & 0 deletions modules/grpc/otel/otel-source-services.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ syslogng::grpc::otel::TraceServiceCall::Proceed(bool ok)
}

LogMessage *msg = log_msg_new_empty();
msg_set_context(msg);
Copy link
Member

@MrAnno MrAnno Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to track the message we are currently working on globally (per-thread). This idea will always imply a certain amount of layering violation, but placing this call into LogMessage constructors wouldn't necessarily help as I'm not sure we want to track each message that pops into existence.

For example, what do we want to do with synthetic messages produced by the grouping-by() and PatternDB parsers? And internal messages of course, which we don't want to track.

Copy link
Member

@MrAnno MrAnno Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this question is answered, I think we can introduce a function that can help reduce these set_context calls at least on the source and processing side.

ProtobufParser::store_raw_metadata(msg, ctx.peer(), resource, resource_spans_schema_url, scope,
scope_spans_schema_url);
ProtobufParser::store_raw(msg, span);
Expand Down
1 change: 1 addition & 0 deletions modules/python/python-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ py_log_source_post(PyObject *s, PyObject *args, PyObject *kwrds)

/* keep a reference until the PyLogMessage instance is freed */
LogMessage *message = log_msg_ref(pymsg->msg);
msg_set_context(message);
sd->post_message(sd, message);

Py_RETURN_NONE;
Expand Down