wu-sheng commented on a change in pull request #6183: URL: https://github.com/apache/skywalking/pull/6183#discussion_r569487933
########## File path: oap-server/analyzer/event-analyzer/src/main/java/org/apache/skywalking/oap/server/analyzer/event/listener/EventRecordAnalyzerListener.java ########## @@ -0,0 +1,79 @@ +/* + * 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.analyzer.event.listener; + +import com.google.gson.Gson; +import lombok.RequiredArgsConstructor; +import org.apache.skywalking.apm.network.event.v3.Source; +import org.apache.skywalking.oap.server.core.CoreModule; +import org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor; +import org.apache.skywalking.oap.server.core.config.NamingControl; +import org.apache.skywalking.oap.server.core.event.Event; +import org.apache.skywalking.oap.server.library.module.ModuleManager; + +/** + * EventRecordAnalyzerListener forwards the event data to the persistence layer with the query required conditions. + */ +@RequiredArgsConstructor +public class EventRecordAnalyzerListener implements EventAnalyzerListener { + private static final Gson GSON = new Gson(); + + private final NamingControl namingControl; + + private final Event event = new Event(); + + @Override + public void build() { + MetricsStreamProcessor.getInstance().in(event); + } + + @Override + public void parse(final org.apache.skywalking.apm.network.event.v3.Event e) { + event.setUuid(e.getUuid()); + + if (e.hasSource()) { + final Source source = e.getSource(); + event.setService(namingControl.formatServiceName(source.getService())); + event.setServiceInstance(namingControl.formatInstanceName(source.getServiceInstance())); + event.setEndpoint(namingControl.formatEndpointName(source.getService(), source.getEndpoint())); + } + + event.setName(e.getName()); + event.setType(e.getType().name()); + event.setMessage(e.getMessage()); + event.setParameters(GSON.toJson(e.getParametersMap())); + event.setStartTime(e.getStartTime()); + event.setEndTime(e.getEndTime()); Review comment: You never `#setTimeBucket`, I think you need to check manually when use ElasticSearch storage. As the time-series data, you need the unchanged `time bucket` as rowid(not entity id) to update the real record. This feature is hard to test in the e2e, as it would cross 2 days(a.k.a. 2 entities). Basically, you need to read the event base on event UUID, and merge it first, to make sure, the start timestamp exists as time bucket. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
