-
Notifications
You must be signed in to change notification settings - Fork 122
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
feat: implement opentelemetry for distributed tracing #706
Conversation
Signed-off-by: namkyu1999 <[email protected]>
邮件已收到,我会尽快阅读并回复,谢谢
|
…o distributed-tracing
Signed-off-by: namkyu1999 <[email protected]>
…o distributed-tracing Signed-off-by: namkyu1999 <[email protected]>
Signed-off-by: namkyu1999 <[email protected]>
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.
This is a great start however I don't see any place where we are marking span as error in case of failure, do we plan to do this in future iterations?
Based on the experiment context it might be good to explore what span attributes might be relevant.
Lastly to be able to correlate logs with traces can we add traceID to logs?
I will record errors like below if err != nil {
span.SetStatus(codes.Error, "operationThatCouldFail failed")
span.RecordError(err)
} But we have over 50 chaos faults, so it can be merged in the next PR (it is a time-consuming job)
Does this mean adding a span attribute to help with future queries by attribute?
sure, I will add it |
Signed-off-by: namkyu1999 <[email protected]>
Span Attributes can be useful for queries but also they can serve as additional context when reviewing the spans. Let's take an example, you get an http request, you might wanna log the relevant headers, the request body and the path similarly in context of the experiments it might be helpful to log the parameters for the experiment, maybe the targets and any other data you think that might be helpful when looking at an error trace :) The demo application might be a good inspiration, another source of inspiration is semantic attributes. Lastly for future I would suggest we increase the coverage of instrumentation (can be a good task for LFX contributors) by creating spans for calls to external services such as AWS, GCP, K8s or any HTTP or DB calls this contrib package has some out of the box shims that can make it easy
Totally understandable, instrumentation quality and coverage can always be improved overtime. Your initiative paves the foundation we can build on top of, my comment was just suggestions/ideas if you have sometime maybe raise log them as Github issues so other contributors can pick them up |
Thanks for your detailed comments @smitthakkar96 :) I am going to pave the foundation for collaborating with other contributors. Adopting a |
Signed-off-by: namkyu1999 <[email protected]>
Signed-off-by: namkyu1999 <[email protected]>
Signed-off-by: namkyu1999 <[email protected]>
440179f
to
86c0bab
Compare
chaoslib/litmus/gcp-vm-disk-loss-by-label/lib/gcp-vm-disk-loss-by-label.go
Outdated
Show resolved
Hide resolved
chaoslib/litmus/gcp-vm-instance-stop-by-label/lib/gcp-vm-instance-stop-by-label.go
Outdated
Show resolved
Hide resolved
bin/experiment/experiment.go
Outdated
|
||
clients := clients.ClientSets{} | ||
ctx, span := otel.Tracer(telemetry.TracerName).Start(ctx, "ExecuteExperiment") |
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.
As we are creating one more ctx context, it will shadow the above context var created with the same name.
Which can cause the defer function not to work. Can we use a different var name here to avoid var shadow?
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.
fixed here fix: avoid shadowing
@@ -24,7 +27,9 @@ var ( | |||
) | |||
|
|||
// PrepareAWSSSMChaosByID contains the prepration and injection steps for the experiment | |||
func PrepareAWSSSMChaosByID(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error { | |||
func PrepareAWSSSMChaosByID(ctx context.Context, experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error { | |||
ctx, span := otel.Tracer(telemetry.TracerName).Start(ctx, "InjectAWSChaosByIDChaos") |
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.
We init otel SDK if otelExporterEndpoint != "". Here we are calling Tracer function without checking if the endpoint is set or not. Will it handle negative cases implicitly or should we call this conditionally?
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.
Signed-off-by: namkyu1999 <[email protected]>
Signed-off-by: namkyu1999 <[email protected]>
Signed-off-by: namkyu1999 <[email protected]>
Signed-off-by: namkyu1999 <[email protected]>
Signed-off-by: namkyu1999 <[email protected]>
What this PR does / why we need it:
This pr implements opentelemetry codes according to this proposal.
Parent context and OTEL endpoint are passed through env(TRACE_PARENT, OTEL_EXPORTER_OTLP_ENDPOINT)
Result is like below
relevant PRs
Checklist:
breaking-changes
tagrequires-upgrade
tag