Skip to content

Commit 0abe068

Browse files
123liuzimingy1yang0
authored andcommitted
feat: modularized rules
Co-authored-by: 牧思 <[email protected]>
1 parent 849cf56 commit 0abe068

File tree

246 files changed

+4798
-3191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+4798
-3191
lines changed

.github/workflows/go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Build
3535
run: make build
3636
- name: InstUt
37-
run: go test -v ./pkg/... -coverprofile=coverage.txt -covermode=atomic
37+
run: go test -v $(go list ./...|grep pkg/ |grep -v rules) -coverprofile=coverage.txt -covermode=atomic
3838
- name: Coverage
3939
run: bash <(curl -s https://codecov.io/bash)
4040
- name: Test

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ otelbuild-*
77
.otel-build
88
vendor
99
test/errors-test/errors-test
10+
test/errorstest/errorstest
1011
test/helloworld/helloworld
1112
test/httpclient/httpclient
1213
test/flags/flags
@@ -19,4 +20,5 @@ otel_rules
1920
otel_pkgdep
2021
opentelemetry-go-auto-instrumentation
2122
*_cache
22-
example/demo/demo
23+
example/demo/demo
24+
test/zap/test_zap

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ XVERSION := -X=$(MOD_NAME)/tool/shared.TheVersion=$(VERSION)
3232
XNAME := -X=$(MOD_NAME)/tool/shared.TheName=$(TOOL_REL_NAME)
3333
STRIP_DEBUG := -s -w
3434
LDFLAGS := $(XVERSION) $(XNAME) $(STRIP_DEBUG)
35-
BUILD_CMD = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -a -ldflags="$(LDFLAGS)" -o $(3)
35+
BUILD_CMD = CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -ldflags="$(LDFLAGS)" -o $(3)
3636

3737
OUTPUT_BASE = $(TOOL_REL_NAME)
3838
OUTPUT_DARWIN_AMD64 = $(OUTPUT_BASE)-darwin-amd64

README.md

+17-11
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ time. Simply replace `go build` with `otelbuild` to get started.
1212

1313
# Installation
1414

15-
#### Install via Bash
15+
### Install via Bash
1616
For **Linux and MacOS** users, install the tool by running the following command :rocket:
1717
```bash
18-
$ sudo curl -fsSL https://raw.githubusercontent.com/alibaba/opentelemetry-go-auto-instrumentation/main/install.sh | sudo bash
18+
$ sudo curl -fsSL https://cdn.jsdelivr.net/gh/alibaba/opentelemetry-go-auto-instrumentation@main/install.sh | sudo bash
1919
```
2020
It will be installed in `/usr/local/bin/otelbuild` by default.
2121

22-
#### Precompiled Binary
22+
### Precompiled Binary
2323

2424
Please download the latest precompiled release version from
2525
the [Release](https://github.com/alibaba/opentelemetry-go-auto-instrumentation/releases)
2626
page.
2727

28-
#### Build From Source
28+
### Build From Source
2929

3030
Checkout the source code and build the tool by running the following command:
3131

@@ -52,25 +52,26 @@ $ ./otelbuild -- -gcflags="-m" cmd/app
5252
The arguments for the tool itself should be placed before the `--` delimiter:
5353

5454
```bash
55-
$ ./otelbuild -help # print help doc
56-
$ ./otelbuild -debuglog # print log to file
55+
$ ./otelbuild -help # print help doc
56+
$ ./otelbuild -debug # enable debug mode
5757
$ ./otelbuild -verbose -- -gcflags="-m" cmd/app # print verbose log
58+
$ ./otelbuild -rule=custom.json # use custom rule
5859
```
5960

6061
You can also explore [**these examples**](./example/) to get hands-on experience.
6162

62-
Also there are several [**documents**](./docs) that you may find useful
63+
Also there are several [**documents**](./docs) that you may find useful for either understanding the project or contributing to it.
6364

6465
> [!NOTE]
65-
> If you find any compilation failures during the process, it's likely a bug.
66+
> If you find any compilation failures while `go build` works, it's likely a bug.
6667
> Please feel free to file a bug
6768
> at [GitHub Issues](https://github.com/alibaba/opentelemetry-go-auto-instrumentation/issues)
6869
> to help us enhance this project.
6970
7071
# Supported Libraries
7172

7273
| Plugin Name | Repository Url | Min Supported Version | Max Supported Version |
73-
|--------------|--------------------------------------------|-----------------------|-----------------------|
74+
| ------------ | ------------------------------------------ | --------------------- | --------------------- |
7475
| database/sql | https://pkg.go.dev/database/sql | - | - |
7576
| echo | https://github.com/labstack/echo | v4.0.0 | v4.12.0 |
7677
| fasthttp | https://github.com/valyala/fasthttp | v1.45.0 | v1.55.0 |
@@ -90,8 +91,13 @@ Also there are several [**documents**](./docs) that you may find useful
9091

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

93-
Please refer to [this document](./docs/how-to-add-a-new-rule.md) for guidance on how to write instrumentation
94-
code for new frameworks.
94+
> [!TIP]
95+
> The framework you expected is not in the support list? Don't worry, we support extensible custom rules.
96+
> You can easily write code to inject into
97+
> any frameworks/libraries that are not officially supported.
98+
>
99+
> Please refer to [this document](./docs/how-to-add-a-new-rule.md) for guidance on how to write instrumentation
100+
> code for new frameworks.
95101
96102
# Community
97103

api/ruledef.go

-234
This file was deleted.

docs/how-it-works.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The `clientOnEnter` function performs the actual monitoring tasks:
111111

112112
```go
113113
// == otel_rule_http59729.go
114-
func clientOnEnter(call *http.CallContext, t *http.Transport, req *http.Request) {
114+
func clientOnEnter(call api.CallContext, t *http.Transport, req *http.Request) {
115115
...
116116
var tracer trace.Tracer
117117
if span := trace.SpanFromContext(req.Context()); span.SpanContext().IsValid() {

0 commit comments

Comments
 (0)