-
Notifications
You must be signed in to change notification settings - Fork 819
Log to Spans #767
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
Comments
@reyang was doing experiments on something similar. Can you comment on this? |
@enzian would you clarify the goal here? It seems that you want logs from ILogger to be attached as Span Events - why would you want to take this approach?
|
@reyang I am aware, that event != logs. There is two reasons for me wanting to use them to carry logging information though. Please correct me if I'm going wrong on any of them or if there are better or more ideomatic solutions to any of these problems. The first problem is, that I want to decouple my code for as many depencencies as possible. The way I'd have to record things right now is to write a log and write one or more lines to write a corresponding event. This introduces two dependencies into my code, one on The other problem is the correlation between logs and traces. While there are a number of system that can collect logs none of them (as far as I know) are able to correlate this to a span in say Jaeger. This is why I would like to use the span to carry this information. I'm ready to be shown the errors of my ways :-) |
This doesn't sound correct to me. Logs/Metrics/Traces are very different things and the OpenTelemetry philosophy is to separate them via different set of APIs. Technically speaking, one could use metrics API for logging and put all the information as dimensions, or use logging API for metrics by putting dimensions as individual fields for a log entry - I don't think OpenTelemetry would encourage such behavior.
Log correlation is an important feature that are supported by several systems and components. class Program
{
static readonly ActivitySource source = new ActivitySource("DemoSource");
static void Main()
{
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole(options => { options.IncludeScopes = true; });
builder.Configure(options => options.ActivityTrackingOptions =
ActivityTrackingOptions.TraceId |
ActivityTrackingOptions.SpanId |
ActivityTrackingOptions.TraceFlags
);
});
var logger = loggerFactory.CreateLogger<Program>();
using (var activity = source.StartActivity("SayHello"))
{
logger.LogInformation("Hello from ILogger!");
}
}
} |
I there an idiomatic way of getting Logs written to a Span? This would accomplish two things at once - eliminate the need for collecting running console outputs and on the other hand it would enable the user to decouple the code from direcly writing to the logs of the current span... The issue I'm facing here is that I am not really clear on the best method to get something like this done. One solution I cam up with was to write an
ILogger
andILoggerFactory
that look something like this:which could then be used like this:
The text was updated successfully, but these errors were encountered: