Skip to content

Commit

Permalink
Merge pull request #9 from eko/observability-tracing
Browse files Browse the repository at this point in the history
Observability: Added OpenTelemetry tracing to Jaeger, Zipkin and OTLP
  • Loading branch information
eko authored Jan 22, 2023
2 parents cbe175f + 6806cf1 commit f221659
Show file tree
Hide file tree
Showing 1,087 changed files with 443,899 additions and 2,347 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ You can use both Role-Based Acccess Control (RBAC) and Attribute-Based Access Co

🔐 Single Sign-On: Use your enterprise SSO to log into the web UI, using OpenID Connect

🕵️‍♂️ Observability: Retrieve metrics and tracing data into your prefered tools

## How it works?

Authorization is simple: a `principal` wants to make an `action` on a `resource`. That's it.
Expand Down
7 changes: 7 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ Here are the available configuration options available as environment variable:
| APP_AUDIT_FLUSH_DELAY | `3s` | Delay in which audit logs will be batch into database |
| APP_AUDIT_RESOURCE_KIND_REGEX | `.*` | Filter which resource kind will be added on audit logs |
| APP_METRICS_ENABLED | `false` | Enable Prometheus metrics observability (available under `/v1/metrics` URL) |
| APP_TRACE_ENABLED | `false` | Enable tracing observability using OpenTelemetry |
| APP_TRACE_EXPORTER | `jaeger` | Exporter you want to use. Could be `jaeger`, `zipkin` or `otlpgrpc` |
| APP_TRACE_JAEGER_URL | `http://localhost:14268/api/traces` | Jaeger API URL to be used |
| APP_TRACE_OTLP_DIAL_TIMEOUT | `3s` | OTLP gRPC exporter dial timeout value |
| APP_TRACE_OTLP_ENDPOINT | `localhost:30080` | OTLP gRPC endpoint value |
| APP_TRACE_SAMPLE_RATIO | `1.0` | Sampling ratio value defines how many traces should be sent to your exporter |
| APP_TRACE_ZIPKIN_URL | `http://localhost:9411/api/v2/spans` | Zipkin API URL to be used |
| APP_STATS_CLEAN_DAYS_TO_KEEP | `30` | Statistics number of days to keep in database |
| APP_STATS_CLEAN_DELAY | `1h` | Statistics clean delay |
| APP_STATS_FLUSH_DELAY | `3s` | Delay in which statistics will be batch into database |
Expand Down
14 changes: 14 additions & 0 deletions backend/configs/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ type App struct {
StatsCleanDaysToKeep int `config:"app_stats_clean_days_to_keep"`
StatsFlushDelay time.Duration `config:"app_stats_flush_delay"`
StatsResourceKindRegex string `config:"app_stats_resource_kind_regex"`
TraceEnabled bool `config:"app_trace_enabled"`
TraceExporter string `config:"app_trace_exporter"`
TraceJaegerURL string `config:"app_trace_jaeger_url"`
TraceOtlpDialTimeout time.Duration `config:"app_trace_otlp_dial_timeout"`
TraceOtlpEndpoint string `config:"app_trace_otlp_endpoint"`
TraceZipkinURL string `config:"app_trace_zipkin_url"`
TraceSampleRatio float64 `config:"app_trace_sample_ratio"`
}

func newApp() *App {
Expand All @@ -27,5 +34,12 @@ func newApp() *App {
StatsCleanDaysToKeep: 30,
StatsFlushDelay: 3 * time.Second,
StatsResourceKindRegex: `.*`,
TraceEnabled: false,
TraceExporter: "jaeger",
TraceJaegerURL: "http://localhost:14268/api/traces",
TraceOtlpDialTimeout: 3 * time.Second,
TraceOtlpEndpoint: "localhost:30080",
TraceZipkinURL: "http://localhost:9411/api/v2/spans",
TraceSampleRatio: 1.0,
}
}
30 changes: 24 additions & 6 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ require (
github.com/go-oauth2/oauth2/v4 v4.5.1
github.com/go-playground/validator/v10 v10.11.1
github.com/gofiber/adaptor/v2 v2.1.30
github.com/gofiber/fiber/v2 v2.40.1
github.com/gofiber/contrib/otelfiber v0.0.0-20230119212140-c5d658dbb5ca
github.com/gofiber/fiber/v2 v2.41.0
github.com/gofiber/swagger v0.1.8
github.com/golang-jwt/jwt/v4 v4.4.3
github.com/golang/mock v1.4.4
Expand All @@ -20,6 +21,12 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.1
github.com/swaggo/swag v1.8.8
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.37.0
go.opentelemetry.io/otel v1.11.2
go.opentelemetry.io/otel/exporters/jaeger v1.11.2
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2
go.opentelemetry.io/otel/exporters/zipkin v1.11.2
go.opentelemetry.io/otel/sdk v1.11.2
go.uber.org/fx v1.18.2
golang.org/x/crypto v0.4.0
golang.org/x/exp v0.0.0-20221208152030-732eee02a75a
Expand All @@ -39,12 +46,15 @@ require (
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/glebarez/go-sqlite v1.20.0 // indirect
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/spec v0.20.4 // indirect
Expand All @@ -55,6 +65,7 @@ require (
github.com/gofrs/uuid v4.0.0+incompatible // indirect
github.com/golang-jwt/jwt v3.2.1+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.0 // indirect
github.com/hashicorp/go-memdb v1.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
Expand All @@ -64,23 +75,30 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/openzipkin/zipkin-go v0.4.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.41.0 // indirect
github.com/valyala/fasthttp v1.44.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
go.opentelemetry.io/contrib v1.12.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2 // indirect
go.opentelemetry.io/otel/metric v0.34.0 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/dig v1.15.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
Expand All @@ -90,7 +108,7 @@ require (
golang.org/x/text v0.6.0 // indirect
golang.org/x/tools v0.5.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705 // indirect
google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/sqlite v1.4.4 // indirect
Expand Down
Loading

0 comments on commit f221659

Please sign in to comment.