You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "hanahmily (via GitHub)" <gi...@apache.org> on 2023/01/23 08:09:16 UTC

[GitHub] [skywalking] hanahmily commented on a diff in pull request #10300: Add aws-firehose-receiver to support collecting AWS CloudWatch metric(OpenTelemetry format)

hanahmily commented on code in PR #10300:
URL: https://github.com/apache/skywalking/pull/10300#discussion_r1083740915


##########
oap-server/server-receiver-plugin/aws-firehose-receiver/src/main/java/org/apache/skywalking/oap/server/receiver/aws/firehose/AWSFirehoseReceiverModuleProvider.java:
##########
@@ -0,0 +1,99 @@
+/*
+ * 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.skywalking.oap.server.receiver.aws.firehose;
+
+import com.linecorp.armeria.common.HttpMethod;
+import java.util.Collections;
+import org.apache.skywalking.oap.server.library.module.ModuleDefine;
+import org.apache.skywalking.oap.server.library.module.ModuleProvider;
+import org.apache.skywalking.oap.server.library.module.ModuleStartException;
+import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
+import org.apache.skywalking.oap.server.library.server.http.HTTPServer;
+import org.apache.skywalking.oap.server.library.server.http.HTTPServerConfig;
+import org.apache.skywalking.oap.server.receiver.otel.OtelMetricReceiverModule;
+
+public class AWSFirehoseReceiverModuleProvider extends ModuleProvider {
+    public static final String NAME = "default";
+
+    private AWSFirehoseReceiverModuleConfig moduleConfig;
+    private HTTPServer httpServer;
+
+    @Override
+    public String name() {
+        return NAME;
+    }
+
+    @Override
+    public Class<? extends ModuleDefine> module() {
+        return AWSFirehoseReceiverModule.class;
+    }
+
+    @Override
+    public ConfigCreator<AWSFirehoseReceiverModuleConfig> newConfigCreator() {
+        return new ConfigCreator<AWSFirehoseReceiverModuleConfig>() {
+            @Override
+            public Class<AWSFirehoseReceiverModuleConfig> type() {
+                return AWSFirehoseReceiverModuleConfig.class;
+            }
+
+            @Override
+            public void onInitialized(final AWSFirehoseReceiverModuleConfig initialized) {
+                moduleConfig = initialized;
+            }
+        };
+    }
+
+    @Override
+    public void prepare() throws ServiceNotProvidedException {
+        final HTTPServerConfig httpServerConfig = HTTPServerConfig.builder().host(moduleConfig.getHost())
+                                                                  .port(moduleConfig.getPort())
+                                                                  .contextPath(moduleConfig.getContextPath())
+                                                                  .maxThreads(moduleConfig.getMaxThreads())
+                                                                  .idleTimeOut(moduleConfig.getIdleTimeOut())
+                                                                  .acceptQueueSize(moduleConfig.getAcceptQueueSize())
+                                                                  .maxRequestHeaderSize(
+                                                                      moduleConfig.getMaxRequestHeaderSize())
+                                                                  .enableTLS(moduleConfig.isEnableTLS())
+                                                                  .tlsKeyPath(moduleConfig.getTlsKeyPath())
+                                                                  .tlsCertChainPath(moduleConfig.getTlsCertChainPath())
+                                                                  .build();
+        httpServer = new HTTPServer(httpServerConfig);
+        httpServer.initialize();
+    }
+
+    @Override
+    public void start() throws ServiceNotProvidedException, ModuleStartException {
+        httpServer.addHandler(
+            new FirehoseHTTPHandler(),
+            Collections.singletonList(HttpMethod.POST)
+        );
+    }
+
+    @Override
+    public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
+        httpServer.start();
+    }
+
+    @Override
+    public String[] requiredModules() {
+        return new String[] {
+            OtelMetricReceiverModule.NAME

Review Comment:
   Scanning tends to get rid of "hard code". It's fine to remove it if it blocks current works. Nothing won't been broken.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org