You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2023/01/03 02:15:25 UTC
[incubator-eventmesh] branch master updated: [ISSUE apache#2788] Add Jaeger tracing plugin config
This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/master by this push:
new f46bfe616 [ISSUE apache#2788] Add Jaeger tracing plugin config
new b925c87a5 Merge pull request #2794 from seriouszyx/trace/jaeger
f46bfe616 is described below
commit f46bfe61655f61b126e2dfcd88fe93148197de56
Author: Yixiang Zhao <se...@foxmail.com>
AuthorDate: Mon Jan 2 12:28:40 2023 +0800
[ISSUE apache#2788] Add Jaeger tracing plugin config
---
build.gradle | 1 +
.../eventmesh-trace-jaeger/build.gradle | 35 ++++++++
.../eventmesh-trace-jaeger/gradle.properties | 19 +++++
.../eventmesh/trace/jaeger/JaegerTraceService.java | 62 ++++++++++++++
.../trace/jaeger/common/JaegerConstants.java | 27 ++++++
.../trace/jaeger/config/JaegerConfiguration.java | 97 ++++++++++++++++++++++
.../jaeger/config/JaegerConfigurationTest.java | 30 +++++++
.../src/test/resources/jaeger.properties | 19 +++++
settings.gradle | 1 +
9 files changed, 291 insertions(+)
diff --git a/build.gradle b/build.gradle
index 733ef7c6d..842a22559 100644
--- a/build.gradle
+++ b/build.gradle
@@ -460,6 +460,7 @@ subprojects {
dependency 'io.prometheus:simpleclient_httpserver:0.8.1'
dependency 'io.opentelemetry:opentelemetry-exporter-zipkin:1.3.0'
dependency 'io.opentelemetry:opentelemetry-semconv:1.3.0-alpha'
+ dependency 'io.opentelemetry:opentelemetry-exporter-jaeger:1.20.1'
dependency "io.openmessaging:openmessaging-api:2.2.1-pubsub"
diff --git a/eventmesh-trace-plugin/eventmesh-trace-jaeger/build.gradle b/eventmesh-trace-plugin/eventmesh-trace-jaeger/build.gradle
new file mode 100644
index 000000000..506570152
--- /dev/null
+++ b/eventmesh-trace-plugin/eventmesh-trace-jaeger/build.gradle
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+dependencies {
+ implementation project(":eventmesh-trace-plugin:eventmesh-trace-api")
+ implementation project(":eventmesh-common")
+ implementation 'org.slf4j:slf4j-api'
+ implementation 'org.apache.commons:commons-lang3'
+ implementation 'com.google.guava:guava'
+
+ implementation 'io.opentelemetry:opentelemetry-exporter-jaeger'
+ implementation 'io.opentelemetry:opentelemetry-semconv'
+
+ compileOnly 'org.projectlombok:lombok:1.18.22'
+ annotationProcessor 'org.projectlombok:lombok:1.18.22'
+
+ testCompileOnly 'org.projectlombok:lombok:1.18.22'
+ testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
+ testImplementation "org.mockito:mockito-core"
+ testImplementation "org.mockito:mockito-inline"
+}
\ No newline at end of file
diff --git a/eventmesh-trace-plugin/eventmesh-trace-jaeger/gradle.properties b/eventmesh-trace-plugin/eventmesh-trace-jaeger/gradle.properties
new file mode 100644
index 000000000..2999bfdbe
--- /dev/null
+++ b/eventmesh-trace-plugin/eventmesh-trace-jaeger/gradle.properties
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+pluginType=trace
+pluginName=jaeger
\ No newline at end of file
diff --git a/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/JaegerTraceService.java b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/JaegerTraceService.java
new file mode 100644
index 000000000..6ed11974c
--- /dev/null
+++ b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/JaegerTraceService.java
@@ -0,0 +1,62 @@
+/*
+ * 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.trace.jaeger;
+
+import org.apache.eventmesh.trace.api.EventMeshTraceService;
+import org.apache.eventmesh.trace.api.exception.TraceException;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanKind;
+import io.opentelemetry.context.Context;
+
+public class JaegerTraceService implements EventMeshTraceService {
+
+ @Override
+ public void init() throws TraceException {
+
+ }
+
+ @Override
+ public Context extractFrom(Context context, Map<String, Object> carrier) throws TraceException {
+ return null;
+ }
+
+ @Override
+ public void inject(Context context, Map<String, Object> carrier) {
+
+ }
+
+ @Override
+ public Span createSpan(String spanName, SpanKind spanKind, long startTimestamp, TimeUnit timeUnit, Context context,
+ boolean isSpanFinishInOtherThread) throws TraceException {
+ return null;
+ }
+
+ @Override
+ public Span createSpan(String spanName, SpanKind spanKind, Context context, boolean isSpanFinishInOtherThread) throws TraceException {
+ return null;
+ }
+
+ @Override
+ public void shutdown() throws TraceException {
+
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/common/JaegerConstants.java b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/common/JaegerConstants.java
new file mode 100644
index 000000000..775cd8993
--- /dev/null
+++ b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/common/JaegerConstants.java
@@ -0,0 +1,27 @@
+/*
+ * 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.trace.jaeger.common;
+
+public class JaegerConstants {
+
+ public static final String SERVICE_NAME = "eventmesh_trace";
+
+ public static final String KEY_JAEGER_IP = "eventmesh.trace.jaeger.ip";
+
+ public static final String KEY_JAEGER_PORT = "eventmesh.trace.jaeger.port";
+}
\ No newline at end of file
diff --git a/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/config/JaegerConfiguration.java b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/config/JaegerConfiguration.java
new file mode 100644
index 000000000..f50fe4bfe
--- /dev/null
+++ b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/main/java/org/apache/eventmesh/trace/jaeger/config/JaegerConfiguration.java
@@ -0,0 +1,97 @@
+/*
+ * 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.trace.jaeger.config;
+
+import org.apache.eventmesh.common.Constants;
+import org.apache.eventmesh.common.utils.PropertiesUtils;
+import org.apache.eventmesh.trace.jaeger.common.JaegerConstants;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Properties;
+
+import com.google.common.base.Preconditions;
+
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@UtilityClass
+public class JaegerConfiguration {
+
+ private static final String CONFIG_FILE = "jaeger.properties";
+
+ private static final Properties PROPERTIES = new Properties();
+
+ private String eventMeshJaegerIp = "localhost";
+
+ private int eventMeshJaegerPort = 14250;
+
+ static {
+ loadProperties();
+ initializeConfig();
+ }
+
+ private void loadProperties() {
+ URL resource = JaegerConfiguration.class.getClassLoader().getResource(CONFIG_FILE);
+ if (resource != null) {
+ try (InputStream inputStream = resource.openStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) {
+ if (inputStream.available() > 0) {
+ PROPERTIES.load(reader);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Load zipkin.properties file from classpath error", e);
+ }
+ }
+ // get from config home
+ try {
+ String configPath = Constants.EVENTMESH_CONF_HOME + File.separator + CONFIG_FILE;
+ PropertiesUtils.loadPropertiesWhenFileExist(PROPERTIES, configPath);
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Cannot load jaeger.properties file from conf", e);
+ }
+ }
+
+ private void initializeConfig() {
+ String jaegerIp = PROPERTIES.getProperty(JaegerConstants.KEY_JAEGER_IP);
+ Preconditions.checkState(StringUtils.isNotEmpty(jaegerIp),
+ String.format("%s error", JaegerConstants.KEY_JAEGER_IP));
+ eventMeshJaegerIp = StringUtils.deleteWhitespace(jaegerIp);
+
+ String jaegerPort = PROPERTIES.getProperty(JaegerConstants.KEY_JAEGER_PORT);
+ if (StringUtils.isNotEmpty(jaegerPort)) {
+ eventMeshJaegerPort = Integer.parseInt(StringUtils.deleteWhitespace(jaegerPort));
+ }
+ }
+
+ public static String getEventMeshJaegerIp() {
+ return eventMeshJaegerIp;
+ }
+
+ public static int getEventMeshJaegerPort() {
+ return eventMeshJaegerPort;
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/test/java/org/apache/eventmesh/trace/jaeger/config/JaegerConfigurationTest.java b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/test/java/org/apache/eventmesh/trace/jaeger/config/JaegerConfigurationTest.java
new file mode 100644
index 000000000..7f1245fe0
--- /dev/null
+++ b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/test/java/org/apache/eventmesh/trace/jaeger/config/JaegerConfigurationTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.trace.jaeger.config;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JaegerConfigurationTest {
+
+ @Test
+ public void testGetConfiguration() {
+ Assert.assertEquals("localhost", JaegerConfiguration.getEventMeshJaegerIp());
+ Assert.assertEquals(14250, JaegerConfiguration.getEventMeshJaegerPort());
+ }
+}
\ No newline at end of file
diff --git a/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/test/resources/jaeger.properties b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/test/resources/jaeger.properties
new file mode 100644
index 000000000..9f4ec9169
--- /dev/null
+++ b/eventmesh-trace-plugin/eventmesh-trace-jaeger/src/test/resources/jaeger.properties
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+eventmesh.trace.jaeger.ip=localhost
+eventmesh.trace.pinpoint.port=14250
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index c40de8cf8..b5ff92e8f 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -60,6 +60,7 @@ include 'eventmesh-trace-plugin'
include 'eventmesh-trace-plugin:eventmesh-trace-api'
include 'eventmesh-trace-plugin:eventmesh-trace-zipkin'
include 'eventmesh-trace-plugin:eventmesh-trace-pinpoint'
+include 'eventmesh-trace-plugin:eventmesh-trace-jaeger'
include 'eventmesh-webhook'
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org