-
Notifications
You must be signed in to change notification settings - Fork 4
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
apptracker: Error tracking interface and it's Sentry implementation #34
Conversation
Error tracking interface and it's Sentry implementation Task: https://app.asana.com/0/1207947010297920/1207245825676510
go mod tidy
lint fixes
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.
Thank you for working on this. I've left a few comments.
} | ||
} | ||
|
||
func StellarEnvironmentOption(configKey *string) *config.ConfigOption { |
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.
What's this environment? What's used for?
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.
Sentry needs a variable called Environment when you call sentry.Init(...) and this basically sets the value for that
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.
It is used to set up the sentry environment which is a variable we need to initialize the sentry tracker
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 think we can use the Network Passphrase
for that, what do you think?
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.
Seems like we use the sentry environment variable to initialize the tracker in the Vibrant backend so I did the same here
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.
@gouthamp-stellar this is something we're refactoring on the Vibrant backend. Unfortunately we have this duplicate ENV there.
Wdyt about using the Network Passphrase env that we already use for ingestion (like @CaioTeixeira95 suggested) and mapping it to testnet/development
or mainnet/production
in the NewSentryTracker
function.
That way we don't have this duplicate config which at the end of the day means the same thing.
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.
If not maybe we can at least name the env something like TRACKER_ENVIRONMENT
so it's not misused in other places interchangeably with NETWORK_PASSPHRASE
.
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.
Down to do that in a future pr. I already pushed a pr to kube-vibrant with this env variable. Since it's only a couple lines, I can add this change to an upcoming pr
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.
Can we add a DryRunAppTracker
? This would only log on the Stdout
, this is useful for local development environments, so we don't need to use a sentry account.
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.
makes sense. done
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.
Done
internal/ingest/ingest.go
Outdated
AppTracker sentry.SentryTracker | ||
SentryDsn string | ||
StellarEnvironment string |
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'd suggest we only have the app tracker here. Then on the config we only use a local variable:
var sentryDSN string
utils.SentryOptions(&sentryDSN)
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.
Done
@@ -151,6 +154,7 @@ func TestRecoverHandler(t *testing.T) { | |||
req, err := http.NewRequest("GET", "/", nil) | |||
require.NoError(t, err) | |||
rr := httptest.NewRecorder() | |||
appTrackerMock.On("CaptureException", mock.Anything).Return(nil) |
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.
The same suggestion that I've made on the InternalServerError
, can we test the error value here?
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.
Done
func (s *SentryTracker) CaptureMessage(message string) { | ||
sentry.CaptureMessage(message) | ||
} | ||
|
||
func (s *SentryTracker) CaptureException(exception error) { | ||
sentry.CaptureException(exception) | ||
} |
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.
Can we add tests for these methods?
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.
Done
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.
Overall, it looks good to me. Please solve the remaining commentaries before merging it.
cmd/ingest.go
Outdated
} | ||
appTracker, err := sentry.NewSentryTracker(sentryDSN, stellarEnvironment, 5) | ||
if err != nil { | ||
log.Fatalf("Error initializing App Tracker: %s", err.Error()) |
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.
log.Fatalf("Error initializing App Tracker: %s", err.Error()) | |
return fmt.Errorf("initializing app tracker: %w", 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.
Done
cmd/ingest.go
Outdated
if err != nil { | ||
log.Fatalf("Error initializing App Tracker: %s", err.Error()) | ||
} | ||
cfg.AppTracker = *appTracker |
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.
Here you should pass the reference because it is an interface!
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 made it
cfg.AppTracker = appTracker
cmd/serve.go
Outdated
if err != nil { | ||
return fmt.Errorf("initializing App Tracker: %w", err) | ||
} | ||
cfg.AppTracker = *appTracker |
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.
Here you should pass the reference because it's an interface!
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 made it
cfg.AppTracker = appTracker
) | ||
|
||
type SentryTracker struct { | ||
FlushFreq int64 |
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.
Why do we need this value, it seems it's not being used. Shall we remove it?
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.
that's a good point, where are we using it?
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.
good point, removed
internal/ingest/ingest.go
Outdated
@@ -25,6 +26,7 @@ type Configs struct { | |||
StartLedger int | |||
EndLedger int | |||
LogLevel logrus.Level | |||
AppTracker sentry.SentryTracker |
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.
Here you should use the interface!
AppTracker sentry.SentryTracker | |
AppTracker apptracker.AppTracker |
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.
Done
internal/serve/serve.go
Outdated
@@ -57,6 +59,9 @@ type Configs struct { | |||
HorizonClientURL string | |||
DistributionAccountSignatureClient signing.SignatureClient | |||
ChannelAccountSignatureClient signing.SignatureClient | |||
|
|||
// Error Tracker | |||
AppTracker sentry.SentryTracker |
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.
Here you should use the apptracker.AppTracker
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.
Done
What
Error tracking interface and it's Sentry implementation
Task: https://app.asana.com/0/1207947010297920/1207245825676510
Why
Adding sentry tracking to the Wallet Backend
Known limitations
N/A
Issue that this PR addresses
https://app.asana.com/0/1207947010297920/1207245825676510
Checklist
PR Structure
all
if the changes are broad or impact many packages.Thoroughness
Release