question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Google.Cloud.Logging.Nlog - Log correlation with traces

See original GitHub issue

Hi!

Is your feature request related to a problem? Please describe. I can’t correlate stackdriver logs in the tracing panel inside the google console. image

I think that’s because of the lack of fields like trace, traceId mentioned here https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

I tried to find in code place where LogEntry is filled and eg. field trace exist, but it’s skipped at GoogleStackdriverTarget during object creation.

var logEntry = new LogEntry { Severity = s_levelMap[loggingEvent.Level], Timestamp = ConvertToTimestamp(loggingEvent.TimeStamp), LogName = _logName, Resource = _resource, }; And at other places, algorithm flow fills labels, resources section, and nothing else.

Describe the solution you’d like Giving the possibility to fill LogEntry fields required for tracing.

If it’s possible to then sorry for asking. However, in this case, documentation should be updated.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (20 by maintainers)

github_iconTop GitHub Comments

2reactions
amanda-tarafacommented, Mar 22, 2021

This has been released in Google.Cloud.Logging.NLog v3.3.0. Thanks @orchowski for the request and @snakefoot for the work!

1reaction
danielwinklercommented, Dec 28, 2021

@snakefoot Thanks for the idea, I implemented your recommendation but have some suggestions for future reference:

  • we need an offset already for the trace id extraction as the extracted value includes the header name
  • instead of layout we should use value in the variable definition
<variable name="cloud-trace-header" value="${aspnet-request-headers:headerNames=X-Cloud-Trace-Context}" />
<variable name="cloud-trace-traceid" value="${substring:inner=${cloud-trace-header}:start=22:length=32}" />
<variable name="cloud-trace-spanid" value="${substring:inner=${cloud-trace-header}:start=55:length=16}" />

@amanda-tarafa Thank you for all your support around here. I just wanted to add that it was really hard for me to wire everything together. It would be nice if there would be a bit more documentation on how to connect google logging and tracing, e.g. on the google nlog package some information on how to use the google tracing header.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google.Cloud.Logging.NLog
TraceSampled - The sampling decision of the trace associated with the log entry. See Google Logging V2 LogEntry reference docs for more ...
Read more >
Correlate log entries
However, you can group, or correlate your log entries by using the trace field in the LogEntry object. When you correlate log entries,...
Read more >
logging - Google StackDriver: How do I correlate (and nest) ...
In order to correlate your logs with the Cloud Run request log, you need to populate the property logging.googleapis.com/trace , Cloud Run ...
Read more >
Config options for NLog's configuration
AspNetTrace - Writes log messages to the ASP.NET trace. · Debugger - Writes log messages to the attached debugger through System. · DebugSystem...
Read more >
How to create Google Cloud Logging entries that are ...
How can I get this trace ID and specify it in the logs I create so I can correlate logs by the request...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found