You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2021/09/23 02:47:40 UTC

[GitHub] [incubator-eventmesh] xwm1992 commented on a change in pull request #527: [ISSUE #340]Add http trace http point

xwm1992 commented on a change in pull request #527:
URL: https://github.com/apache/incubator-eventmesh/pull/527#discussion_r714434943



##########
File path: eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/exporter/logExporter.java
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.eventmesh.runtime.exporter;
+
+import io.opentelemetry.sdk.common.CompletableResultCode;
+import io.opentelemetry.sdk.common.InstrumentationLibraryInfo;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import io.opentelemetry.sdk.trace.export.SpanExporter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collection;
+
+/**
+ *  Because the class 'LoggingSpanExporter' in openTelemetry exported garbled code in eventMesh's startUp, I override the 'LoggingSpanExporter'.
+ */
+public class logExporter implements SpanExporter {
+    private static final Logger logger = LoggerFactory.getLogger(logExporter.class);
+
+    @Override
+    public CompletableResultCode export(Collection<SpanData> spans) {
+        // We always have 32 + 16 + name + several whitespace, 60 seems like an OK initial guess.
+        StringBuilder sb = new StringBuilder(60);
+        for (SpanData span : spans) {
+            sb.setLength(0);
+            InstrumentationLibraryInfo instrumentationLibraryInfo = span.getInstrumentationLibraryInfo();
+            sb.append("'")
+                    .append(span.getName())
+                    .append("' : ")
+                    .append(span.getTraceId())
+                    .append(" ")
+                    .append(span.getSpanId())
+                    .append(" ")
+                    .append(span.getKind())
+                    .append(" [tracer: ")
+                    .append(instrumentationLibraryInfo.getName())
+                    .append(":")
+                    .append(
+                            instrumentationLibraryInfo.getVersion() == null
+                                    ? ""
+                                    : instrumentationLibraryInfo.getVersion())
+                    .append("] ")
+                    .append(span.getAttributes());
+            logger.info(sb.toString());
+        }
+        return CompletableResultCode.ofSuccess();
+    }
+
+    /**
+     * Flushes the data.
+     * (i guess it is not necessary for slf4j's log)
+     * @return the result of the operation
+     */
+    @Override
+    public CompletableResultCode flush() {
+        CompletableResultCode resultCode = new CompletableResultCode();
+//        for (Handler handler : logger.getHandlers()) {

Review comment:
       remove the unused code

##########
File path: tool/license/allowed-licenses.txt
##########
@@ -564,6 +564,36 @@
             "moduleLicense": "The Apache Software License, Version 2.0",
             "moduleVersion": "0.8.1",
             "moduleName": "io.prometheus:simpleclient_httpserver"
+        },
+        {
+            "moduleLicense": "The Apache License, Version 2.0",
+            "moduleVersion": "1.3.0",
+            "moduleName": "io.opentelemetry:opentelemetry-exporter-zipkin"
+        },
+        {
+            "moduleLicense": "The Apache Software License, Version 2.0",
+            "moduleVersion": "2.16.3",
+            "moduleName": "io.zipkin.reporter2:zipkin-reporter"
+        },
+        {
+            "moduleLicense": "The Apache Software License, Version 2.0",
+            "moduleVersion": "2.16.3",
+            "moduleName": "io.zipkin.reporter2:zipkin-sender-okhttp3"
+        },
+        {
+            "moduleLicense": "The Apache Software License, Version 2.0",
+            "moduleVersion": "2.23.2",
+            "moduleName": "io.zipkin.zipkin2:zipkin"
+        },
+        {
+            "moduleLicense": "Apache 2.0",
+            "moduleVersion": "3.14.9",
+            "moduleName": "com.squareup.okhttp3:okhttp"
+        },
+        {
+            "moduleLicense": "Apache 2.0",

Review comment:
       same as above

##########
File path: eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/trace/OpenTelemetryTraceFactory.java
##########
@@ -41,15 +44,18 @@
 
     private SpanExporter spanExporter;
 
-    private SpanExporter defaultExporter = new LoggingSpanExporter();
+    private SpanExporter defaultExporter = new logExporter();
 
     private SpanProcessor spanProcessor;
 
+    // Name of the service(using the instrumentationName)
+    private String SERVICE_NAME;
+
     public OpenTelemetryTraceFactory(CommonConfiguration configuration){
-        //different spanExporter
         try {
             String exporterName = configuration.eventMeshTraceExporterType;
-            spanExporter = (SpanExporter) Class.forName("io.opentelemetry.exporter."+exporterName+"."+exporterName+"SpanExporter").newInstance();
+            //todo different spanExporter

Review comment:
       Different exporter may implement the `SpanExporter` and you can use the reflection to get different exporter instance

##########
File path: tool/license/allowed-licenses.txt
##########
@@ -564,6 +564,36 @@
             "moduleLicense": "The Apache Software License, Version 2.0",
             "moduleVersion": "0.8.1",
             "moduleName": "io.prometheus:simpleclient_httpserver"
+        },
+        {
+            "moduleLicense": "The Apache License, Version 2.0",
+            "moduleVersion": "1.3.0",
+            "moduleName": "io.opentelemetry:opentelemetry-exporter-zipkin"
+        },
+        {
+            "moduleLicense": "The Apache Software License, Version 2.0",
+            "moduleVersion": "2.16.3",
+            "moduleName": "io.zipkin.reporter2:zipkin-reporter"
+        },
+        {
+            "moduleLicense": "The Apache Software License, Version 2.0",
+            "moduleVersion": "2.16.3",
+            "moduleName": "io.zipkin.reporter2:zipkin-sender-okhttp3"
+        },
+        {
+            "moduleLicense": "The Apache Software License, Version 2.0",
+            "moduleVersion": "2.23.2",
+            "moduleName": "io.zipkin.zipkin2:zipkin"
+        },
+        {
+            "moduleLicense": "Apache 2.0",

Review comment:
       Here not correct, `The Apache Software License, Version 2.0` or  `The Apache License, Version 2.0`




-- 
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: dev-unsubscribe@eventmesh.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org