Skip to content

Commit 8f77f65

Browse files
y1yang0NameHaibinZhang
authored andcommitted
[to #58094268] sync upstream
- feat: regexp-based ReceiverType (#391) - feat: new CallContext.{GetFuncName, GetPackageName} APIs #392 Link: https://code.alibaba-inc.com/go-agent/otel-go-auto-instrumentation/codereview/21087434 * [to #58094268] sync upstream
1 parent 3034490 commit 8f77f65

32 files changed

+626
-232
lines changed

Diff for: README.md

+55-28
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
![](docs/anim-logo.svg)
22

3-
[![](https://shields.io/badge/Docs-English-blue?logo=Read%20The%20Docs)](./docs/README.md)
4-
[![](https://shields.io/badge/Readme-中文-blue?logo=Read%20The%20Docs)](./docs/README_CN.md)
5-
[![codecov](https://codecov.io/gh/alibaba/opentelemetry-go-auto-instrumentation/branch/main/graph/badge.svg)](https://codecov.io/gh/alibaba/opentelemetry-go-auto-instrumentation)
6-
[![](https://shields.io/badge/Commercial-Aliyun-orange?logo=alibabacloud)](https://help.aliyun.com/zh/arms/application-monitoring/getting-started/monitoring-the-golang-applications)
3+
[![](https://shields.io/badge/Docs-English-blue?logo=Read%20The%20Docs)](./README.md)  
4+
[![](https://shields.io/badge/Readme-中文-blue?logo=Read%20The%20Docs)](./docs/README_CN.md)  
5+
[![codecov](https://codecov.io/gh/alibaba/opentelemetry-go-auto-instrumentation/branch/main/graph/badge.svg)](https://codecov.io/gh/alibaba/opentelemetry-go-auto-instrumentation)  
6+
[![](https://shields.io/badge/Aliyun-Commercial-orange?logo=alibabacloud)](https://help.aliyun.com/zh/arms/application-monitoring/getting-started/monitoring-the-golang-applications)  
7+
[![](https://img.shields.io/badge/New-Adopter-orange?logo=githubsponsors)](https://github.com/alibaba/opentelemetry-go-auto-instrumentation/issues/225)  
78

89
This project provides an automatic solution for Golang applications that want to
910
leverage OpenTelemetry to enable effective observability. No code changes are
@@ -13,7 +14,7 @@ time. Simply adding `otel` prefix to `go build` to get started :rocket:
1314
# Installation
1415

1516
### Install via Bash
16-
For **Linux and MacOS** users, install the tool by running the following command
17+
For Linux and MacOS users, install the tool by running the following command
1718
```bash
1819
$ sudo curl -fsSL https://cdn.jsdelivr.net/gh/alibaba/opentelemetry-go-auto-instrumentation@main/install.sh | sudo bash
1920
```
@@ -36,6 +37,11 @@ $ make install # build and install
3637

3738
# Getting Started
3839

40+
Check the version by running:
41+
```bash
42+
$ otel version
43+
```
44+
3945
The configuration for the tool can be set by the following command:
4046

4147
```bash
@@ -45,7 +51,7 @@ $ otel set -rule=custom.json # use default and custom rules
4551
$ otel set -debug -verbose -rule=custom.json # set multiple configs
4652
```
4753

48-
Normally, you don't need to set any configurations. Just adding `otel` prefix to `go build` to build your project:
54+
**Normally, you don't need to set any configurations. Just adding `otel` prefix to `go build` to build your project:**
4955

5056
```bash
5157
$ otel go build
@@ -63,26 +69,44 @@ The detailed usage of `otel` tool can be found in [**Usage**](./docs/usage.md).
6369
> at [GitHub Issues](https://github.com/alibaba/opentelemetry-go-auto-instrumentation/issues)
6470
> to help us enhance this project.
6571
72+
# Examples
73+
74+
You can also explore [**these examples**](./example/) to get hands-on experience. They are designed to construct a full picture of how to use the tool in different scenarios.
75+
76+
Also there are several [**documents**](./docs) that you may find useful for either understanding the project or contributing to it.
77+
6678
# Supported Libraries
6779

68-
| Plugin Name | Repository Url | Min Supported Version | Max Supported Version |
69-
| ------------ | ------------------------------------------ | --------------------- | --------------------- |
70-
| database/sql | https://pkg.go.dev/database/sql | - | - |
71-
| echo | https://github.com/labstack/echo | v4.0.0 | v4.12.0 |
72-
| fasthttp | https://github.com/valyala/fasthttp | v1.45.0 | v1.57.0 |
73-
| gin | https://github.com/gin-gonic/gin | v1.7.0 | v1.10.0 |
74-
| go-redis | https://github.com/redis/go-redis | v9.0.5 | v9.5.1 |
75-
| gorm | https://github.com/go-gorm/gorm | v1.22.0 | v1.25.9 |
76-
| grpc | https://google.golang.org/grpc | v1.44.0 | v1.67.0 |
77-
| hertz | https://github.com/cloudwego/hertz | v0.8.0 | v0.9.2 |
78-
| kratos | https://github.com/go-kratos/kratos | v2.6.3 | v2.8.2 |
79-
| log | https://pkg.go.dev/log | - | - |
80-
| logrus | https://github.com/sirupsen/logrus | v1.5.0 | v1.9.3 |
81-
| mongodb | https://github.com/mongodb/mongo-go-driver | v1.11.1 | v1.15.2 |
82-
| mux | https://github.com/gorilla/mux | v1.3.0 | v1.8.1 |
83-
| net/http | https://pkg.go.dev/net/http | - | - |
84-
| slog | https://pkg.go.dev/log/slog | - | - |
85-
| zap | https://github.com/uber-go/zap | v1.20.0 | v1.27.0 |
80+
| Plugin Name | Repository Url | Min Supported Version | Max Supported Version |
81+
|---------------| ---------------------------------------------- |-----------------------|-----------------------|
82+
| database/sql | https://pkg.go.dev/database/sql | - | - |
83+
| echo | https://github.com/labstack/echo | v4.0.0 | v4.12.0 |
84+
| elasticsearch | https://github.com/elastic/go-elasticsearch | v8.4.0 | v8.15.0 |
85+
| fasthttp | https://github.com/valyala/fasthttp | v1.45.0 | v1.59.0 |
86+
| fiber | https://github.com/gofiber/fiber | v2.43.0 | v2.52.6 |
87+
| gin | https://github.com/gin-gonic/gin | v1.7.0 | v1.10.0 |
88+
| go-redis | https://github.com/redis/go-redis | v9.0.5 | v9.5.1 |
89+
| go-redis v8 | https://github.com/redis/go-redis | v8.11.0 | v8.11.5 |
90+
| gomicro | https://github.com/micro/go-micro | v5.0.0 | v5.3.0 |
91+
| gorestful | https://github.com/emicklei/go-restful | v3.7.0 | v3.12.1 |
92+
| gorm | https://github.com/go-gorm/gorm | v1.22.0 | v1.25.9 |
93+
| grpc | https://google.golang.org/grpc | v1.44.0 | v1.71.0 |
94+
| hertz | https://github.com/cloudwego/hertz | v0.8.0 | v0.9.2 |
95+
| iris | https://github.com/kataras/iris | v12.2.0 | v12.2.11 |
96+
| kitex | https://github.com/cloudwego/kitex | v0.5.1 | v0.11.3 |
97+
| kratos | https://github.com/go-kratos/kratos | v2.6.3 | v2.8.4 |
98+
| langchaingo | https://github.com/tmc/langchaingo | v0.1.13 | v0.1.13 |
99+
| log | https://pkg.go.dev/log | - | - |
100+
| logrus | https://github.com/sirupsen/logrus | v1.5.0 | v1.9.3 |
101+
| mongodb | https://github.com/mongodb/mongo-go-driver | v1.11.1 | v1.15.1 |
102+
| mux | https://github.com/gorilla/mux | v1.3.0 | v1.8.1 |
103+
| nacos | https://github.com/nacos-group/nacos-sdk-go/v2 | v2.0.0 | v2.2.7 |
104+
| net/http | https://pkg.go.dev/net/http | - | - |
105+
| redigo | https://github.com/gomodule/redigo | v1.9.0 | v1.9.2 |
106+
| slog | https://pkg.go.dev/log/slog | - | - |
107+
| trpc-go | https://github.com/trpc-group/trpc-go | v1.0.0 | v1.0.3 |
108+
| zap | https://github.com/uber-go/zap | v1.20.0 | v1.27.0 |
109+
| zerolog | https://github.com/rs/zerolog | v1.10.0 | v1.33.0 |
86110

87111
We are progressively open-sourcing the libraries we have supported, and your contributions are very welcome 💖!
88112

@@ -99,9 +123,12 @@ to engage with us.
99123

100124
<img src="docs/dingtalk.png" height="200">
101125

102-
# Adopters
126+
We would thankfully acknowledge the following contributors for their valuable contributions to this project:
127+
128+
<a href="https://github.com/alibaba/opentelemetry-go-auto-instrumentation/graphs/contributors">
129+
<img alt="contributors" src="https://contrib.rocks/image?repo=alibaba/opentelemetry-go-auto-instrumentation" height="100"/>
130+
</a>
103131

104-
These are only part of the companies using this project, for reference only. If you are using this project, please [add your company here](https://github.com/alibaba/opentelemetry-go-auto-instrumentation/issues/225) to tell us your scenario to make this project better.
132+
The star history of this project is as follows, which shows the growth of this project over time:
105133

106-
- <img src="./docs/alibaba.png" width="80">
107-
- <img src="./docs/aliyun.png" width="100">
134+
<img src="https://api.star-history.com/svg?repos=alibaba/opentelemetry-go-auto-instrumentation&type=Date" height="200">

Diff for: armstest/errors_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func TestRunErrors(t *testing.T) {
5656
}
5757

5858
// Test for generic hook
59+
maxFunc := 7
5960
re = regexp.MustCompile(".*xian.*")
6061
matches = re.FindAllString(stderr, -1)
6162
if len(matches) != 4 { // f1 + f2 + f4 + init
@@ -66,4 +67,24 @@ func TestRunErrors(t *testing.T) {
6667
if len(matches) != 2 {
6768
t.Fatalf("expecting 2 matches")
6869
}
70+
re = regexp.MustCompile(".*zhejiang.*") // match all funcs(including init)
71+
matches = re.FindAllString(stderr, -1)
72+
if len(matches) != maxFunc {
73+
t.Fatalf("expecting full matches")
74+
}
75+
re = regexp.MustCompile(".*beijing.*") // f3 + f5
76+
matches = re.FindAllString(stderr, -1)
77+
if len(matches) != 2 {
78+
t.Fatalf("expecting 2 matches")
79+
}
80+
re = regexp.MustCompile(".*entering.*") // match all funcs(including init)
81+
matches = re.FindAllString(stderr, -1)
82+
if len(matches) != maxFunc {
83+
t.Fatalf("expecting full matches")
84+
}
85+
re = regexp.MustCompile(".*within.*") // match all funcs(including init)
86+
matches = re.FindAllString(stderr, -1)
87+
if len(matches) != maxFunc {
88+
t.Fatalf("expecting full matches")
89+
}
6990
}

Diff for: armstest/errorstest/all/match.go

+8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ func f1() {}
1818
func f2(a string) {}
1919

2020
type recv int
21+
type recv2 int
22+
type recx int
2123

2224
func (r *recv) f3() {}
2325

2426
func f4() int { return 7632 }
2527

28+
func (r *recv2) f5() int { return 7632 }
29+
30+
func (r *recx) f6() int { return 7632 }
31+
2632
func init() {
2733
f1()
2834
f2("shanxi")
2935
new(recv).f3()
3036
f4()
37+
new(recv2).f5()
38+
new(recx).f6()
3139
}

Diff for: docs/README.md

-13
This file was deleted.

0 commit comments

Comments
 (0)