Skip to content

Commit 71a101f

Browse files
authored
Merge pull request #60 from exceptionless/refactor-configuration-manager
Merged ConfigurationManager and Configuration into one class
2 parents 7775919 + 1d391d5 commit 71a101f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+794
-831
lines changed

README.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Exceptionless.Java
22

3-
The definition of the word exceptionless is: to be without exception. [Exceptionless](https://exceptionless.io) provides real-time error reporting for your Java apps. It organizes the gathered information into simple actionable data that will help your app become exceptionless!
3+
The definition of the word exceptionless is: to be without exception. [Exceptionless](https://exceptionless.io) provides
4+
real-time error reporting for your Java apps. It organizes the gathered information into simple actionable data that
5+
will help your app become exceptionless!
46

57
## Using Exceptionless
68

@@ -11,7 +13,7 @@ Refer to the Exceptionless documentation here: [Exceptionless Docs](http://docs.
1113
## Show me the code
1214

1315
```java
14-
class ExampleApp{
16+
class ExampleApp {
1517
public static void main(String[] args) {
1618
private static final ExceptionlessClient client =
1719
ExceptionlessClient.from(
@@ -44,24 +46,26 @@ _Example: Customizing your Event Queue implementation_
4446

4547
```
4648
EventQueueIF queue = //get your implementation
47-
Configuration configuration =
48-
Configuration.builder().serverUrl("http://your-server-url").apiKey("your-api-key").build();
49-
ConfigurationManager configurationManager =
50-
ConfigurationManager.builder().queue(queue).configuration(configuration).build();
51-
ExceptionlessClient client =
52-
ExceptionlessClient.builder().configurationManager(configurationManager).build();
49+
Configuration configuration = Configuration.builder()
50+
.serverUrl("http://your-server-url")
51+
.apiKey("your-api-key")
52+
.queue(queue)
53+
.build();
54+
ExceptionlessClient client = ExceptionlessClient.builder().configuration(configuration).build();
5355
```
5456

5557
In this library we have made sure that all the values which are not set by builders fallback to reasonable defaults. So
5658
don't feel the pressure to supply values for all the fields. **Note:** Whenever customizing the client
57-
using `ConfigurationManager` never forget to supply your `serverUrl` and `apiKey` using a `Configuration` object as
59+
using `Configuration` never forget to supply your `serverUrl` and `apiKey` using a `Configuration` object as
5860
shown above.
5961

6062
## Spring Boot Users
6163

62-
You can observe `NoClassDefFoundError` in your Spring-boot apps because Spring-boot uses v3 of `OkHttpClient` while this client uses v4. In that case you have to explicitly declare v4 of the library in you `pom.xml/build.gradle`.
64+
You can observe `NoClassDefFoundError` in your Spring-boot apps because Spring-boot uses v3 of `OkHttpClient` while this
65+
client uses v4. In that case you have to explicitly declare v4 of the library in you `pom.xml/build.gradle`.
6366

6467
```xml
68+
6569
<dependencies>
6670
<dependency>
6771
<groupId>com.exceptionless</groupId>
@@ -83,15 +87,18 @@ You can observe `NoClassDefFoundError` in your Spring-boot apps because Spring-b
8387

8488
## General Data Protection Regulation
8589

86-
By default the Exceptionless Client will report all available metadata including potential PII data.
87-
You can fine tune the collection of information via Data Exclusions or turning off collection completely.
90+
By default the Exceptionless Client will report all available metadata including potential PII data. You can fine tune
91+
the collection of information via Data Exclusions or turning off collection completely.
8892

89-
Please visit the [docs](https://exceptionless.com/docs/clients/javascript/client-configuration/#general-data-protection-regulation)
93+
Please visit
94+
the [docs](https://exceptionless.com/docs/clients/javascript/client-configuration/#general-data-protection-regulation)
9095
for detailed information on how to configure the client to meet your requirements.
9196

9297
## Support
9398

94-
If you need help, please contact us via in-app support, [open an issue](https://github.com/exceptionless/Exceptionless.Java/issues/new) or [join our chat on Discord](https://discord.gg/6HxgFCx). We’re always here to help if you have any questions!
99+
If you need help, please contact us via in-app
100+
support, [open an issue](https://github.com/exceptionless/Exceptionless.Java/issues/new)
101+
or [join our chat on Discord](https://discord.gg/6HxgFCx). We’re always here to help if you have any questions!
95102

96103
## Thanks
97104

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<dependency>
5555
<groupId>org.mockito</groupId>
5656
<artifactId>mockito-core</artifactId>
57-
<version>2.21.0</version>
57+
<version>2.25.1</version>
5858
<scope>test</scope>
5959
</dependency>
6060
<dependency>

samples/example-app/src/main/java/com/exceptionless/example/app/ExampleApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void sampleEventSubmissions() {
1919
}
2020

2121
public static void sampleUseOfSessions() {
22-
client.getConfigurationManager().useSessions();
22+
client.getConfiguration().useSessions();
2323
client.submitEvent(client.createSessionStart().userIdentity("test-user").build());
2424
client.submitSessionEnd("test-user");
2525
}

src/main/java/com/exceptionless/exceptionlessclient/ExceptionlessClient.java

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.exceptionless.exceptionlessclient;
22

33
import com.exceptionless.exceptionlessclient.configuration.Configuration;
4-
import com.exceptionless.exceptionlessclient.configuration.ConfigurationManager;
54
import com.exceptionless.exceptionlessclient.enums.EventPropertyKey;
65
import com.exceptionless.exceptionlessclient.enums.EventType;
76
import com.exceptionless.exceptionlessclient.models.Event;
@@ -28,27 +27,24 @@ public class ExceptionlessClient {
2827
private static final int UPDATE_SETTINGS_TIMER_INITIAL_DELAY = 5000;
2928
private static final Integer DEFAULT_NTHREADS = 10;
3029

31-
@Getter private final ConfigurationManager configurationManager;
30+
@Getter private final Configuration configuration;
3231
private final EventPluginRunner eventPluginRunner;
3332
private final Timer updateSettingsTimer;
3433
private final ExecutorService executorService;
3534

3635
@Builder
37-
public ExceptionlessClient(ConfigurationManager configurationManager, Integer nThreads) {
36+
public ExceptionlessClient(Configuration configuration, Integer nThreads) {
3837
this(
39-
configurationManager,
38+
configuration,
4039
UPDATE_SETTINGS_TIMER_INITIAL_DELAY,
4140
nThreads == null ? DEFAULT_NTHREADS : nThreads);
4241
}
4342

4443
@VisibleForTesting
4544
ExceptionlessClient(
46-
ConfigurationManager configurationManager,
47-
long updateSettingsTimerInitialDelay,
48-
Integer nThreads) {
49-
this.configurationManager = configurationManager;
50-
this.eventPluginRunner =
51-
EventPluginRunner.builder().configurationManager(this.configurationManager).build();
45+
Configuration configuration, long updateSettingsTimerInitialDelay, Integer nThreads) {
46+
this.configuration = configuration;
47+
this.eventPluginRunner = EventPluginRunner.builder().configuration(this.configuration).build();
5248
this.updateSettingsTimer = new Timer(UPDATE_SETTINGS_TIMER_NAME);
5349
this.executorService = Executors.newFixedThreadPool(nThreads);
5450
init(updateSettingsTimerInitialDelay);
@@ -60,29 +56,25 @@ private void init(long delay) {
6056
@Override
6157
public void run() {
6258
try {
63-
configurationManager.getSettingsManager().updateSettings();
59+
configuration.getSettingsManager().updateSettings();
6460
} catch (Exception e) {
6561
log.error("Error in updating settings", e);
6662
}
6763
}
6864
},
6965
delay,
70-
configurationManager.getConfiguration().getUpdateSettingsWhenIdleInterval());
66+
configuration.getUpdateSettingsWhenIdleInterval().get());
7167

72-
configurationManager.onChanged(
73-
ignored -> configurationManager.getSettingsManager().updateSettings());
74-
configurationManager
68+
configuration.onChanged(ignored -> configuration.getSettingsManager().updateSettings());
69+
configuration
7570
.getQueue()
7671
.onEventsPosted(
77-
(ignored1, ignored2) -> configurationManager.getSettingsManager().updateSettings());
72+
(ignored1, ignored2) -> configuration.getSettingsManager().updateSettings());
7873
}
7974

8075
public static ExceptionlessClient from(String apiKey, String serverUrl) {
8176
return ExceptionlessClient.builder()
82-
.configurationManager(
83-
ConfigurationManager.builder()
84-
.configuration(Configuration.builder().apiKey(apiKey).serverUrl(serverUrl).build())
85-
.build())
77+
.configuration(Configuration.builder().apiKey(apiKey).serverUrl(serverUrl).build())
8678
.build();
8779
}
8880

@@ -223,9 +215,7 @@ public Event.EventBuilder createSessionStart() {
223215
}
224216

225217
public Event.EventBuilder createEvent() {
226-
return Event.builder()
227-
.dataExclusions(configurationManager.getDataExclusions())
228-
.date(LocalDate.now());
218+
return Event.builder().dataExclusions(configuration.getDataExclusions()).date(LocalDate.now());
229219
}
230220

231221
public CompletableFuture<Void> submitEventAsync(Event event) {
@@ -252,7 +242,7 @@ public CompletableFuture<Void> submitSessionEndAsync(String sessionOrUserId) {
252242

253243
public void submitSessionEnd(String sessionOrUserId) {
254244
log.info(String.format("Submitting session end: %s", sessionOrUserId));
255-
configurationManager.getSubmissionClient().sendHeartBeat(sessionOrUserId, true);
245+
configuration.getSubmissionClient().sendHeartBeat(sessionOrUserId, true);
256246
}
257247

258248
public CompletableFuture<SubmissionResponse> updateEmailAndDescriptionAsync(
@@ -264,7 +254,7 @@ public CompletableFuture<SubmissionResponse> updateEmailAndDescriptionAsync(
264254
public SubmissionResponse updateEmailAndDescription(
265255
String referenceId, String email, String description) {
266256
SubmissionResponse response =
267-
configurationManager
257+
configuration
268258
.getSubmissionClient()
269259
.postUserDescription(
270260
referenceId,
@@ -285,6 +275,6 @@ public SubmissionResponse updateEmailAndDescription(
285275
}
286276

287277
public String getLastReferenceId() {
288-
return configurationManager.getLastReferenceIdManager().getLast();
278+
return configuration.getLastReferenceIdManager().getLast();
289279
}
290280
}

0 commit comments

Comments
 (0)