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

Use common subset of SentryOptions in all 3rd party integrations to avoid code duplication and possibility to miss support of newly added properties in those integrations.

💡 Motivation and Context

Duplication between Logback and Spring Boot integration.

📝 Checklist

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

@maciejwalkowiak maciejwalkowiak changed the title Refactor common SentryOptions usage. Refactor using common parts of SentryOptions. Aug 28, 2020
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.

LGTM.
just out of curiosity, why you didn't go with the inheritance solution?

private Boolean debug;

/** @see SentryOptions#diagnosticLevel */
private SentryLevel diagnosticLevel = SentryLevel.DEBUG;
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use SentryOptions.DEFAULT_DIAGNOSTIC_LEVEL here?

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 should be null by default. My bad.

Copy link
Member

Choose a reason for hiding this comment

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

It should be DEBUG by default (perhaps with a const DEFAULT_DIAGNOSTIC_LEVEL) though, right?

If the user sets option.setDebug(true) it should automatically start printing all diag msgs of all levels

Comment on lines +14 to +27
/** @see SentryOptions#shutdownTimeoutMillis */
private Long shutdownTimeoutMillis;

/** @see SentryOptions#flushTimeoutMillis */
private Long flushTimeoutMillis;

/** @see SentryOptions#readTimeoutMillis */
private Integer readTimeoutMillis;

/** @see SentryOptions#bypassSecurity */
private Boolean bypassSecurity;

/** @see SentryOptions#debug */
private Boolean debug;
Copy link
Contributor

@marandaneto marandaneto Aug 28, 2020

Choose a reason for hiding this comment

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

should we use primitive types? otherwise, we'd need to do NPE checks in the setters too, also for all the other fields that are primitive types in SentryOptions

Copy link
Member

Choose a reason for hiding this comment

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

The advantage is being able to know if the value was set explicitly by the user and being able to flip the default after invoking a user callback.

But for this field I agree probably doesn't make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As @bruno-garcia said, we need to know which values were set explicitly by user. This way we don't need to keep in sync default values on SentryOptions and SentryCommonOptions. This also includes data type for fields - they have to be nullable otherwise we loose this information.

}

public void setDiagnosticLevel(SentryLevel diagnosticLevel) {
this.diagnosticLevel = diagnosticLevel;
Copy link
Contributor

Choose a reason for hiding this comment

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

if you look at SentryOptions.setDiagnosticLevel you see that we don't allow null values, and here it is possible, if one sets it to null, it'll crash the app.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In applyTo there is a check for null. The idea is that we apply only properties explicitly set by user.

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.

before LGTM, left a few comments.

@maciejwalkowiak
Copy link
Contributor Author

LGTM.
just out of curiosity, why you didn't go with the inheritance solution?

@marandaneto I don't see how I can apply inheritance here to achieve this.

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

@maciejwalkowiak
Copy link
Contributor Author

Superseded by #530

@bruno-garcia bruno-garcia deleted the refactor-sentry-properties branch August 31, 2020 22:10
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