Skip to content

Commit

Permalink
Support collect OTLP traces in v3 server (#3580)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrproliu authored Oct 31, 2023
1 parent d5d4901 commit 3c23205
Show file tree
Hide file tree
Showing 40 changed files with 688 additions and 458 deletions.
7 changes: 7 additions & 0 deletions zipkin-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
<module>../skywalking/oap-server/server-core</module>
<module>../skywalking/oap-server/server-receiver-plugin/receiver-proto</module>
<module>../skywalking/oap-server/server-receiver-plugin/zipkin-receiver-plugin</module>
<module>../skywalking/oap-server/server-receiver-plugin/otel-receiver-plugin</module>
<module>../skywalking/oap-server/server-receiver-plugin/skywalking-sharing-server-plugin</module>
<module>../skywalking/oap-server/server-cluster-plugin/cluster-standalone-plugin</module>
<module>../skywalking/oap-server/server-cluster-plugin/cluster-consul-plugin</module>
<module>../skywalking/oap-server/server-cluster-plugin/cluster-etcd-plugin</module>
Expand All @@ -59,6 +61,9 @@
<module>../skywalking/oap-server/server-testing</module>
<module>../skywalking/oap-server/server-configuration/configuration-api</module>
<module>../skywalking/oap-server/ai-pipeline</module>
<module>../skywalking/oap-server/analyzer/meter-analyzer</module>
<module>../skywalking/oap-server/analyzer/log-analyzer</module>
<module>../skywalking/oap-server/analyzer/agent-analyzer</module>

<module>server-core</module>
<module>server-starter</module>
Expand All @@ -73,6 +78,8 @@
<module>telemetry-zipkin</module>
<module>zipkin-dependency</module>
<module>zipkin-storage-ext</module>
<module>receiver-zipkin-core</module>
<module>receiver-otlp-trace</module>
</modules>

<dependencyManagement>
Expand Down
37 changes: 37 additions & 0 deletions zipkin-server/receiver-otlp-trace/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>zipkin-server-parent</artifactId>
<groupId>io.zipkin</groupId>
<version>2.24.4-SNAPSHOT</version>
</parent>

<artifactId>receiver-otlp-trace</artifactId>
<name>OTLP Trace Receiver</name>

<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>otel-receiver-plugin</artifactId>
<version>${skywalking.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.skywalking</groupId>
<artifactId>skywalking-sharing-server-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.skywalking</groupId>
<artifactId>meter-analyzer</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.skywalking</groupId>
<artifactId>log-analyzer</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2015-2023 The OpenZipkin Authors
*
* Licensed 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 zipkin.server.receiver.otlp;

import org.apache.skywalking.oap.server.library.module.ModuleConfig;

public class OTLPTraceConfig extends ModuleConfig {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright 2015-2023 The OpenZipkin Authors
*
* Licensed 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 zipkin.server.receiver.otlp;

import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
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.receiver.otel.OtelMetricReceiverConfig;
import org.apache.skywalking.oap.server.receiver.otel.OtelMetricReceiverModule;
import org.apache.skywalking.oap.server.receiver.otel.otlp.OpenTelemetryMetricRequestProcessor;
import org.apache.skywalking.oap.server.receiver.otel.otlp.OpenTelemetryTraceHandler;
import zipkin.server.receiver.otlp.handler.OTLPTraceHandler;

public class OTLPTraceProvider extends ModuleProvider {
private OTLPTraceConfig moduleConfig;
private OpenTelemetryTraceHandler traceHandler;

@Override
public String name() {
return "zipkin";
}

@Override
public Class<? extends ModuleDefine> module() {
return OtelMetricReceiverModule.class;
}

@Override
public ConfigCreator<? extends ModuleConfig> newConfigCreator() {
return new ConfigCreator<OTLPTraceConfig>() {

@Override
public Class<OTLPTraceConfig> type() {
return OTLPTraceConfig.class;
}

@Override
public void onInitialized(OTLPTraceConfig initialized) {
moduleConfig = initialized;
}
};
}

@Override
public void prepare() throws ServiceNotProvidedException, ModuleStartException {
this.registerServiceImplementation(OpenTelemetryMetricRequestProcessor.class,
new OpenTelemetryMetricRequestProcessor(getManager(), new OtelMetricReceiverConfig()));
}

@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
GRPCHandlerRegister handlerRegister = getManager().find(CoreModule.NAME).provider().getService(GRPCHandlerRegister.class);
traceHandler = new OTLPTraceHandler(handlerRegister, getManager());
traceHandler.active();
}

@Override
public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
}

@Override
public String[] requiredModules() {
return new String[0];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2015-2023 The OpenZipkin Authors
*
* Licensed 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 zipkin.server.receiver.otlp.handler;

import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
import org.apache.skywalking.oap.server.receiver.otel.otlp.OpenTelemetryTraceHandler;

public class OTLPTraceHandler extends OpenTelemetryTraceHandler {
private final GRPCHandlerRegister register;
public OTLPTraceHandler(GRPCHandlerRegister register, ModuleManager manager) {
super(manager);
this.register = register;
}

@Override
public void active() throws ModuleStartException {
register.addHandler(this);
}
}
Original file line number Diff line number Diff line change
@@ -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.
#
#

zipkin.server.receiver.otlp.OTLPTraceProvider
8 changes: 1 addition & 7 deletions zipkin-server/receiver-zipkin-activemq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@
<dependencies>
<dependency>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-server-core</artifactId>
<artifactId>receiver-zipkin-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>zipkin-receiver-plugin</artifactId>
<version>${skywalking.version}</version>
</dependency>

<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.apache.activemq.transport.TransportListener;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.receiver.zipkin.trace.SpanForward;
import org.apache.skywalking.oap.server.receiver.zipkin.SpanForwardService;
import org.apache.skywalking.oap.server.telemetry.TelemetryModule;
import org.apache.skywalking.oap.server.telemetry.api.CounterMetrics;
import org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics;
Expand Down Expand Up @@ -54,7 +54,7 @@ public class ActiveMQHandler implements TransportListener, MessageListener, Clos
private static final Logger log = LoggerFactory.getLogger(ActiveMQHandler.class.getName());

private final ZipkinActiveMQConfig config;
private final SpanForward spanForward;
private final SpanForwardService spanForward;
private final ActiveMQConnectionFactory connectionFactory;

static final CheckResult
Expand All @@ -70,11 +70,11 @@ public class ActiveMQHandler implements TransportListener, MessageListener, Clos

volatile CheckResult checkResult = CheckResult.OK;

public ActiveMQHandler(ZipkinActiveMQConfig config, SpanForward spanForward, ModuleManager moduleManager) {
public ActiveMQHandler(ZipkinActiveMQConfig config, SpanForwardService spanForward, ModuleManager moduleManager) {
this(config, createConnectionFactory(config), spanForward, moduleManager);
}

public ActiveMQHandler(ZipkinActiveMQConfig config, ActiveMQConnectionFactory connectionFactory, SpanForward spanForward, ModuleManager moduleManager) {
public ActiveMQHandler(ZipkinActiveMQConfig config, ActiveMQConnectionFactory connectionFactory, SpanForwardService spanForward, ModuleManager moduleManager) {
this.config = config;
this.spanForward = spanForward;
this.connectionFactory = connectionFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
package zipkin.server.receiver.zipkin.activemq;

import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.config.ConfigService;
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
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.receiver.zipkin.trace.SpanForward;
import zipkin.server.core.services.ZipkinConfigService;
import org.apache.skywalking.oap.server.receiver.zipkin.SpanForwardService;
import org.apache.skywalking.oap.server.receiver.zipkin.ZipkinReceiverModule;

public class ZipkinActiveMQProvider extends ModuleProvider {
private ZipkinActiveMQConfig moduleConfig;
private SpanForward spanForward;
private SpanForwardService spanForward;

@Override
public String name() {
Expand Down Expand Up @@ -59,8 +58,7 @@ public void prepare() throws ServiceNotProvidedException, ModuleStartException {

@Override
public void start() throws ServiceNotProvidedException, ModuleStartException {
final ConfigService service = getManager().find(CoreModule.NAME).provider().getService(ConfigService.class);
this.spanForward = new SpanForward(((ZipkinConfigService)service).toZipkinReceiverConfig(), getManager());
this.spanForward = getManager().find(ZipkinReceiverModule.NAME).provider().getService(SpanForwardService.class);
}

@Override
Expand Down
29 changes: 29 additions & 0 deletions zipkin-server/receiver-zipkin-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>zipkin-server-parent</artifactId>
<groupId>io.zipkin</groupId>
<version>2.24.4-SNAPSHOT</version>
</parent>

<artifactId>receiver-zipkin-core</artifactId>
<name>Zipkin Receiver Core</name>

<dependencies>
<dependency>
<groupId>io.zipkin</groupId>
<artifactId>zipkin-server-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>zipkin-receiver-plugin</artifactId>
<version>${skywalking.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright 2015-2023 The OpenZipkin Authors
*
* Licensed 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 zipkin.server.receiver.zipkin.core;

import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.receiver.zipkin.ZipkinReceiverConfig;
import org.apache.skywalking.oap.server.receiver.zipkin.trace.SpanForward;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class SpanForwardCore extends SpanForward {
private final ZipkinReceiverConfig config;
public SpanForwardCore(ZipkinReceiverConfig config, ModuleManager manager) {
super(config, manager);
this.config = config;
}

public Set<String> getTagAutocompleteKeys() {
return new HashSet<>(Arrays.asList(config.getSearchableTracesTags().split(Const.COMMA)));
}
}
Loading

0 comments on commit 3c23205

Please sign in to comment.