-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add Datadog IO #37319
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
Open
derrickaw
wants to merge
6
commits into
apache:master
Choose a base branch
from
derrickaw:addDatadogIO
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Datadog IO #37319
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
97da850
porting and some improvements
derrickaw e392f79
fix some publisher issues
derrickaw 8494052
checkstyle, import, etc changes
derrickaw b2ed9dd
add changes info on datadog
derrickaw 3854688
updated formatting and correct issue link
derrickaw e53a329
fix format issue
derrickaw 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
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,49 @@ | ||||
| /* | ||||
| * Licensed to the Apache Software Foundation (ASF) under one | ||||
| * or more contributor license agreements. See the NOTICE file | ||||
| * distributed with this work for additional information | ||||
| * regarding copyright ownership. The ASF 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. | ||||
| */ | ||||
|
|
||||
| plugins { id 'org.apache.beam.module' } | ||||
| applyJavaNature( | ||||
| automaticModuleName: 'org.apache.beam.sdk.io.datadog' | ||||
| ) | ||||
|
|
||||
| description = "Apache Beam :: SDKs :: Java :: IO :: Datadog" | ||||
| ext.summary = "IO to read and write to Datadog." | ||||
|
|
||||
| dependencies { | ||||
| implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom) | ||||
| implementation project(path: ":sdks:java:core", configuration: "shadow") | ||||
| implementation library.java.vendored_guava_32_1_2_jre | ||||
| implementation library.java.joda_time | ||||
| implementation library.java.slf4j_api | ||||
| implementation library.java.google_http_client | ||||
| implementation library.java.google_code_gson | ||||
| implementation library.java.auto_value_annotations | ||||
| annotationProcessor library.java.auto_value | ||||
|
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. This should already be handled by BeamModulePlugin:
and not needed here |
||||
| testImplementation project(path: ":sdks:java:core", configuration: "shadowTest") | ||||
| testImplementation library.java.jupiter_api | ||||
| testRuntimeOnly library.java.jupiter_engine | ||||
| testImplementation library.java.jupiter_params | ||||
| testImplementation library.java.truth | ||||
| testRuntimeOnly project(path: ":runners:direct-java", configuration: "shadow") | ||||
| testImplementation project(path: ":sdks:java:io:common") | ||||
| testImplementation group: 'org.mock-server', name: 'mockserver-client-java', version: '5.10.0' | ||||
| testImplementation group: 'org.mock-server', name: 'mockserver-junit-rule', version: '5.10.0' | ||||
| implementation library.java.google_http_client_apache_v2 | ||||
| implementation library.java.http_client | ||||
| implementation library.java.http_core | ||||
| } | ||||
102 changes: 102 additions & 0 deletions
102
sdks/java/io/datadog/src/main/java/org/apache/beam/sdk/io/datadog/DatadogEvent.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,102 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF 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 org.apache.beam.sdk.io.datadog; | ||
|
|
||
| import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull; | ||
|
|
||
| import com.google.auto.value.AutoValue; | ||
| import javax.annotation.Nullable; | ||
|
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. Prefer to use checkframework Nullable |
||
|
|
||
| /** A class for Datadog events. */ | ||
| @AutoValue | ||
| public abstract class DatadogEvent { | ||
|
|
||
| public static Builder newBuilder() { | ||
| return new AutoValue_DatadogEvent.Builder(); | ||
| } | ||
|
|
||
| @Nullable | ||
| public abstract String ddsource(); | ||
|
|
||
| @Nullable | ||
| public abstract String ddtags(); | ||
|
|
||
| @Nullable | ||
| public abstract String hostname(); | ||
|
|
||
| @Nullable | ||
| public abstract String service(); | ||
|
|
||
| @Nullable | ||
| public abstract String message(); | ||
|
|
||
| /** A builder class for creating {@link DatadogEvent} objects. */ | ||
| @AutoValue.Builder | ||
| public abstract static class Builder { | ||
|
|
||
| abstract Builder setDdsource(String source); | ||
|
|
||
| abstract Builder setDdtags(String tags); | ||
|
|
||
| abstract Builder setHostname(String hostname); | ||
|
|
||
| abstract Builder setService(String service); | ||
|
|
||
| abstract Builder setMessage(String message); | ||
|
|
||
| abstract String message(); | ||
|
|
||
| abstract DatadogEvent autoBuild(); | ||
|
|
||
| public Builder withSource(String source) { | ||
| checkNotNull(source, "withSource(source) called with null input."); | ||
|
|
||
| return setDdsource(source); | ||
| } | ||
|
|
||
| public Builder withTags(String tags) { | ||
| checkNotNull(tags, "withTags(tags) called with null input."); | ||
|
|
||
| return setDdtags(tags); | ||
| } | ||
|
|
||
| public Builder withHostname(String hostname) { | ||
| checkNotNull(hostname, "withHostname(hostname) called with null input."); | ||
|
|
||
| return setHostname(hostname); | ||
| } | ||
|
|
||
| public Builder withService(String service) { | ||
| checkNotNull(service, "withService(service) called with null input."); | ||
|
|
||
| return setService(service); | ||
| } | ||
|
|
||
| public Builder withMessage(String message) { | ||
| checkNotNull(message, "withMessage(message) called with null input."); | ||
|
|
||
| return setMessage(message); | ||
| } | ||
|
|
||
| public DatadogEvent build() { | ||
| checkNotNull(message(), "Message is required."); | ||
|
|
||
| return autoBuild(); | ||
| } | ||
| } | ||
| } | ||
94 changes: 94 additions & 0 deletions
94
sdks/java/io/datadog/src/main/java/org/apache/beam/sdk/io/datadog/DatadogEventCoder.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,94 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF 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 org.apache.beam.sdk.io.datadog; | ||
|
|
||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.OutputStream; | ||
| import org.apache.beam.sdk.coders.AtomicCoder; | ||
| import org.apache.beam.sdk.coders.NullableCoder; | ||
| import org.apache.beam.sdk.coders.StringUtf8Coder; | ||
| import org.apache.beam.sdk.values.TypeDescriptor; | ||
|
|
||
| /** A {@link org.apache.beam.sdk.coders.Coder} for {@link DatadogEvent} objects. */ | ||
| public class DatadogEventCoder extends AtomicCoder<DatadogEvent> { | ||
|
|
||
| private static final DatadogEventCoder DATADOG_EVENT_CODER = new DatadogEventCoder(); | ||
|
|
||
| private static final TypeDescriptor<DatadogEvent> TYPE_DESCRIPTOR = | ||
| new TypeDescriptor<DatadogEvent>() {}; | ||
| private static final StringUtf8Coder STRING_UTF_8_CODER = StringUtf8Coder.of(); | ||
| private static final NullableCoder<String> STRING_NULLABLE_CODER = | ||
| NullableCoder.of(STRING_UTF_8_CODER); | ||
|
|
||
| public static DatadogEventCoder of() { | ||
| return DATADOG_EVENT_CODER; | ||
| } | ||
|
|
||
| @Override | ||
| public void encode(DatadogEvent value, OutputStream out) throws IOException { | ||
| STRING_NULLABLE_CODER.encode(value.ddsource(), out); | ||
| STRING_NULLABLE_CODER.encode(value.ddtags(), out); | ||
| STRING_NULLABLE_CODER.encode(value.hostname(), out); | ||
| STRING_NULLABLE_CODER.encode(value.service(), out); | ||
| STRING_NULLABLE_CODER.encode(value.message(), out); | ||
| } | ||
|
|
||
| @Override | ||
| public DatadogEvent decode(InputStream in) throws IOException { | ||
| DatadogEvent.Builder builder = DatadogEvent.newBuilder(); | ||
|
|
||
| String source = STRING_NULLABLE_CODER.decode(in); | ||
| if (source != null) { | ||
| builder.withSource(source); | ||
| } | ||
|
|
||
| String tags = STRING_NULLABLE_CODER.decode(in); | ||
| if (tags != null) { | ||
| builder.withTags(tags); | ||
| } | ||
|
|
||
| String hostname = STRING_NULLABLE_CODER.decode(in); | ||
| if (hostname != null) { | ||
| builder.withHostname(hostname); | ||
| } | ||
|
|
||
| String service = STRING_NULLABLE_CODER.decode(in); | ||
| if (service != null) { | ||
| builder.withService(service); | ||
| } | ||
|
|
||
| String message = STRING_NULLABLE_CODER.decode(in); | ||
| if (message != null) { | ||
| builder.withMessage(message); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
| @Override | ||
| public TypeDescriptor<DatadogEvent> getEncodedTypeDescriptor() { | ||
| return TYPE_DESCRIPTOR; | ||
| } | ||
|
|
||
| @Override | ||
| public void verifyDeterministic() throws NonDeterministicException { | ||
| throw new NonDeterministicException( | ||
| this, "DatadogEvent can hold arbitrary instances, which may be non-deterministic."); | ||
| } | ||
| } |
Oops, something went wrong.
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.
see below, this isn't needed