Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump google.golang.org/protobuf from 1.32.0 to 1.33.0 in /examples/multi-services #2

13 changes: 11 additions & 2 deletions .github/workflows/compatibility-test.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
name: compatibility-test

on:
push:
paths-ignore:
- "**.md"
- LICENCE
- CODEOWNERS
branches:
- master
pull_request_review:
types: [submitted]

jobs:
compatibility-test:
if: github.event.review.state == 'APPROVED'
# we trigger the job only when the PR is approved or the job is triggered by other events
# defined in the on section
if: github.event.review.state == 'APPROVED' || github.event_name != 'pull_request_review'
strategy:
matrix:
go-version: ["1.19", "1.20", "1.21"]
go-version: ["1.21", "1.22"]
os: [ubuntu-latest, macos-latest, windows-latest]
# GitHub Actions does not support arm* architectures on default
# runners. It is possible to acomplish this with a self-hosted runner
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name: ci
name: quick-test

on:
push:
pull_request:
paths-ignore:
- "**.md"
- LICENCE
- CODEOWNERS
branches:
- master
pull_request:

jobs:
test-build:
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/release-please-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
push:
branches:
- master

name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: go
draft-pull-request: "true"
labels: "be-autorelease-pending"
release-labels: "be-autorelease-tagged"


25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0](https://github.com/kitabisa/otelchi/compare/v1.0.0...v1.1.0) (2024-07-07)


### Features

* renamed to trace-id ([edd5dd9](https://github.com/kitabisa/otelchi/commit/edd5dd97f9db6840811618810e7ded3973be23ed))

## [Unreleased]

## [0.9.0] - 2024-07-06

### Changed

- `WithFilter` option now support multiple filter functions, just like in [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/v1.24.0/instrumentation/github.com/gorilla/mux/otelmux/config.go#L106-L110). ([#47])
- Upgrade `go.opentelemetry.io/otel`, `go.opentelemetry.io/otel/sdk`, & `go.opentelemetry.io/otel/trace` to `v1.28.0`. ([#49])
- Upgrade `github.com/go-chi/chi/v5` to `v5.1.0`. ([#49])
- Set the go versions for testing in both `Makefile` & `compatibility-test.yml` to `1.21` & `1.22`. ([#49])

### Removed

- Drop support for Go `<1.21`. ([#49])

## [0.8.0] - 2024-04-29

### ⚠️ Notice ⚠️
Expand Down Expand Up @@ -161,6 +181,8 @@ It contains instrumentation for trace and depends on:
- Example code for a basic usage.
- Apache-2.0 license.

[#49]: https://github.com/riandyrn/otelchi/pull/49
[#47]: https://github.com/riandyrn/otelchi/pull/47
[#43]: https://github.com/riandyrn/otelchi/pull/43
[#42]: https://github.com/riandyrn/otelchi/pull/42
[#41]: https://github.com/riandyrn/otelchi/pull/41
Expand All @@ -181,7 +203,8 @@ It contains instrumentation for trace and depends on:
[#2]: https://github.com/riandyrn/otelchi/pull/2
[#1]: https://github.com/riandyrn/otelchi/pull/1

[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.8.0...HEAD
[Unreleased]: https://github.com/riandyrn/otelchi/compare/v0.9.0...HEAD
[0.9.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.9.0
[0.8.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.8.0
[0.7.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.7.0
[0.6.0]: https://github.com/riandyrn/otelchi/releases/tag/v0.6.0
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: *

GO_VERSIONS="1.19 1.20 1.21"
GO_VERSIONS="1.21 1.22"

# This is the command that will be used to run the tests
go-test:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# otelchi

[![ci](https://github.com/riandyrn/otelchi/actions/workflows/ci.yaml/badge.svg)](https://github.com/riandyrn/otelchi/actions/workflows/ci.yaml)
[![compatibility-test](https://github.com/riandyrn/otelchi/actions/workflows/compatibility-test.yaml/badge.svg)](https://github.com/riandyrn/otelchi/actions/workflows/compatibility-test.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/riandyrn/otelchi)](https://goreportcard.com/report/github.com/riandyrn/otelchi)
[![Documentation](https://godoc.org/github.com/riandyrn/otelchi?status.svg)](https://pkg.go.dev/mod/github.com/riandyrn/otelchi)

OpenTelemetry instrumentation for [go-chi/chi](https://github.com/go-chi/chi).

Essentialy this is adaptation from [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/gorilla/mux/otelmux) but instead using `gorilla/mux`, we use `go-chi/chi`.
Essentially this is an adaptation from [otelmux](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation/github.com/gorilla/mux/otelmux) but instead of using `gorilla/mux`, we use `go-chi/chi`.

Currently it could only instrument traces.
Currently, this library can only instrument traces.

Contributions are welcomed!

Expand All @@ -24,4 +24,4 @@ See [examples](./examples) for details.

## Why Port This?

I was planning to make this project as part of Open Telemetry Go instrumentation project. However based on [this comment](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/986#issuecomment-941280855) they no longer accept new instrumentation. This is why I maintain this project here.
I was planning to make this project as part of the Open Telemetry Go instrumentation project. However, based on [this comment](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/986#issuecomment-941280855) they no longer accept new instrumentation. This is why I maintain this project here.
19 changes: 13 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type config struct {
Propagators propagation.TextMapPropagator
ChiRoutes chi.Routes
RequestMethodInSpanName bool
Filter func(r *http.Request) bool
Filters []Filter
TraceResponseHeaderKey string
PublicEndpointFn func(r *http.Request) bool
}
Expand All @@ -32,6 +32,10 @@ func (o optionFunc) apply(c *config) {
o(c)
}

// Filter is a predicate used to determine whether a given http.request should
// be traced. A Filter must return true if the request should be traced.
type Filter func(*http.Request) bool

// WithPropagators specifies propagators to use for extracting
// information from the HTTP requests. If none are specified, global
// ones will be used.
Expand Down Expand Up @@ -76,12 +80,15 @@ func WithRequestMethodInSpanName(isActive bool) Option {
})
}

// WithFilter is used for filtering request that should not be traced.
// This is useful for filtering health check request, etc.
// A Filter must return true if the request should be traced.
func WithFilter(filter func(r *http.Request) bool) Option {
// WithFilter adds a filter to the list of filters used by the handler.
// If any filter indicates to exclude a request then the request will not be
// traced. All filters must allow a request to be traced for a Span to be created.
// If no filters are provided then all requests are traced.
// Filters will be invoked for each processed request, it is advised to make them
// simple and fast.
func WithFilter(filter Filter) Option {
return optionFunc(func(cfg *config) {
cfg.Filter = filter
cfg.Filters = append(cfg.Filters, filter)
})
}

Expand Down
4 changes: 2 additions & 2 deletions examples/basic/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.18
FROM golang:1.21-alpine3.20

WORKDIR /go/src/github.com/riandyrn/otelchi
COPY . .
Expand All @@ -7,4 +7,4 @@ WORKDIR /go/src/github.com/riandyrn/otelchi/examples/basic
RUN go mod download -x
RUN go build -o server

ENTRYPOINT ["./server"]
ENTRYPOINT ["./server"]
11 changes: 4 additions & 7 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# go-chi/chi instrumentation example

An HTTP server using go-chi/chi and instrumentation. The server has a
`/users/{id:[0-9]+}` endpoint. The server generates span information to
`stdout`.
An HTTP server using go-chi/chi and instrumentation. The server has a `/users/{id:[0-9]+}` endpoint. The server generates span information to `stdout`.

These instructions expect you have
[docker-compose](https://docs.docker.com/compose/) installed.
These instructions expect you to have [docker-compose](https://docs.docker.com/compose/) installed.

Bring up the `mux-server` and `mux-client` services to run the
example:
Expand All @@ -14,8 +11,8 @@ example:
docker-compose up --detach mux-server mux-client
```

The `mux-client` service sends just one HTTP request to `mux-server`
and then exits. View the span generated by `mux-server` in the logs:
The `mux-client` service sends just one HTTP request to the `mux-server`
and then exits. View the span generated by the `mux-server` in the logs:

```sh
docker-compose logs mux-server
Expand Down
21 changes: 11 additions & 10 deletions examples/basic/go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
module github.com/riandyrn/otelchi/examples/basic

go 1.19
go 1.21

replace github.com/riandyrn/otelchi => ../../

require (
github.com/go-chi/chi/v5 v5.0.12
github.com/riandyrn/otelchi v0.6.0
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0
go.opentelemetry.io/otel/sdk v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
github.com/go-chi/chi/v5 v5.1.0
github.com/riandyrn/otelchi v0.9.0
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0
go.opentelemetry.io/otel/sdk v1.28.0
go.opentelemetry.io/otel/trace v1.28.0
)

require (
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
golang.org/x/sys v0.17.0 // indirect
github.com/google/uuid v1.6.0 // indirect
go.opentelemetry.io/otel/metric v1.28.0 // indirect
golang.org/x/sys v0.21.0 // indirect
)
41 changes: 24 additions & 17 deletions examples/basic/go.sum
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 h1:sEL90JjOO/4yhquXl5zTAkLLsZ5+MycAgX99SDsxGc8=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0/go.mod h1:oCslUcizYdpKYyS9e8srZEqM6BB8fq41VJBjLAE6z1w=
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo=
go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0 h1:EVSnY9JbEEW92bEkIYOVMw4q1WJxIAGoFTrtYOzWuRQ=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.28.0/go.mod h1:Ea1N1QQryNXpCD0I1fdLibBAIpQuBkznMmkdKrapk1Y=
go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q=
go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s=
go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE=
go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg=
go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g=
go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
10 changes: 5 additions & 5 deletions examples/multi-services/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Multi Services Example

This is simple example on how instrumenting multiple services.
This is a simple example of how instrumenting multiple services.

There are 2 services in this example:

- `front-svc` => the front service receiving request from client
- `back-svc` => the service that being called by `front-svc` (hence named `back`)
- `front-svc` => the front service receiving requests from the client
- `back-svc` => the service that is being called by `front-svc` (hence named `back`)

![Architecture Diagram](architecture.svg)

Expand All @@ -19,7 +19,7 @@ Make sure to have Docker & Docker Compose installed in your system. After that r
> make run
```

If the command run successfully (it will take a moment), you will see something like this in the terminal:
If the command runs successfully (it will take a moment), you will see something like this in the terminal:

```
back-svc_1 | 2022/07/23 01:49:29 back service is listening on :8091
Expand All @@ -30,4 +30,4 @@ multi-services_client_1 exited with code 0

Open your browser and access `http://localhost:16686` to access the Jaeger UI.

You should see some traces available already in the UI.
You should see some traces available already in the UI.
4 changes: 2 additions & 2 deletions examples/multi-services/back-svc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.18
FROM golang:1.21-alpine3.20
WORKDIR /go/src/github.com/riandyrn/otelchi

RUN apk --no-cache add curl
Expand All @@ -10,4 +10,4 @@ RUN go mod download -x
WORKDIR /go/src/github.com/riandyrn/otelchi/examples/multi-services/back-svc
RUN go build -o server

ENTRYPOINT ["./server"]
ENTRYPOINT ["./server"]
4 changes: 2 additions & 2 deletions examples/multi-services/front-svc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19-alpine3.18
FROM golang:1.21-alpine3.20
WORKDIR /go/src/github.com/riandyrn/otelchi

RUN apk --no-cache add curl
Expand All @@ -10,4 +10,4 @@ RUN go mod download -x
WORKDIR /go/src/github.com/riandyrn/otelchi/examples/multi-services/front-svc
RUN go build -o server

ENTRYPOINT ["./server"]
ENTRYPOINT ["./server"]
Loading