-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Add OpenTelemetry replacements for bespoke trace logging #20728
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
base: main
Are you sure you want to change the base?
Add OpenTelemetry replacements for bespoke trace logging #20728
Conversation
It can replace bespoke tracing solution while keeping the current behavior and log format. Signed-off-by: Aleksander Mistewicz <amistewicz@google.com>
c691efe to
bebf769
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 32 files with indirect coverage changes @@ Coverage Diff @@
## main #20728 +/- ##
==========================================
- Coverage 69.16% 69.14% -0.02%
==========================================
Files 420 424 +4
Lines 34817 34882 +65
==========================================
+ Hits 24081 24120 +39
- Misses 9338 9361 +23
- Partials 1398 1401 +3 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
This is the first step:
Going with k8s-ci-robot suggestion for reviewer... /assign @ivanvc |
|
Please provide dumps of traces for before and after you change. |
|
Before change: (formatted) After change: (formatted) |
| duration := end.Sub(start) | ||
| events := s.Events() | ||
| steps := make([]string, 0, len(events)) | ||
| slices.SortFunc(events, func(a, b trace.Event) int { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does it work with nesting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From PR description:
Currently, the only difference are "child traces" which are not yet instrumented in Etcd's OpenTelemetry tracing. This can be later mitigated by adding "links" or copying events between spans. I also have other ideas...
so either printing spanID so it will be easy to search in logs/Otel collector or returning the span to use for copying like in #20307
Please note that "applier span" is the only case when one trace is part of another
pkg/traceutil/exporter.go
Outdated
| }) | ||
| for _, event := range events { | ||
| step := fmt.Sprintf("%s %s [+%dms]", | ||
| event.Name, writeAttrs(event.Attributes), event.Time.Sub(start).Milliseconds()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we match the resolution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to %.3fms
| if len(attrs) == 0 { | ||
| return "" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if len(attrs) == 0 { | |
| return "" | |
| } | |
| if len(attrs) == 0 { | |
| return "{}" | |
| } |
| } | ||
| } | ||
|
|
||
| func writeAttrs(attrs []attribute.KeyValue) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why implement own json serializer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to keep it as close to the previous implementation as possible: https://github.com/etcd-io/etcd/blob/v3.6.5/pkg/traceutil/trace.go#L44-L55
Signed-off-by: Aleksander Mistewicz <amistewicz@google.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: AwesomePatrol The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@AwesomePatrol: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Part of #12460
SpanProcessorfiltersSpansto mimic behavior ofLogIfLongand passes them toSpanExporter.SpanExporterwritesSpanstozap.LoggerasInfomessages while trying to keep the same format and contents as the original bespoke solution.Currently, the only difference are "child traces" which are not yet instrumented in Etcd's OpenTelemetry tracing. This can be later mitigated by adding "links" or copying events between spans. I also have other ideas...