-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Update emitter library and add support for ParametrizedUriEmitter #4722
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f8e92cc
Move emitters from io.druid.server.initialization to the dedicated io…
leventov 4ef0ce2
Log created RequestLoggers
leventov d9daca8
Fix forbidden API
leventov 1770ea9
Test fix
leventov c4cb602
More Http and Parametrized Http Emitter docs
leventov 1964e2c
Merge remote-tracking branch 'upstream/master' into update-emitter
leventov 88ec8bd
Merge remote-tracking branch 'upstream/master' into update-emitter
leventov 0830d52
Switch to debug level
leventov 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
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 |
|---|---|---|
|
|
@@ -203,7 +203,7 @@ The Druid servers [emit various metrics](../operations/metrics.html) and alerts | |
|
|
||
| |Property|Description|Default| | ||
| |--------|-----------|-------| | ||
| |`druid.emitter`|Setting this value to "noop", "logging", or "http" will initialize one of the emitter modules. value "composing" can be used to initialize multiple emitter modules. |noop| | ||
| |`druid.emitter`|Setting this value to "noop", "logging", "http" or "parametrized" will initialize one of the emitter modules. value "composing" can be used to initialize multiple emitter modules. |noop| | ||
|
|
||
| #### Logging Emitter Module | ||
|
|
||
|
|
@@ -216,10 +216,26 @@ The Druid servers [emit various metrics](../operations/metrics.html) and alerts | |
|
|
||
| |Property|Description|Default| | ||
| |--------|-----------|-------| | ||
| |`druid.emitter.http.timeOut`|The timeout for data reads.|PT5M| | ||
| |`druid.emitter.http.readTimeout`|The timeout for data reads.|PT5M| | ||
| |`druid.emitter.http.flushMillis`|How often the internal message buffer is flushed (data is sent).|60000| | ||
| |`druid.emitter.http.flushCount`|How many messages the internal message buffer can hold before flushing (sending).|500| | ||
| |`druid.emitter.http.recipientBaseUrl`|The base URL to emit messages to. Druid will POST JSON to be consumed at the HTTP endpoint specified by this property.|none| | ||
| |`druid.emitter.http.basicAuthentication`|Login and password for authentification in "login:password" form, e. g. `druid.emitter.http.basicAuthentication=admin:adminpassword`|not specified = no authentification| | ||
|
Contributor
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. wish list: this to be a |
||
| |`druid.emitter.http.flushTimeOut|The timeout after which an event should be sent to the endpoint, even if internal buffers are not filled, in milliseconds.|not specified = no timeout| | ||
| |`druid.emitter.http.batchingStrategy`|The strategy of how the batch is formatted. "ARRAY" means `[event1,event2]`, "NEWLINES" means `event1\nevent2`, ONLY_EVENTS means `event1event2`.|ARRAY| | ||
| |`druid.emitter.http.maxBatchSize`|The maximum batch size, in bytes.|5191680 (i. e. 5 MB)| | ||
| |`druid.emitter.http.recipientBaseUrl`|The base URL to emit messages to. Druid will POST JSON to be consumed at the HTTP endpoint specified by this property.|none, required config| | ||
|
|
||
| #### Parametrized Http Emitter Module | ||
|
|
||
| `druid.emitter.parametrized.httpEmitting.*` configs correspond to the configs of Http Emitter Modules, see above. | ||
| Except `readTimeout` and `recipientBaseUrl`. E. g. `druid.emitter.parametrized.httpEmitting.flushMillis`, | ||
| `druid.emitter.parametrized.httpEmitting.flushCount`, etc. | ||
|
|
||
| The additional configs are: | ||
| |Property|Description|Default| | ||
| |--------|-----------|-------| | ||
| |`druid.emitter.parametrized.readTimeout`|The timeout for data reads.|PT5M| | ||
| |`druid.emitter.parametrized.recipientBaseUrlPattern`|The URL pattern to send an event to, based on the event's feed. E. g. `http://foo.bar/{feed}`, that will send event to `http://foo.bar/metrics` if the event's feed is "metrics".|none, required config| | ||
|
|
||
| #### Composing Emitter Module | ||
|
|
||
|
|
||
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
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
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
34 changes: 34 additions & 0 deletions
34
server/src/main/java/io/druid/server/emitter/ParametrizedUriEmitterConfig.java
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,34 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package io.druid.server.emitter; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import org.joda.time.Period; | ||
|
|
||
| public class ParametrizedUriEmitterConfig extends com.metamx.emitter.core.ParametrizedUriEmitterConfig | ||
| { | ||
| @JsonProperty | ||
| private Period readTimeout = new Period("PT5M"); | ||
|
|
||
| public Period getReadTimeout() | ||
| { | ||
| return readTimeout; | ||
| } | ||
| } |
72 changes: 72 additions & 0 deletions
72
server/src/main/java/io/druid/server/emitter/ParametrizedUriEmitterModule.java
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,72 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package io.druid.server.emitter; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.google.common.base.Supplier; | ||
| import com.google.inject.Binder; | ||
| import com.google.inject.Module; | ||
| import com.google.inject.Provides; | ||
| import com.google.inject.name.Named; | ||
| import com.metamx.emitter.core.Emitter; | ||
| import com.metamx.emitter.core.ParametrizedUriEmitter; | ||
| import com.metamx.http.client.HttpClientConfig; | ||
| import com.metamx.http.client.HttpClientInit; | ||
| import io.druid.guice.JsonConfigProvider; | ||
| import io.druid.guice.ManageLifecycle; | ||
| import io.druid.guice.http.LifecycleUtils; | ||
| import io.druid.java.util.common.lifecycle.Lifecycle; | ||
|
|
||
| import javax.annotation.Nullable; | ||
| import javax.net.ssl.SSLContext; | ||
|
|
||
| public class ParametrizedUriEmitterModule implements Module | ||
| { | ||
| @Override | ||
| public void configure(Binder binder) | ||
| { | ||
| JsonConfigProvider.bind(binder, "druid.emitter.parametrized", ParametrizedUriEmitterConfig.class); | ||
| HttpEmitterModule.configureSsl(binder); | ||
| } | ||
|
|
||
| @Provides | ||
| @ManageLifecycle | ||
| @Named("parametrized") | ||
| public Emitter getEmitter( | ||
| Supplier<ParametrizedUriEmitterConfig> config, | ||
| @Nullable SSLContext sslContext, | ||
| Lifecycle lifecycle, | ||
| ObjectMapper jsonMapper | ||
| ) | ||
| { | ||
| final HttpClientConfig.Builder builder = HttpClientConfig | ||
| .builder() | ||
| .withNumConnections(1) | ||
| .withReadTimeout(config.get().getReadTimeout().toStandardDuration()); | ||
| if (sslContext != null) { | ||
| builder.withSslContext(sslContext); | ||
| } | ||
| return new ParametrizedUriEmitter( | ||
| config.get(), | ||
| HttpClientInit.createClient(builder.build(), LifecycleUtils.asMmxLifecycle(lifecycle)), | ||
| jsonMapper | ||
| ); | ||
| } | ||
| } |
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
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.
given that targetMap passed is a method local object, why can't we simple do it like...
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 value may be a
Mapor aString,!(nested instanceof Map)checks that the nested map couldn't be populated