Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Conversation

@maciejwalkowiak
Copy link
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Log4j2 integration based on existing Logback integration.

💡 Motivation and Context

Feature parity with 1.x

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • All tests passing
  • No breaking changes

🔮 Next steps

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

First pass. Just a couple notes

}

@ApiStatus.Internal
void setTransport(@Nullable ITransport transport) {
Copy link
Member

Choose a reason for hiding this comment

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

Dow e really need this or can we use the client here instead?
I assume it's for testing.
We could take a IHub in the constructor instead.
An internal overload would take it. The public overload calls into it with HubAdapter.getInstance for the prod use case

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I agree with @bruno-garcia
Sentry.init already overwrites the NoOpTransport to HttpTransport on Sdk init.
if it's for the sake of testing, I'd use the hub, I guess the other integrations also have references for transport and I'd refactor as well unless there's a need that I'm not aware of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that some properties are set in MainEventProcessor - like sdk version. This is why I moved to mocking transport instead of Hub - some things are just not possible to test when just Hub is mocked.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, makes sense.
whats about creating a new Hub, passing options, but mocking the transport in the options, it'd be pretty much the same, but the entry point here would be the Hub still as every other integration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have nothing against but I also don't see how adding this one level of indirection makes anything better..?

Copy link
Contributor

Choose a reason for hiding this comment

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

we could discuss what would make more sense here, but that's how it is in all the others tests, we never make a reference directly to the transport, but rather the entry point, and mock things in the options if necessary, so we could assert and verify directly from them.
if we decide that this would make more sense (assert on the transport), I'd rather change everywhere, I just would like to avoid a mix of different ways of doing things.

maybe @bruno-garcia has opinions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some information like SDK version is added later, in MainEventProcessor - this is why i need to mock transport on lower level.

I started with mocking Hub, but this does not give me tools to test integration properly.

Comment on lines +39 to +40
private @NotNull Level minimumBreadcrumbLevel = Level.INFO;
private @NotNull Level minimumEventLevel = Level.ERROR;
Copy link
Contributor

Choose a reason for hiding this comment

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

does it make sense to add this either to options or to the Level class as static default fields and we just read the default values from them? cus I see these 2 values repeated in all the integrations, like:

SentryOptions.DEFAULT_BREADCRUMB_LEVEL
SentryOptions.DEFAULT_EVENT_LEVEL

or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It depends if we want to pollute sentry-core with integration specific code. At this stage core is not aware of the whole mechanism of attaching breadcrumbs to events in logging integrations.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be fine with that, to not DRY, of course, it depends on a case by case, but this duplication is already in 4 integrations.

It'd be something similar, defining default values to be reused elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok understood. This would mean that we need to add conversion from SentryLevel to logging-framework-level - as these levels in appenders are are from log4j2/Logback packages.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah the converters for sure, it's just to reuse the default levels, nothing more.

Copy link
Member

Choose a reason for hiding this comment

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

IMHO I also rather to keep them out since core has nothing to do with min breadcrumb level of a logger integration

DRY doesn't mean avoid any and all "duplication" by breaking cohesion

Copy link
Contributor

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

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

looks good, left a few comments though

Copy link
Member

@bruno-garcia bruno-garcia left a comment

Choose a reason for hiding this comment

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

Just nits and questions. Looking forward to merge this!

@maciejwalkowiak
Copy link
Contributor Author

@bruno-garcia @marandaneto please take another look. I would be happy if we could finish it today.

@bruno-garcia bruno-garcia merged commit 35750dd into feat/sentry-java Sep 2, 2020
@bruno-garcia bruno-garcia deleted the log4j2-integration branch September 2, 2020 17:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants