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

AO-16209 otel tracer #174

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

AO-16209 otel tracer #174

wants to merge 24 commits into from

Conversation

jiwen624
Copy link
Contributor

@jiwen624 jiwen624 commented Apr 9, 2021

An OT tracer implementation which works as an think wrapper to the existing AO Go agent.
See https://swicloud.atlassian.net/browse/AO-16209?focusedCommentId=236389 for more details.

@codecov-io
Copy link

codecov-io commented Apr 14, 2021

Codecov Report

Merging #174 (ab68a4b) into master (653c51e) will decrease coverage by 0.33%.
The diff coverage is 46.34%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #174      +/-   ##
==========================================
- Coverage   81.98%   81.65%   -0.34%     
==========================================
  Files          40       40              
  Lines        4292     4322      +30     
==========================================
+ Hits         3519     3529      +10     
- Misses        638      654      +16     
- Partials      135      139       +4     
Impacted Files Coverage Δ
v1/ao/http_client_instrumentation.go 100.00% <ø> (ø)
v1/ao/internal/reporter/event.go 97.48% <ø> (ø)
v1/ao/opentracing/tracer.go 100.00% <ø> (ø)
v1/contrib/aogrpc/interceptors.go 8.80% <0.00%> (-0.79%) ⬇️
v1/ao/trace.go 81.69% <50.00%> (-0.92%) ⬇️
v1/ao/internal/reporter/context.go 92.98% <60.00%> (-1.07%) ⬇️
v1/ao/layer.go 81.50% <62.50%> (-1.60%) ⬇️
v1/ao/http_instrumentation.go 91.39% <100.00%> (+0.28%) ⬆️
v1/ao/internal/reporter/reporter.go 82.17% <100.00%> (ø)
v1/ao/internal/reporter/reporter_grpc.go 76.85% <0.00%> (+0.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 653c51e...ab68a4b. Read the comment docs.

// SpanOptions defines the options of creating a span
type SpanOptions struct {
// WithBackTrace indicates whether to include the backtrace in BeginSpan
// Keep in mind that the cost of this option may be high as it calls
// `debug.Stack()` internally to gather the stack trace. Please consider
// the impact on performance/memory footprint carefully.
WithBackTrace bool

StartTime time.Time
EndTime time.Time

Choose a reason for hiding this comment

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

is EndTime being used? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not used in the OT tracer, the Timestamp in OT's SpanConfig is used as timestamp override instead.

// This is based from the OpenTelemetry sdk code.
func GetSpanContextAndLinks(ctx context.Context,
ignoreContext bool) (trace.Span, []trace.Link) {
local := trace.SpanFromContext(ctx)
Copy link

@patsonluk patsonluk Apr 23, 2021

Choose a reason for hiding this comment

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

Wondering if this would work if the root span is an ao.Span? For example the root span is created by our instrumentation (hence an ao.Span), then a dev uses our tracer to create a nested span, would the context.Context returns ot span which is the wrapped ao.Span root span?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, as the span needs to be attached to the context with the key currentSpanKey (defined in OT). It also checks if the span implements OT's span before returned to the caller. The users should always use one set of APIs to create spans (either OT or AO, but not mixed)

local := trace.SpanFromContext(ctx)

if ignoreContext {
links := addLinkIfValid(nil, local.SpanContext(), "current")

Choose a reason for hiding this comment

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

Is this trying to keep some info of current context (if exist), even if the config tells creating a new root? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this produces a loose link to the current span context with an attribute indicating it's "ignored-on-demand".

@patsonluk
Copy link

patsonluk commented Apr 23, 2021

Will we provide text map propagator for our tracer? https://github.com/open-telemetry/opentelemetry-go/blob/d616df61f5d163589228c5ff3be4aa5415f5a884/oteltest/text_map_propagator.go#L164

If a dev creates their own instrumentation , and then uses OT context injection, it will be nice ao's x-trace header is injected too such that it can interacts with other ao agent? :)

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2021

Codecov Report

Merging #174 (862b3c2) into master (653c51e) will decrease coverage by 0.36%.
The diff coverage is 46.34%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #174      +/-   ##
==========================================
- Coverage   81.98%   81.62%   -0.37%     
==========================================
  Files          40       40              
  Lines        4292     4322      +30     
==========================================
+ Hits         3519     3528       +9     
- Misses        638      655      +17     
- Partials      135      139       +4     
Impacted Files Coverage Δ
v1/ao/http_client_instrumentation.go 100.00% <ø> (ø)
v1/ao/internal/reporter/event.go 97.48% <ø> (ø)
v1/ao/opentracing/tracer.go 100.00% <ø> (ø)
v1/contrib/aogrpc/interceptors.go 8.80% <0.00%> (-0.79%) ⬇️
v1/ao/trace.go 81.69% <50.00%> (-0.92%) ⬇️
v1/ao/internal/reporter/context.go 92.98% <60.00%> (-1.07%) ⬇️
v1/ao/layer.go 81.50% <62.50%> (-1.60%) ⬇️
v1/ao/http_instrumentation.go 91.39% <100.00%> (+0.28%) ⬆️
v1/ao/internal/reporter/reporter.go 82.17% <100.00%> (ø)
v1/ao/internal/reporter/reporter_grpc.go 76.68% <0.00%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 653c51e...862b3c2. Read the comment docs.

@jiwen624
Copy link
Contributor Author

Will we provide text map propagator for our tracer? https://github.com/open-telemetry/opentelemetry-go/blob/d616df61f5d163589228c5ff3be4aa5415f5a884/oteltest/text_map_propagator.go#L164

If a dev creates their own instrumentation , and then uses OT context injection, it will be nice ao's x-trace header is injected too such that it can interacts with other ao agent? :)

Good point. An AO context text map propagator is added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants