-
Notifications
You must be signed in to change notification settings - Fork 128
feat(rpc): add OpenTelemetry tracing #863
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?
Conversation
swift1337
left a comment
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.
Big! Left comments
|
|
||
| import "go.opentelemetry.io/otel" | ||
|
|
||
| var tracer = otel.Tracer("evm/rpc/backend") |
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.
let's drop this file and move this to backend.go
| func (b *Backend) GetCode(address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (hexutil.Bytes, error) { | ||
| blockNum, err := b.BlockNumberFromComet(blockNrOrHash) | ||
| func (b *Backend) GetCode(ctx context.Context, address common.Address, blockNrOrHash rpctypes.BlockNumberOrHash) (bz hexutil.Bytes, err error) { | ||
| ctx, span := tracer.Start(ctx, "GetCode", trace.WithAttributes(attribute.String("address", address.String()), attribute.String("blockNorHash", unwrapBlockNOrHash(blockNrOrHash)))) |
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 see a lot of repeated code that can be simplified with a small wrapper. Consider the following:
Creating span for existing ctx:
// wrapper would be located here:
// import https://github.com/cosmos/evm/trace
// func Start(ctx context.Context, name string, attr... Attribute)
// trace.Str supports string or Stringable
// trace.Block automatically parses block or hash
// ... other cosmos/evm specific attrs
ctx, span := trace.Start(ctx, "GetCode", trace.Str("address", address), trace.Block("block", blockNrOrHash))
// regular span end
defer span.End()
// captures err if not nil
defer span.EndErr(err)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.
Creating span for new ctx:
ctx, span := trace.StartNew("GetCode", attrs...)
defer span.End()| "github.com/cosmos/cosmos-sdk/server" | ||
| ) | ||
|
|
||
| var tracer = otel.Tracer("evm/rpc/namespaces/ethereum/debug") |
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.
same approach:
// import github.com/cosmos/evm/trace
var tracer = trace.New("evm/rpc/namespaces/ethereum/debug")|
Curious, where do we configure tracing sampling rate here? |
Description
adds otel tracers to the RPC package.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
mainbranch