Skip to content

Commit

Permalink
doc: added doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
moonming committed Jul 26, 2019
1 parent cf8e40f commit 989d941
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 2 deletions.
2 changes: 2 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ Redistributions in binary form must reproduce the above copyright notice, this l

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

%%%%%%%%%

opentracing-openresty

https://github.com/iresty/opentracing-openresty
Expand Down
92 changes: 92 additions & 0 deletions doc/plugins/zipkin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Summary
- [**Name**](#name)
- [**Attributes**](#attributes)
- [**How To Enable**](#how-to-enable)
- [**Test Plugin**](#test-plugin)
- [**Disable Plugin**](#disable-plugin)


## Name

`Zipkin` is a OpenTracing plugin.

It's also works with `Apache SkyWalking`, which is support Zipkin v1/v2 format.

## Attributes

* `endpoint`: the http endpoint of Ziplin, for example: `http://127.0.0.1:9411/api/v2/spans`.

* `sample_ratio`: the ratio of sample, the default value is 0.001, the minimum is 0.00001, the maximum is 1.

## How To Enable

Here's an example, enable the zipkin plugin on the specified route:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -X PUT -d '
{
"methods": ["GET"],
"uri": "/index.html",
"plugins": {
"zipkin": {
"endpoint": "http://127.0.0.1:9411/api/v2/spans",
"sample_ratio": 1
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"39.97.63.215:80": 1
}
}
}'
```

## Test Plugin

### run the Zipkin instance

e.g. using docker:

```
sudo docker run -d -p 9411:9411 openzipkin/zipkin
```

Here is a test example:

```shell
$ curl http://127.0.0.1:9080/index.html
HTTP/1.1 200 OK
...
```

Then you can use a browser to access the webUI of Zipkin:

```
http://127.0.0.1:9411/zipkin
```

## Disable Plugin

When you want to disable the zipkin plugin, it is very simple,
you can delete the corresponding json configuration in the plugin configuration,
no need to restart the service, it will take effect immediately:

```shell
$ curl http://127.0.0.1:2379/v2/keys/apisix/routes/1 -X PUT -d value='
{
"methods": ["GET"],
"uri": "/index.html",
"id": 1,
"plugins": {
},
"upstream": {
"type": "roundrobin",
"nodes": {
"39.97.63.215:80": 1
}
}
}'
```

The zipkin plugin has been disabled now. It works for other plugins.
2 changes: 1 addition & 1 deletion lua/apisix/core/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

local ngx = ngx
local get_headers = ngx.req.get_headers

local tonumber = tonumber

local _M = {version = 0.1}

Expand Down
1 change: 1 addition & 0 deletions lua/apisix/core/response.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local ngx_exit = ngx.exit
local insert_tab = table.insert
local concat_tab = table.concat
local str_sub = string.sub
local tonumber = tonumber

local _M = {version = 0.1}

Expand Down
2 changes: 2 additions & 0 deletions lua/apisix/plugins/zipkin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local new_tracer = require("opentracing.tracer").new
local zipkin_codec = require("apisix.plugins.zipkin.codec")
local new_random_sampler = require("apisix.plugins.zipkin.random_sampler").new
local new_reporter = require("apisix.plugins.zipkin.reporter").new
local ngx = ngx
local pairs = pairs

local plugin_name = "zipkin"

Expand Down
2 changes: 1 addition & 1 deletion t/admin/plugins.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ __DATA__
--- request
GET /apisix/admin/plugins/list
--- response_body_like eval
qr/example-plugin","limit-req","limit-count","key-auth","prometheus","limit-conn","node-status"/
qr/\["example-plugin","limit-req","limit-count","limit-conn","key-auth","prometheus","node-status","jwt-auth","zipkin"\]/
--- no_error_log
[error]

0 comments on commit 989d941

Please sign in to comment.