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

Log context integration changes #1382

Merged
merged 2 commits into from
May 9, 2022

Conversation

helsaawy
Copy link
Contributor

@helsaawy helsaawy commented Apr 27, 2022

This PR is broken into two commits: the second is a text-replace of trace.StartSpan with oc.StartSpan

Changed how internal\log functions interacts with context.
log.G no longer adds trace/span IDs to entry.
Added logrus hook to add trace/span ID to entry when exporting log
entry.

This reduces overhead associated creating a log entry such that tracing
information is only added if the entry will be exported.

Added log.U(ctx) to update the context an entry (in the context) points
to, allowing it to reference the latest span and other values stored in the
context.

Added log.S(ctx) to set the log entry stored in the context with
provided fields. log.G(ctx) now checks the context for a stored
context.
log.S and log.U are the logging equivalent of span attributes, except
the logrus fields added will be present on all log entries in the context
retrieved with log.G(ctx).

Added log.Copy() to add log entry and trace span from source context
to destination, allowing for duplicating log entries and span context
but not cancellation.

Added oc.StartSpan[WithRemoteParent] to set the context for log entries
to reference the newly created context that contains the span using log.U.

Replaced instances of trace.StartSpan with oc.StartSpan.

Signed-off-by: Hamza El-Saawy hamzaelsaawy@microsoft.com

@helsaawy helsaawy requested a review from a team as a code owner April 27, 2022 22:01
@helsaawy helsaawy force-pushed the he/trace-log-context branch 2 times, most recently from 9d36957 to e41a89c Compare April 27, 2022 22:36
@ghost
Copy link

ghost commented Apr 28, 2022

CLA assistant check
All CLA requirements met.

@helsaawy helsaawy force-pushed the he/trace-log-context branch 4 times, most recently from d7bc8cf to c967588 Compare April 29, 2022 20:40
internal/log/context.go Outdated Show resolved Hide resolved
internal/oc/span.go Outdated Show resolved Hide resolved
pkg/octtrpc/interceptor.go Show resolved Hide resolved
@helsaawy
Copy link
Contributor Author

helsaawy commented May 2, 2022

@anmaxvl I'm embarrassed I didn't catch those

internal/oc/span.go Outdated Show resolved Hide resolved
@helsaawy helsaawy force-pushed the he/trace-log-context branch 2 times, most recently from 2ef2e13 to bb92ba5 Compare May 2, 2022 22:15
internal/oc/span.go Outdated Show resolved Hide resolved
@helsaawy helsaawy force-pushed the he/trace-log-context branch 2 times, most recently from c36bebc to c99c73d Compare May 3, 2022 14:44
@helsaawy
Copy link
Contributor Author

helsaawy commented May 3, 2022

rebased to preserve commit split between updates to logging and tracing, and then replacement in code

@anmaxvl anmaxvl self-assigned this May 4, 2022
Copy link
Contributor

@anmaxvl anmaxvl left a comment

Choose a reason for hiding this comment

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

one question, otherwise LGTM

helsaawy added 2 commits May 9, 2022 11:02
Changed `internal\log` functions interacts with context.
`log.G` no longer adds trace/span IDs to entry.

Added logrus hook to add trace/span ID to entry when exporting log
entry.

Added `log.S()` to set the log entry stored in the context with
provided fields. `log.G()` now checks the context for a stored
context.

Added `log.Copy()` to add log entry and trace span from source context
to destination, allowing for duplicating contexts but not cancellation.

Added `log.U()` to update the context an entry (in the context) points
to, allowing it to reference the latest span and other information.

Added `oc.StartSpan[WithRemoteParent]` to set the context for log entries
to reference the newly created context.

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
@helsaawy helsaawy force-pushed the he/trace-log-context branch from c99c73d to 50896fa Compare May 9, 2022 15:03
@helsaawy
Copy link
Contributor Author

helsaawy commented May 9, 2022

rebased to fix merge conflict

@helsaawy helsaawy merged commit 9efc654 into microsoft:master May 9, 2022
@helsaawy helsaawy deleted the he/trace-log-context branch May 9, 2022 15:11
anmaxvl added a commit that referenced this pull request Feb 7, 2023
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 28, 2024
Log integration changes

Changed `internal\log` functions interacts with context.
`log.G` no longer adds trace/span IDs to entry.

Added logrus hook to add trace/span ID to entry when exporting log
entry.

Added `log.S()` to set the log entry stored in the context with
provided fields. `log.G()` now checks the context for a stored
context.

Added `log.Copy()` to add log entry and trace span from source context
to destination, allowing for duplicating contexts but not cancellation.

Added `log.U()` to update the context an entry (in the context) points
to, allowing it to reference the latest span and other information.

Added `oc.StartSpan[WithRemoteParent]` to set the context for log entries
to reference the newly created context.

Switch to oc.StartSpan to update log context

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
princepereira pushed a commit to princepereira/hcsshim that referenced this pull request Aug 29, 2024
Log integration changes

Changed `internal\log` functions interacts with context.
`log.G` no longer adds trace/span IDs to entry.

Added logrus hook to add trace/span ID to entry when exporting log
entry.

Added `log.S()` to set the log entry stored in the context with
provided fields. `log.G()` now checks the context for a stored
context.

Added `log.Copy()` to add log entry and trace span from source context
to destination, allowing for duplicating contexts but not cancellation.

Added `log.U()` to update the context an entry (in the context) points
to, allowing it to reference the latest span and other information.

Added `oc.StartSpan[WithRemoteParent]` to set the context for log entries
to reference the newly created context.

Switch to oc.StartSpan to update log context

Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants