-
Notifications
You must be signed in to change notification settings - Fork 229
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
integrate some basic opentelemetry tracing #734
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,13 @@ import ( | |
"github.com/libp2p/go-libp2p-xor/kademlia" | ||
kadkey "github.com/libp2p/go-libp2p-xor/key" | ||
"github.com/libp2p/go-libp2p-xor/trie" | ||
"go.opentelemetry.io/otel" | ||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/trace" | ||
) | ||
|
||
var Tracer = otel.Tracer("") | ||
|
||
var logger = logging.Logger("fullrtdht") | ||
|
||
// FullRT is an experimental DHT client that is under development. Expect breaking changes to occur in this client | ||
|
@@ -390,6 +395,10 @@ func workers(numWorkers int, fn func(interface{}), inputs <-chan interface{}) { | |
} | ||
|
||
func (dht *FullRT) GetClosestPeers(ctx context.Context, key string) ([]peer.ID, error) { | ||
ctx, span := Tracer.Start(ctx, "GetClosestPeers") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tell the error to go deal with itself? |
||
_ = ctx // not used, but we want to assign it _just_ in case we use it. | ||
defer span.End() | ||
|
||
kbID := kb.ConvertKey(key) | ||
kadKey := kadkey.KbucketIDToKey(kbID) | ||
dht.rtLk.RLock() | ||
|
@@ -764,6 +773,9 @@ func (dht *FullRT) getValues(ctx context.Context, key string, stopQuery chan str | |
|
||
// Provide makes this node announce that it can provide a value for the given key | ||
func (dht *FullRT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err error) { | ||
ctx, span := Tracer.Start(ctx, "Provide") | ||
defer span.End() | ||
|
||
if !dht.enableProviders { | ||
return routing.ErrNotSupported | ||
} else if !key.Defined() { | ||
|
@@ -839,6 +851,9 @@ func (dht *FullRT) Provide(ctx context.Context, key cid.Cid, brdcst bool) (err e | |
// execOnMany has returned (e.g. do not write to resources that might get closed or set to nil and therefore result in | ||
// a panic instead of just returning an error). | ||
func (dht *FullRT) execOnMany(ctx context.Context, fn func(context.Context, peer.ID) error, peers []peer.ID, sloppyExit bool) int { | ||
ctx, span := Tracer.Start(ctx, "execOnMany") | ||
defer span.End() | ||
|
||
if len(peers) == 0 { | ||
return 0 | ||
} | ||
|
@@ -902,6 +917,9 @@ func (dht *FullRT) execOnMany(ctx context.Context, fn func(context.Context, peer | |
} | ||
|
||
func (dht *FullRT) ProvideMany(ctx context.Context, keys []multihash.Multihash) error { | ||
ctx, span := Tracer.Start(ctx, "ProvideMany") | ||
defer span.End() | ||
|
||
if !dht.enableProviders { | ||
return routing.ErrNotSupported | ||
} | ||
|
@@ -963,6 +981,9 @@ func (dht *FullRT) PutMany(ctx context.Context, keys []string, values [][]byte) | |
} | ||
|
||
func (dht *FullRT) bulkMessageSend(ctx context.Context, keys []peer.ID, fn func(ctx context.Context, target, k peer.ID) error, isProvRec bool) error { | ||
ctx, span := Tracer.Start(ctx, "bulkMessageSend", trace.WithAttributes(attribute.Int("numKeys", len(keys)))) | ||
defer span.End() | ||
|
||
if len(keys) == 0 { | ||
return nil | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
name?
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.
empty string uses the default tracer instance, which is fine because this isnt a top level application.
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.
Ah, got it.