This repository was archived by the owner on May 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Add event sampling. Name threads. #44
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,18 +6,15 @@ apply plugin: 'idea' | |
| apply plugin: 'com.github.johnrengelman.shadow' | ||
|
|
||
| configurations.all { | ||
| // check for updates every build | ||
| // check for updates every build for dependencies with: 'changing: true' | ||
| resolutionStrategy.cacheChangingModulesFor 0, 'seconds' | ||
| } | ||
|
|
||
| repositories { | ||
| mavenCentral() | ||
| mavenLocal() | ||
|
|
||
| // Before LaunchDarkly release artifacts get synced to Maven Central they are here along with snapshots: | ||
| maven { | ||
| url "https://oss.sonatype.org/content/groups/public/" | ||
| } | ||
| maven { url "https://oss.sonatype.org/content/groups/public/" } | ||
| mavenCentral() | ||
| } | ||
|
|
||
| allprojects { | ||
|
|
@@ -38,7 +35,7 @@ dependencies { | |
| compile "redis.clients:jedis:2.8.0" | ||
| testCompile "org.easymock:easymock:3.4" | ||
| testCompile 'junit:junit:[4.10,)' | ||
| testRuntime "org.slf4j:slf4j-simple:1.7.7" | ||
| testRuntime "ch.qos.logback:logback-classic:1.1.3" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using logback for tests allows for more helpful log messages that include source code line number. |
||
| } | ||
|
|
||
| jar { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ public final class LDConfig { | |
| private static final int DEFAULT_FLUSH_INTERVAL = 5; | ||
| private static final long DEFAULT_POLLING_INTERVAL_MILLIS = 1000L; | ||
| private static final long DEFAULT_START_WAIT_MILLIS = 0L; | ||
| private static final int DEFAULT_SAMPLING_INTERVAL = 0; | ||
| private static final Logger logger = LoggerFactory.getLogger(LDConfig.class); | ||
|
|
||
| protected static final LDConfig DEFAULT = new Builder().build(); | ||
|
|
@@ -42,6 +43,7 @@ public final class LDConfig { | |
| final boolean offline; | ||
| final long pollingIntervalMillis; | ||
| final long startWaitMillis; | ||
| final int samplingInterval; | ||
|
|
||
| protected LDConfig(Builder builder) { | ||
| this.baseURI = builder.baseURI; | ||
|
|
@@ -63,6 +65,7 @@ protected LDConfig(Builder builder) { | |
| this.pollingIntervalMillis = builder.pollingIntervalMillis; | ||
| } | ||
| this.startWaitMillis = builder.startWaitMillis; | ||
| this.samplingInterval = builder.samplingInterval; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -94,6 +97,7 @@ public static class Builder { | |
| private long pollingIntervalMillis = DEFAULT_POLLING_INTERVAL_MILLIS; | ||
| private FeatureStore featureStore = new InMemoryFeatureStore(); | ||
| public long startWaitMillis = DEFAULT_START_WAIT_MILLIS; | ||
| public int samplingInterval = DEFAULT_SAMPLING_INTERVAL; | ||
|
|
||
| /** | ||
| * Creates a builder with all configuration parameters set to the default | ||
|
|
@@ -335,6 +339,21 @@ public Builder startWaitMillis(long startWaitMillis) { | |
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Enable event sampling. When set to the default of zero, sampling is disabled and all events | ||
| * are sent back to LaunchDarkly. When set to greater than zero, there is a 1 in | ||
| * <code>samplingInterval</code> chance events will be will be sent. | ||
| * | ||
| * <p>Example: if you want 5% sampling rate, set <code>samplingInterval</code> to 20. | ||
| * | ||
| * @param samplingInterval the sampling interval. | ||
| * @return the builder | ||
| */ | ||
| public Builder samplingInterval(int samplingInterval) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied the semantics in the go client, but putting myself in the user's shoes I prefer using a percentage value here (and everywhere else) in the form of a floating point value from 0 to 1.0 where at 1.0 all events get sent and at 0.0 none get sent. I think consistency is more important, so we should leave it or change it everywhere. |
||
| this.samplingInterval = samplingInterval; | ||
| return this; | ||
| } | ||
|
|
||
| HttpHost proxyHost() { | ||
| if (this.proxyHost == null && this.proxyPort == -1 && this.proxyScheme == null) { | ||
| return null; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <configuration> | ||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <!-- encoders are assigned the type | ||
| ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
| <encoder> | ||
| <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36}:%line - %msg%n</pattern> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <root level="debug"> | ||
| <appender-ref ref="STDOUT" /> | ||
| </root> | ||
| </configuration> |
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
order matters here, so we look first locally, then elsewhere.