Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

feat: add reporter plugins: kafka sarama #33

Merged
merged 23 commits into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ec38728
add reporter plugins: kafka sarama
matianjun1 Sep 23, 2021
bbc2212
add e2e test to sarama reporter
matianjun1 Sep 24, 2021
647e8a5
fix license and add sarama plugin_test
matianjun1 Sep 24, 2021
55336e1
rename sarama to kafkareporter
matianjun1 Sep 24, 2021
2218acd
fix kafkareporter docker-compose.yml context dir
matianjun1 Sep 26, 2021
ddc989f
remove GOPROXY in kafkareporter docker-compose.yml
matianjun1 Sep 26, 2021
ec6b651
fix docker-compose.yml in kafkareporter
matianjun1 Sep 26, 2021
b74aad6
fix go_kafka_reporter_plugin_test.yaml
matianjun1 Sep 27, 2021
cf23d19
fix ports in kafkareporter/test
matianjun1 Sep 27, 2021
1ce6f2f
fix go_kafka_reporter_plugin_test.yaml verify
matianjun1 Sep 27, 2021
481b66e
active kafka fetcher in go_kafka_reporter_plugin_test.yaml
matianjun1 Sep 27, 2021
942e2d2
remove healthy check in kafkareporter/test
matianjun1 Sep 27, 2021
ad53aeb
create topics in kafkareporter docker-compose.yml
matianjun1 Sep 29, 2021
e09d307
add EntrySpan to kafkareporter e2e test
matianjun1 Sep 29, 2021
8472e79
update trace-info-detail in kafkareporter
matianjun1 Sep 29, 2021
913fa3b
remove useless code in kafkareporter
matianjun1 Sep 29, 2021
1bd7926
update service-instance.yml in kafkareporter/test
matianjun1 Sep 30, 2021
e20e649
fix service-instance.yml in kafkareporter/test
matianjun1 Sep 30, 2021
17ba8e9
Update kafkareporter/test/expected/service-instance.yml
rainbend Sep 30, 2021
75712b7
fix serviceinstancename in kafkareporter/test
matianjun1 Oct 8, 2021
8cde33a
Merge branch 'master' into kafka_reporter
rainbend Oct 10, 2021
1ce91a1
replace range with contains
rainbend Oct 10, 2021
171c05c
replace range with contains
rainbend Oct 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/plugin_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
resty/test/go_resty_plugin_test.yaml: resty/**
kratos/test/go_kratos_plugin_test.yaml: kratos/**
sql/test/sql_plugin_test.yaml: sql/**
kafkareporter/test/go_kafka_reporter_plugin_test.yaml: kafkareporter/**

PluginsTest:
name: Plugin
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ The plugins of [go2sky](https://github.com/SkyAPM/go2sky)

## Plugin Summary

### Reporter Plugins

1. [kafkareporter](kafkareporter/README.md)

### Trace Plugins

1. [http server & client](http/README.md)
1. [gin](gin/README.md)
1. [gear](gear/README.md)
Expand All @@ -17,5 +22,6 @@ The plugins of [go2sky](https://github.com/SkyAPM/go2sky)
1. [sql](sql/README.md)

### Log Plugins

1. [logrus](logrus/README.md)
1. [zap](zap/README.md)
18 changes: 18 additions & 0 deletions kafkareporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Go2sky with kafka reporter

## Installation

```go
go get -u github.com/SkyAPM/go2sky-plugins/kafkareporter
```

## Usage

```go
r, err := kafkareporter.New([]string{"localhost:9092"})
if err != nil {
log.Fatalf("new kafka reporter error %v \n", err)
}
defer r.Close()
tracer, err := go2sky.NewTracer("example", go2sky.WithReporter(r))
```
18 changes: 18 additions & 0 deletions kafkareporter/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright 2021 SkyAPM org
//
// 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 sarama is a plugin that can be one kafka reporter as go2sky.Reporter.
package kafkareporter
10 changes: 10 additions & 0 deletions kafkareporter/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/SkyAPM/go2sky-plugins/kafkareporter

go 1.16

require (
github.com/Shopify/sarama v1.29.1
github.com/SkyAPM/go2sky v1.2.0
google.golang.org/protobuf v1.27.1
skywalking.apache.org/repo/goapi v0.0.0-20210820070710-e10b78bbf481
)
225 changes: 225 additions & 0 deletions kafkareporter/go.sum

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions kafkareporter/internal/tool/os_util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//
// Copyright 2021 SkyAPM org
//
// 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 tool

import (
"net"
"os"
"runtime"
"strconv"
)

func ProcessNo() string {
if os.Getpid() > 0 {
return strconv.Itoa(os.Getpid())
}
return ""
}

func HostName() string {
if hs, err := os.Hostname(); err == nil {
return hs
}
return "unknown"
}

func OSName() string {
return runtime.GOOS
}

func AllIPV4() (ipv4s []string) {
adders, err := net.InterfaceAddrs()
if err != nil {
return
}

for _, addr := range adders {
if ipNet, ok := addr.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
if ipNet.IP.To4() != nil {
ipv4 := ipNet.IP.String()
if ipv4 == "127.0.0.1" || ipv4 == "localhost" {
continue
}
ipv4s = append(ipv4s, ipv4)
}
}
}
return
}

func IPV4() string {
ipv4s := AllIPV4()
if len(ipv4s) > 0 {
return ipv4s[0]
}
return "no-hostname"
}
Loading