Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions it/datadog/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.it.datadog',
)

description = "Apache Beam :: IT :: Datadog"
ext.summary = "Integration test utilities for Datadog."

dependencies {
implementation project(path: ":it:common")
implementation project(path: ":it:testcontainers")
implementation project(path: ":it:truthmatchers")
implementation project(path: ":it:conditions")
implementation "org.testcontainers:mockserver:1.19.7"
implementation "org.testcontainers:testcontainers:1.19.7"
implementation "org.mock-server:mockserver-client-java:5.10.0"
implementation "org.mock-server:mockserver-core:5.10.0"
implementation library.java.json_org
implementation "org.apache.httpcomponents:httpclient:4.5.13"
implementation "org.apache.httpcomponents:httpcore:4.4.14"
implementation library.java.google_code_gson
implementation library.java.vendored_guava_32_1_2_jre
implementation "com.google.guava:guava:33.1.0-jre"
implementation "org.slf4j:slf4j-api:2.0.16"
compileOnly library.java.auto_value_annotations

testImplementation(library.java.truth) {
exclude group: 'com.google.guava', module: 'guava'
}
testImplementation library.java.junit
testImplementation library.java.mockito_inline
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.it.datadog;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.mockserver.client.MockServerClient;

/** Datadog Driver Factory class. */
class DatadogClientFactory {
DatadogClientFactory() {}

/**
* Returns an HTTP client that is used to send HTTP messages to Datadog API.
*
* @return An HTTP client for sending HTTP messages to Datadog API.
*/
CloseableHttpClient getHttpClient() {
return HttpClientBuilder.create().disableContentCompression().build();
}

/**
* Returns a {@link MockServerClient} for sending requests to a MockServer instance.
*
* @param host the service host.
* @param port the service port.
* @return A {@link MockServerClient} to retrieve messages from a MockServer instance.
*/
MockServerClient getServiceClient(String host, int port) {
return new MockServerClient(host, port);
}
}
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.it.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;

/** A class for Datadog log entries, copy of DatadogEvent. */
@AutoValue
public abstract class DatadogLogEntry {

public static Builder newBuilder() {
return new AutoValue_DatadogLogEntry.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 DatadogLogEntry} 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 DatadogLogEntry 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 DatadogLogEntry build() {
checkNotNull(message(), "Message is required.");

return autoBuild();
}
}
}
Loading
Loading