-
Notifications
You must be signed in to change notification settings - Fork 13
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: DataDog POC #250
feat: DataDog POC #250
Conversation
f2da767
to
f7c0385
Compare
WalkthroughThe recent updates focus on refining the system's telemetry and context management across various components. Key changes include enhancing the OTEL tracer setup, adjusting import statements, reorganizing graceful shutdown processes, and revamping endpoint configurations in multiple JSON files. Additionally, there are modifications to various function signatures, field renaming, and dependency updates. Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
f7c0385
to
89e5b8c
Compare
type OTELConfig struct { | ||
// The DSN to use. |
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.
Note: removed Sentry config
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.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
Files selected for processing (14)
- app/main.go (3 hunks)
- app/sqs_config.go (1 hunks)
- config-testnet.json (2 hunks)
- config.json (2 hunks)
- domain/config.go (2 hunks)
- domain/mocks/pools_usecase_mock.go (1 hunks)
- domain/pools.go (1 hunks)
- go.mod (6 hunks)
- pools/usecase/pools_usecase.go (2 hunks)
- router/usecase/pools/cosmwasm_utils.go (2 hunks)
- router/usecase/pools/pool_factory.go (1 hunks)
- router/usecase/router_test.go (1 hunks)
- router/usecase/routertesting/suite.go (1 hunks)
- system/delivery/http/system_http_handler.go (1 hunks)
Files skipped from review due to trivial changes (1)
- domain/pools.go
Additional comments not posted (21)
app/sqs_config.go (1)
15-16
: LGTM!The new endpoints
ChainTendermingRPCEndpoint
andChainGRPCGatewayEndpoint
have been added correctly to theDefaultConfig
struct.router/usecase/pools/cosmwasm_utils.go (2)
9-12
: LGTM!The new imports for gRPC and OpenTelemetry have been added correctly.
17-27
: Ensure proper error handling for gRPC client initialization.The
initializeWasmClient
function initializes a gRPC client with OpenTelemetry instrumentation. Ensure that the error handling covers all potential failure points.Verification successful
Proper error handling for gRPC client initialization is implemented.
The
initializeWasmClient
function's error handling is correctly implemented where it is used. The error returned by the function is checked and handled appropriately.
router/usecase/pools/pool_factory.go:
- Lines around the usage of
initializeWasmClient
show that the error is checked and returned if it exists.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the error handling for gRPC client initialization in the `initializeWasmClient` function. # Test: Search for the function usage. Expect: Proper error handling in all occurrences. rg --type go 'initializeWasmClient'Length of output: 391
Script:
#!/bin/bash # Description: Verify the error handling for gRPC client initialization in the `initializeWasmClient` function. # Test: Inspect the usage of `initializeWasmClient` in `router/usecase/pools/pool_factory.go` to ensure proper error handling. rg --type go --context 5 'initializeWasmClient' router/usecase/pools/pool_factory.goLength of output: 400
config-testnet.json (2)
7-8
: LGTM!The new endpoints
grpc-tendermint-rpc-endpoint
andgrpc-gateway-endpoint
have been added correctly to the configuration.
62-63
: LGTM!The OTEL configuration has been added correctly and is enabled.
config.json (2)
7-8
: LGTM!The new endpoints
grpc-tendermint-rpc-endpoint
andgrpc-gateway-endpoint
have been added correctly to the configuration.
81-82
: LGTM!The OTEL configuration has been added correctly and is enabled with the environment set to
sqs-dev
.domain/mocks/pools_usecase_mock.go (1)
30-32
: Verify theChainGRPCGatewayEndpoint
field.The
ChainGRPCGatewayEndpoint
field is set to an empty string. Ensure this is intentional and not an oversight.domain/config.go (2)
15-16
: LGTM!The new fields
ChainTendermingRPCEndpoint
andChainGRPCGatewayEndpoint
are correctly added and follow the existing pattern.
49-50
: LGTM!The new fields
Enabled
andEnvironment
are correctly added and follow the existing pattern.app/main.go (3)
18-20
: LGTM!The new import statements for OpenTelemetry and other related packages are correctly added and necessary for the changes introduced.
77-78
: LGTM!The context handling for graceful shutdown is correctly implemented and follows best practices.
145-158
: LGTM!The
initOTELTracer
function is correctly implemented and follows best practices for setting up OpenTelemetry.router/usecase/pools/pool_factory.go (2)
123-125
: LGTM!The
initializeWasmClient
function is correctly implemented and necessary for the changes introduced.
123-125
: LGTM!The modifications to the
newRoutableCosmWasmPool
function are correctly implemented and necessary for the changes introduced.system/delivery/http/system_http_handler.go (1)
58-58
: Ensure correct endpoint configuration.The
grpcAddress
assignment now usesconfig.ChainTendermingRPCEndpoint
. Verify thatChainTendermingRPCEndpoint
is correctly defined and initialized in theconfig
object.Verification successful
Ensure correct endpoint configuration.
The
ChainTendermingRPCEndpoint
is correctly defined and initialized in theconfig
object. The configuration loading mechanism usingviper
ensures that this value is properly set from the configuration file.
domain/config.go
: Definition ofChainTendermingRPCEndpoint
.app/main.go
: Configuration loading and unmarshalling usingviper
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `ChainTendermingRPCEndpoint` is correctly defined and initialized in the `config` object. # Test: Search for the definition and initialization of `ChainTendermingRPCEndpoint`. rg --type go $'ChainTendermingRPCEndpoint'Length of output: 407
Script:
#!/bin/bash # Description: Verify that the configuration loading process correctly initializes the config object with ChainTendermingRPCEndpoint. # Test: Search for the configuration loading mechanism in the codebase. rg --type go 'mapstructure'Length of output: 4197
Script:
#!/bin/bash # Description: Verify the configuration loading mechanism to ensure that the config object is correctly initialized. # Test: Search for the configuration loading mechanism in the codebase. rg --type go 'viper|config.Load|unmarshal|decode'Length of output: 2688
router/usecase/router_test.go (1)
215-216
: Ensure correct initialization ofCosmWasmPoolRouterConfig
.The
CosmWasmPoolRouterConfig
initialization now includesGeneralCosmWasmCodeIDs
andChainGRPCGatewayEndpoint
. Verify that these fields are correctly defined and used in the tests.Verification successful
Initialization of
CosmWasmPoolRouterConfig
VerifiedThe initialization of
GeneralCosmWasmCodeIDs
andChainGRPCGatewayEndpoint
in theCosmWasmPoolRouterConfig
has been correctly defined in the test files.
router/usecase/router_test.go:
GeneralCosmWasmCodeIDs
is initialized asmap[uint64]struct{}{}
.ChainGRPCGatewayEndpoint
is initialized as an empty string""
.router/usecase/routertesting/suite.go:
GeneralCosmWasmCodeIDs
is initialized asmap[uint64]struct{}{}
.ChainGRPCGatewayEndpoint
is initialized as an empty string""
.These fields are properly initialized and used in the tests.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `GeneralCosmWasmCodeIDs` and `ChainGRPCGatewayEndpoint` are correctly defined and used in the tests. # Test: Search for the definition and usage of `GeneralCosmWasmCodeIDs` and `ChainGRPCGatewayEndpoint`. rg --type go $'GeneralCosmWasmCodeIDs|ChainGRPCGatewayEndpoint'Length of output: 2182
Script:
#!/bin/bash # Extract initialization of GeneralCosmWasmCodeIDs and ChainGRPCGatewayEndpoint in test files # Search for the initialization in router_test.go echo "router_test.go initializations:" rg --type go --after 3 --before 3 'GeneralCosmWasmCodeIDs|ChainGRPCGatewayEndpoint' router/usecase/router_test.go # Search for the initialization in suite.go echo "suite.go initializations:" rg --type go --after 3 --before 3 'GeneralCosmWasmCodeIDs|ChainGRPCGatewayEndpoint' router/usecase/routertesting/suite.goLength of output: 1255
Script:
#!/bin/bash # Extract initialization of GeneralCosmWasmCodeIDs and ChainGRPCGatewayEndpoint in test files # Search for the initialization in router_test.go echo "router_test.go initializations:" rg --type go --after-context 3 --before-context 3 'GeneralCosmWasmCodeIDs|ChainGRPCGatewayEndpoint' router/usecase/router_test.go # Search for the initialization in suite.go echo "suite.go initializations:" rg --type go --after-context 3 --before-context 3 'GeneralCosmWasmCodeIDs|ChainGRPCGatewayEndpoint' router/usecase/routertesting/suite.goLength of output: 1065
pools/usecase/pools_usecase.go (2)
32-32
: Ensure correct function signature and parameter usage.The
NewPoolsUsecase
function signature now includeschainGRPCGatewayEndpoint
. Verify that this parameter is correctly passed and used in the function.Verification successful
Verified: Correct function signature and parameter usage.
The
chainGRPCGatewayEndpoint
parameter is correctly passed and used in theNewPoolsUsecase
function. It is assigned to theChainGRPCGatewayEndpoint
field of theCosmWasmPoolRouterConfig
struct, which is then used to initialize thepoolsUseCase
struct.
pools/usecase/pools_usecase.go:59
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `chainGRPCGatewayEndpoint` is correctly passed and used in the `NewPoolsUsecase` function. # Test: Search for the usage of `chainGRPCGatewayEndpoint` in the `NewPoolsUsecase` function. rg --type go $'NewPoolsUsecase'Length of output: 1279
Script:
#!/bin/bash # Extract the implementation of the NewPoolsUsecase function from pools/usecase/pools_usecase.go ast-grep --lang go --pattern $'func NewPoolsUsecase(poolsConfig *domain.PoolsConfig, chainGRPCGatewayEndpoint string, routerRepository routerrepo.RouterRepository, scalingFactorGetterCb domain.ScalingFactorGetterCb) $_' pools/usecase/pools_usecase.goLength of output: 2948
59-59
: Ensure correct initialization ofcosmWasmConfig
.The
cosmWasmConfig
initialization now includesChainGRPCGatewayEndpoint
. Verify that this field is correctly defined and used in the code.Verification successful
Initialization and usage of
ChainGRPCGatewayEndpoint
are correct.The
ChainGRPCGatewayEndpoint
is properly defined, initialized, and used in the codebase:
- Defined in
domain/pools.go
anddomain/config.go
.- Initialized in
pools/usecase/pools_usecase.go
.- Used in
router/usecase/pools/pool_factory.go
.No issues were found regarding its initialization and usage.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that `ChainGRPCGatewayEndpoint` is correctly defined and used in the code. # Test: Search for the definition and usage of `ChainGRPCGatewayEndpoint`. rg --type go $'ChainGRPCGatewayEndpoint'Length of output: 932
Script:
#!/bin/bash # Extract relevant code snippets to verify the correct initialization and usage of `ChainGRPCGatewayEndpoint`. # Extract definition in domain/pools.go echo "Definition in domain/pools.go:" rg --type go --context 5 'ChainGRPCGatewayEndpoint' domain/pools.go # Extract definition in domain/config.go echo "Definition in domain/config.go:" rg --type go --context 5 'ChainGRPCGatewayEndpoint' domain/config.go # Extract initialization in pools/usecase/pools_usecase.go echo "Initialization in pools/usecase/pools_usecase.go:" rg --type go --context 5 'ChainGRPCGatewayEndpoint' pools/usecase/pools_usecase.go # Extract usage in router/usecase/pools/pool_factory.go echo "Usage in router/usecase/pools/pool_factory.go:" rg --type go --context 5 'ChainGRPCGatewayEndpoint' router/usecase/pools/pool_factory.goLength of output: 2401
go.mod (1)
22-24
: Ensure correct addition of OpenTelemetry dependencies.The OpenTelemetry-related packages (
go.opentelemetry.io/otel
,go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc
,go.opentelemetry.io/otel/sdk
) have been added. Verify that these dependencies are correctly used in the code.Verification successful
OpenTelemetry dependencies are correctly used in the code.
The verification shows that the OpenTelemetry packages are appropriately imported and utilized in the following files:
router/delivery/http/router_handler.go
middleware/middleware.go
app/main.go
These files include necessary configurations and usage patterns for OpenTelemetry.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the OpenTelemetry dependencies are correctly used in the code. # Test: Search for the usage of OpenTelemetry-related packages. rg --type go $'go.opentelemetry.io/otel|go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc|go.opentelemetry.io/otel/sdk'Length of output: 929
Script:
#!/bin/bash # Description: Verify the correct usage of OpenTelemetry dependencies in the identified files. # Search for the usage of OpenTelemetry functions and methods in router_handler.go rg --type go 'otel|otlptrace|sdktrace|semconv' router/delivery/http/router_handler.go # Search for the usage of OpenTelemetry functions and methods in middleware.go rg --type go 'otel|otlptrace|sdktrace|semconv' middleware/middleware.go # Search for the usage of OpenTelemetry functions and methods in main.go rg --type go 'otel|otlptrace|sdktrace|semconv' app/main.goLength of output: 1389
router/usecase/routertesting/suite.go (1)
106-108
: Changes inEmpyCosmWasmPoolRouterConfig
look good.The new fields
TransmuterCodeIDs
,GeneralCosmWasmCodeIDs
, andChainGRPCGatewayEndpoint
seem appropriate for configuring CosmWasm pools.
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect | ||
go.opentelemetry.io/proto/otlp v1.3.1 // indirect |
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.
Tip
Codebase Verification
Ensure correct usage of indirect OpenTelemetry dependencies.
The go.opentelemetry.io/proto/otlp
dependency is not used in the codebase and may need to be removed. The go.opentelemetry.io/otel/exporters/otlp/otlptrace
dependency is indirectly used through otlptracegrpc
.
- Remove
go.opentelemetry.io/proto/otlp
if it is not required.
Analysis chain
Ensure correct usage of indirect OpenTelemetry dependencies.
The indirect OpenTelemetry-related packages (go.opentelemetry.io/otel/exporters/otlp/otlptrace
, go.opentelemetry.io/proto/otlp
) have been added. Verify that these dependencies are correctly used in the code.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the indirect OpenTelemetry dependencies are correctly used in the code.
# Test: Search for the usage of indirect OpenTelemetry-related packages.
rg --type go $'go.opentelemetry.io/otel/exporters/otlp/otlptrace|go.opentelemetry.io/proto/otlp'
Length of output: 176
Script:
#!/bin/bash
# Description: Verify if go.opentelemetry.io/proto/otlp is used in the codebase
# Search for the usage of go.opentelemetry.io/proto/otlp package
rg --type go 'go.opentelemetry.io/proto/otlp'
Length of output: 45
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect | ||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.25.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.25.0 | ||
go.uber.org/goleak v1.3.0 // indirect | ||
go.opentelemetry.io/otel/metric v1.28.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.28.0 |
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.
Tip
Codebase Verification
Unused OpenTelemetry Dependencies Found
The following OpenTelemetry dependencies are not used in the codebase and can be removed from go.mod
if they are not needed:
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
go.opentelemetry.io/otel/metric
Please review and remove these unnecessary dependencies to keep the go.mod
file clean.
Analysis chain
Ensure correct usage of OpenTelemetry instrumentation dependencies.
The OpenTelemetry instrumentation packages (go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc
, go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
, go.opentelemetry.io/otel/metric
, go.opentelemetry.io/otel/trace
) have been added. Verify that these dependencies are correctly used in the code.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that the OpenTelemetry instrumentation dependencies are correctly used in the code.
# Test: Search for the usage of OpenTelemetry instrumentation packages.
rg --type go $'go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc|go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp|go.opentelemetry.io/otel/metric|go.opentelemetry.io/otel/trace'
Length of output: 467
Script:
#!/bin/bash
# Description: Verify that the OpenTelemetry instrumentation dependencies are correctly used in the code.
# Search for the usage of the specific OpenTelemetry instrumentation packages that were not found in the initial search.
rg --type go 'go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp|go.opentelemetry.io/otel/metric'
Length of output: 110
Description
Switchd to GRPC gateway (port 9090) for cw queries.
Continues to use tendermint RPC for status.
Run DataDog Agent:
Failing trace
Passing trace
Notes:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores