zbw911 commented on code in PR #128:
URL: 
https://github.com/apache/skywalking-satellite/pull/128#discussion_r1148498585


##########
plugins/forwarder/kafka/nativetracing/forwarder.go:
##########
@@ -0,0 +1,121 @@
+// Licensed to 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. Apache Software Foundation (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 nativetracing
+
+import (
+       "fmt"
+       "reflect"
+
+       "github.com/Shopify/sarama"
+       "google.golang.org/protobuf/proto"
+
+       "github.com/apache/skywalking-satellite/internal/pkg/config"
+       "github.com/apache/skywalking-satellite/internal/pkg/log"
+       "github.com/apache/skywalking-satellite/internal/satellite/event"
+
+       v3 "skywalking.apache.org/repo/goapi/collect/language/agent/v3"
+       v1 "skywalking.apache.org/repo/goapi/satellite/data/v1"
+)
+
+const (
+       Name     = "native-tracing-kafka-forwarder"
+       ShowName = "Native Tracing Kafka Forwarder"
+)
+
+type Forwarder struct {
+       config.CommonFields
+       Topic    string `mapstructure:"topic"` // The forwarder topic.
+       producer sarama.SyncProducer
+}
+
+func (f *Forwarder) Name() string {
+       return Name
+}
+
+func (f *Forwarder) ShowName() string {
+       return ShowName
+}
+
+func (f *Forwarder) Description() string {
+       return "This is a synchronization Kafka forwarder with the SkyWalking 
native log protocol."
+}
+
+func (f *Forwarder) DefaultConfig() string {
+       return `
+# The remote topic. 
+topic: "skywalking-segments"
+`
+}
+
+func (f *Forwarder) Prepare(connection interface{}) error {
+       client, ok := connection.(sarama.Client)
+       if !ok {
+               return fmt.Errorf("the %s only accepts a grpc client, but 
received a %s",
+                       f.Name(), reflect.TypeOf(connection).String())
+       }
+       producer, err := sarama.NewSyncProducerFromClient(client)
+       if err != nil {
+               return err
+       }
+       f.producer = producer
+       return nil
+}
+
+func (f *Forwarder) Forward(batch event.BatchEvents) error {
+       var message []*sarama.ProducerMessage
+       for _, e := range batch {
+               switch data := e.GetData().(type) {
+               case *v1.SniffData_Segment:
+                       segmentObject := &v3.SegmentObject{}
+                       err := proto.Unmarshal(data.Segment, segmentObject)
+                       if err != nil {
+                               return err
+                       }
+
+                       message = append(message, &sarama.ProducerMessage{
+                               Topic: f.Topic,
+                               Key:   
sarama.StringEncoder(segmentObject.GetTraceSegmentId()),
+                               Value: sarama.ByteEncoder(data.Segment),
+                       })
+               case *v1.SniffData_SpanAttachedEvent:
+                       // SniffData_SpanAttachedEvent is from ebpf agent, 
skywalking-rover project.
+                       // You could find it here,
+                       // 
https://github.com/apache/skywalking-data-collect-protocol/blob/0da9c8b3e111fb51c9f8854cae16d4519462ecfe
+                       // /language-agent/Tracing.proto#L244
+                       // ref: 
https://github.com/apache/skywalking-satellite/pull/128#discussion_r1136909393
+                       log.Logger.WithField("pipe", 
f.PipeName).Warnf("native-tracing-kafka-forwarder " +

Review Comment:
   @mrproliu  Help!!!
   I've been trying to do e2e testing for several days now, trying various 
methods such as using swctl to query with a single sentence, and also modifying 
service-instance.yml to adapt to the return value, but when it comes to the 
process list step, it always returns [].
   
   I have not been able to successfully execute the test, and the whole process 
has been stuck in this part, making progress extremely difficult.
   
   I hope you can help me figure out how to make this part run smoothly, and 
what kind of environment or tools I need to use. I have tried almost all the 
methods that I can try now.
   
   My usage is Docker Desktop, and the instance is running normally from 
Containers.
   
   Below is the original error message from the main branch:
   ----------
   ```
     ERROR failed to verify the output: swctl --display yaml 
--base-url=http://${oap_host}:${oap_12800}/graphql instance list 
--service-name=service, error:
   mismatch (-want +got):
     []interface{}{
   -       map[interface{}]interface{}{
   -               string("attributes"):   []interface{}{},
   -               string("id"):           string("c2VydmljZQ==.1_dGVzdA=="),
   -               string("instanceuuid"): 
string("c2VydmljZQ==.1_NTFjOGZmOTBjYmE2MTFlZGEwYjIwMjQyYWMxOTAwMDRAMTcyLjI1LjAuNA=="),
   -               string("language"):     string("UNKNOWN"),
   -               string("name"):         string("test"),
   -       },
   +       map[interface{}]interface{}{
   +               string("attributes"): []interface{}{
   +                       map[interface{}]interface{}{string("name"): 
string("Process No."), string("value"): string("1")},
   +                       map[interface{}]interface{}{string("name"): 
string("hostname"), string("value"): string("e7786ddc74c7")},
   +                       map[interface{}]interface{}{string("name"): 
string("OS Name"), string("value"): string("linux")},
   +                       map[interface{}]interface{}{string("name"): 
string("ipv4s"), string("value"): string("172.25.0.4")},
   +               },
   +               string("id"):           
string("c2VydmljZQ==.1_NTFjOGZmOTBjYmE2MTFlZGEwYjIwMjQyYWMxOTAwMDRAMTcyLjI1LjAuNA=="),
   +               string("instanceuuid"): 
string("c2VydmljZQ==.1_NTFjOGZmOTBjYmE2MTFlZGEwYjIwMjQyYWMxOTAwMDRAMTcyLjI1LjAuNA=="),
   +               string("language"):     string("GO"),
   +               string("name"):         
string("[email protected]"),
   +       },
     }
   ```
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to