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

[otel-tracing] Initial opentelemetry support #3481

Closed
wants to merge 0 commits into from

Conversation

lengrongfu
Copy link

issues: #3451

Local Repose workflows result :

image

@codecov-commenter
Copy link

Codecov Report

Merging #3481 (5d1ed40) into main (38ab4c6) will decrease coverage by 0.60%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3481      +/-   ##
==========================================
- Coverage   56.38%   55.78%   -0.61%     
==========================================
  Files         102      103       +1     
  Lines        7324     7543     +219     
==========================================
+ Hits         4130     4208      +78     
- Misses       2541     2675     +134     
- Partials      653      660       +7     
Impacted Files Coverage Δ
...bution/distribution/configuration/configuration.go 56.30% <0.00%> (-5.74%) ⬇️
...stribution/registry/storage/cache/memory/memory.go 87.17% <0.00%> (-2.53%) ⬇️
...distribution/distribution/registry/handlers/app.go 45.04% <0.00%> (-1.13%) ⬇️
...distribution/registry/storage/cache/redis/redis.go 0.00% <0.00%> (ø)
...hub.com/distribution/distribution/health/health.go 45.26% <0.00%> (ø)
.../distribution/distribution/notifications/bridge.go 53.52% <0.00%> (+0.39%) ⬆️

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 38ab4c6...5d1ed40. Read the comment docs.

@lengrongfu
Copy link
Author

@milosgajdos Hi,What else do I need to do about this PR。

tracing/tracing.go Outdated Show resolved Hide resolved
@aaronlehmann
Copy link
Contributor

It would also be great to support client-side tracing in the registry client. In a recent project, I had to fork much of the client code to use http.NewRequestWithContext instead of http.NewRequest.

@lengrongfu
Copy link
Author

lengrongfu commented Aug 23, 2021

It would also be great to support client-side tracing in the registry client. In a recent project, I had to fork much of the client code to use http.NewRequestWithContext instead of http.NewRequest.

Yes, your idea is great, but I don't know whether the registry client is the part of the distribution code or the project. If you can write in more detail, I can add this part of the function together. @aaronlehmann

@aaronlehmann
Copy link
Contributor

Yes, your idea is great, but I don't know whether the registry client is the part of the distribution code or the project

It is in the registry/client directory in this repository.

@@ -791,25 +947,33 @@ func (bs *blobs) Create(ctx context.Context, options ...distribution.BlobCreateO
if err != nil {
return nil, err
}
span.SetAttributes(attribute.String("URL", u))
span.SetAttributes(attribute.String("Method", http.MethodPost))

req, err := http.NewRequest("POST", u, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this need to be changed to NewRequestWithContext? There are also some uses of NewRequest elsewhere in this file and in registry/client/auth/session.go and registry/client/blob_writer.go.

Copy link
Author

Choose a reason for hiding this comment

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

What is the reason for changing to NewRequestWithContext here? If we are to achieve trace injection, I think it can be achieved by otel.GetTextMapPropagator().Inject(traceCtx,propagation.HeaderCarrier(req.Header)).

Copy link
Contributor

Choose a reason for hiding this comment

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

I had thought that the transport would get the span information from the context, but if that's not how it works you can disregard the comment.

Copy link
Author

Choose a reason for hiding this comment

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

You didn't understand it wrong,
1、Obtain the trace from the context and create a span, if there is one, create a new span if not

span, traceCtx := tracing.StartSpan(ctx, "blobs.delete")

2、Inject trace into other http services, go through the following steps

otel.GetTextMapPropagator().Inject(traceCtx, propagation.HeaderCarrier(req.Header))

@milosgajdos
Copy link
Member

This will need a rebase

@milosgajdos
Copy link
Member

Can you please rebase @lengrongfu

@milosgajdos
Copy link
Member

hey @lengrongfu do you mind rebasing please?

@lengrongfu
Copy link
Author

@milosgajdos hi, I don't understand how to do rebase, can you tell me the steps? thanks.

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

Successfully merging this pull request may close these issues.

None yet

5 participants