This repository has been archived by the owner on Jun 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add reporter plugins: kafka sarama (#33)
- Loading branch information
1 parent
2175b8c
commit ee26026
Showing
16 changed files
with
1,306 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
Oops, something went wrong.