diff --git a/cmd/serve.go b/cmd/serve.go
index 69dfbaed..647ee1c5 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -4,6 +4,7 @@ import (
"context"
"github.com/spf13/cobra"
+ "github.com/theopenlane/beacon/otelx"
"go.uber.org/zap"
dbx "github.com/theopenlane/dbx/pkg/dbxclient"
@@ -16,7 +17,6 @@ import (
"github.com/theopenlane/core/internal/httpserve/server"
"github.com/theopenlane/core/internal/httpserve/serveropts"
"github.com/theopenlane/core/pkg/cache"
- "github.com/theopenlane/core/pkg/otelx"
)
var serveCmd = &cobra.Command{
@@ -75,7 +75,7 @@ func serve(ctx context.Context) error {
serveropts.WithTokenManager(),
)
- err = otelx.NewTracer(so.Config.Settings.Tracer, appName, logger)
+ err = otelx.NewTracer(so.Config.Settings.Tracer, appName)
if err != nil {
logger.Fatalw("failed to initialize tracer", "error", err)
}
diff --git a/config/config.go b/config/config.go
index aa911c6c..0f05c28e 100644
--- a/config/config.go
+++ b/config/config.go
@@ -10,6 +10,7 @@ import (
"github.com/knadh/koanf/providers/file"
"github.com/knadh/koanf/v2"
"github.com/mcuadros/go-defaults"
+ "github.com/theopenlane/beacon/otelx"
dbx "github.com/theopenlane/dbx/pkg/dbxclient"
"github.com/theopenlane/entx"
"github.com/theopenlane/iam/fgax"
@@ -31,7 +32,6 @@ import (
"github.com/theopenlane/core/pkg/middleware/ratelimit"
"github.com/theopenlane/core/pkg/middleware/redirect"
"github.com/theopenlane/core/pkg/middleware/secure"
- "github.com/theopenlane/core/pkg/otelx"
)
var (
diff --git a/go.mod b/go.mod
index 27e431e8..ff93a1b6 100644
--- a/go.mod
+++ b/go.mod
@@ -52,6 +52,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/stoewer/go-strcase v1.3.0
github.com/stretchr/testify v1.9.0
+ github.com/theopenlane/beacon v0.1.0
github.com/theopenlane/dbx v0.1.0
github.com/theopenlane/echo-prometheus v0.1.0
github.com/theopenlane/echox v0.1.0
@@ -64,12 +65,6 @@ require (
github.com/tursodatabase/libsql-client-go v0.0.0-20240812094001-348a4e45b535
github.com/vektah/gqlparser/v2 v2.5.16
github.com/wundergraph/graphql-go-tools v1.67.4
- go.opentelemetry.io/otel v1.29.0
- go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.29.0
- go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0
- go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.29.0
- go.opentelemetry.io/otel/sdk v1.29.0
go.uber.org/zap v1.27.0
gocloud.dev v0.39.0
golang.org/x/crypto v0.26.0
@@ -123,6 +118,7 @@ require (
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
+ github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-faster/jx v1.1.0 // indirect
@@ -132,6 +128,7 @@ require (
github.com/go-openapi/inflect v0.21.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
+ github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-viper/mapstructure/v2 v2.1.0 // indirect
github.com/go-webauthn/x v0.1.14 // indirect
@@ -188,6 +185,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/natefinch/wrap v0.2.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
+ github.com/nxadm/tail v1.4.11 // indirect
github.com/ogen-go/ogen v1.3.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
@@ -223,6 +221,7 @@ require (
github.com/spf13/viper v1.19.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
+ github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.27.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
@@ -236,7 +235,13 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib v1.29.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
+ go.opentelemetry.io/otel v1.29.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.29.0 // indirect
+ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0 // indirect
+ go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
+ go.opentelemetry.io/otel/sdk v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
diff --git a/go.sum b/go.sum
index c56ff087..50ff5f4c 100644
--- a/go.sum
+++ b/go.sum
@@ -155,12 +155,13 @@ github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
+github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
-github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
-github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
+github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
+github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
github.com/gertd/go-pluralize v0.2.1 h1:M3uASbVjMnTsPb0PNqg+E/24Vwigyo/tvyMTtAlLgiA=
github.com/gertd/go-pluralize v0.2.1/go.mod h1:rbYaKDbsXxmRfr8uygAEKhOWsjyrrqrkHVpZvoOp8zk=
github.com/getkin/kin-openapi v0.127.0 h1:Mghqi3Dhryf3F8vR370nN67pAERW+3a95vomb3MAREY=
@@ -184,12 +185,12 @@ github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
-github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
-github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
-github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
-github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
-github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24=
-github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
+github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
+github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
+github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
+github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
+github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
+github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-redis/redismock/v8 v8.0.6 h1:rtuijPgGynsRB2Y7KDACm09WvjHWS4RaG44Nm7rcj4Y=
@@ -344,8 +345,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
-github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
-github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
+github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
+github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k=
github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU=
github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=
@@ -403,8 +404,8 @@ github.com/natefinch/wrap v0.2.0/go.mod h1:6gMHlAl12DwYEfKP3TkuykYUfLSEAvHw67itm
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
-github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
-github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
+github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY=
+github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc=
github.com/nyaruka/phonenumbers v1.4.0 h1:ddhWiHnHCIX3n6ETDA58Zq5dkxkjlvgrDWM2OHHPCzU=
github.com/nyaruka/phonenumbers v1.4.0/go.mod h1:gv+CtldaFz+G3vHHnasBSirAi3O2XLqZzVWz4V1pl2E=
github.com/ogen-go/ogen v1.3.0 h1:c0+CvdbwvKmaHQUqbPpRKflvkiJ/NAsEw3L3HhofDso=
@@ -531,6 +532,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
+github.com/theopenlane/beacon v0.1.0 h1:cyGx18rbaJTZT8pRcqMMvg+kN6uh86X4OoDahQp6VnE=
+github.com/theopenlane/beacon v0.1.0/go.mod h1:gOJAanQzfmDF3FIyv7Lwx16bKI7YPkJx1iRT4SdcBW4=
github.com/theopenlane/dbx v0.1.0 h1:hjaaruFBwLQ8yHDAN3P68j8hYbdkJE3fb0ynAwTidOY=
github.com/theopenlane/dbx v0.1.0/go.mod h1:SJm0TRYqkqC+Ap+G32zgK96OkujZvtHTqWQXmzo8ZRg=
github.com/theopenlane/echo-prometheus v0.1.0 h1:1zMejBVHe5w4zLHS+k5FV9S/46QBiwO6ggTSKi6r/7E=
@@ -553,8 +556,8 @@ github.com/tursodatabase/libsql-client-go v0.0.0-20240812094001-348a4e45b535 h1:
github.com/tursodatabase/libsql-client-go v0.0.0-20240812094001-348a4e45b535/go.mod h1:l8xTsYB90uaVdMHXMCxKKLSgw5wLYBwBKKefNIUnm9s=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
-github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
-github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
+github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
+github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8=
github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
@@ -673,6 +676,7 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
diff --git a/jsonschema/api-docs.md b/jsonschema/api-docs.md
index 1afd6d9f..be464c75 100644
--- a/jsonschema/api-docs.md
+++ b/jsonschema/api-docs.md
@@ -15,7 +15,7 @@ Config contains the configuration for the core server
|[**db**](#db)|`object`||yes|
|[**dbx**](#dbx)|`object`|||
|[**redis**](#redis)|`object`|Config for the redis client used to store key-value pairs
||
-|[**tracer**](#tracer)|`object`|Config defines the configuration settings for opentelemetry tracing
||
+|[**tracer**](#tracer)|`object`|||
|[**email**](#email)|`object`|||
|[**sessions**](#sessions)|`object`|||
|[**posthog**](#posthog)|`object`|Config is the configuration for PostHog
||
@@ -454,50 +454,41 @@ Config for the redis client used to store key-value pairs
## tracer: object
-Config defines the configuration settings for opentelemetry tracing
-
-
**Properties**
|Name|Type|Description|Required|
|----|----|-----------|--------|
-|**enabled**|`boolean`|Enabled to enable tracing
||
-|**provider**|`string`|Provider to use for tracing
||
-|**environment**|`string`|Environment to set for the service
||
-|[**stdout**](#tracerstdout)|`object`|StdOut settings for the stdout provider
||
-|[**otlp**](#tracerotlp)|`object`|OTLP settings for the otlp provider
||
+|**enabled**|`boolean`|||
+|**provider**|`string`|||
+|**environment**|`string`|||
+|[**stdout**](#tracerstdout)|`object`|||
+|[**otlp**](#tracerotlp)|`object`|||
**Additional Properties:** not allowed
### tracer\.stdout: object
-StdOut settings for the stdout provider
-
-
**Properties**
|Name|Type|Description|Required|
|----|----|-----------|--------|
-|**pretty**|`boolean`|Pretty enables pretty printing of the output
||
-|**disableTimestamp**|`boolean`|DisableTimestamp disables the timestamp in the output
||
+|**pretty**|`boolean`|||
+|**disableTimestamp**|`boolean`|||
**Additional Properties:** not allowed
### tracer\.otlp: object
-OTLP settings for the otlp provider
-
-
**Properties**
|Name|Type|Description|Required|
|----|----|-----------|--------|
-|**endpoint**|`string`|Endpoint to send the traces to
||
-|**insecure**|`boolean`|Insecure to disable TLS
||
-|**certificate**|`string`|Certificate to use for TLS
||
+|**endpoint**|`string`|||
+|**insecure**|`boolean`|||
+|**certificate**|`string`|||
|[**headers**](#tracerotlpheaders)|`string[]`|||
-|**compression**|`string`|Compression to use for the request
||
-|**timeout**|`integer`|Timeout for the request
||
+|**compression**|`string`|||
+|**timeout**|`integer`|||
**Additional Properties:** not allowed
diff --git a/jsonschema/core.config.json b/jsonschema/core.config.json
index 000f0618..eca6f8fb 100644
--- a/jsonschema/core.config.json
+++ b/jsonschema/core.config.json
@@ -616,75 +616,59 @@
"otelx.Config": {
"properties": {
"enabled": {
- "type": "boolean",
- "description": "Enabled to enable tracing"
+ "type": "boolean"
},
"provider": {
- "type": "string",
- "description": "Provider to use for tracing"
+ "type": "string"
},
"environment": {
- "type": "string",
- "description": "Environment to set for the service"
+ "type": "string"
},
"stdout": {
- "$ref": "#/$defs/otelx.StdOut",
- "description": "StdOut settings for the stdout provider"
+ "$ref": "#/$defs/otelx.StdOut"
},
"otlp": {
- "$ref": "#/$defs/otelx.OTLP",
- "description": "OTLP settings for the otlp provider"
+ "$ref": "#/$defs/otelx.OTLP"
}
},
"additionalProperties": false,
- "type": "object",
- "description": "Config defines the configuration settings for opentelemetry tracing"
+ "type": "object"
},
"otelx.OTLP": {
"properties": {
"endpoint": {
- "type": "string",
- "description": "Endpoint to send the traces to"
+ "type": "string"
},
"insecure": {
- "type": "boolean",
- "description": "Insecure to disable TLS"
+ "type": "boolean"
},
"certificate": {
- "type": "string",
- "description": "Certificate to use for TLS"
+ "type": "string"
},
"headers": {
- "$ref": "#/$defs/[]string",
- "description": "Headers to send with the request"
+ "$ref": "#/$defs/[]string"
},
"compression": {
- "type": "string",
- "description": "Compression to use for the request"
+ "type": "string"
},
"timeout": {
- "type": "integer",
- "description": "Timeout for the request"
+ "type": "integer"
}
},
"additionalProperties": false,
- "type": "object",
- "description": "OTLP settings for the otlp provider"
+ "type": "object"
},
"otelx.StdOut": {
"properties": {
"pretty": {
- "type": "boolean",
- "description": "Pretty enables pretty printing of the output"
+ "type": "boolean"
},
"disableTimestamp": {
- "type": "boolean",
- "description": "DisableTimestamp disables the timestamp in the output"
+ "type": "boolean"
}
},
"additionalProperties": false,
- "type": "object",
- "description": "StdOut settings for the stdout provider"
+ "type": "object"
},
"posthog.Config": {
"properties": {
diff --git a/jsonschema/schema_generator.go b/jsonschema/schema_generator.go
index ac2a36f9..dd9285c2 100644
--- a/jsonschema/schema_generator.go
+++ b/jsonschema/schema_generator.go
@@ -37,7 +37,6 @@ var includedPackages = []string{
"./internal/ent",
"./internal/entdb",
"./internal/httpserve/handlers",
- "./pkg/otelx",
"./pkg/analytics",
"./pkg/middleware",
"./pkg/events/kafka/kafkaconfig",
diff --git a/pkg/otelx/doc.go b/pkg/otelx/doc.go
deleted file mode 100644
index d3f2415f..00000000
--- a/pkg/otelx/doc.go
+++ /dev/null
@@ -1,2 +0,0 @@
-// Package otelx provides configuration options for various OpenTelemetry integrations.
-package otelx
diff --git a/pkg/otelx/errors.go b/pkg/otelx/errors.go
deleted file mode 100644
index 711013bb..00000000
--- a/pkg/otelx/errors.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package otelx
-
-import (
- "errors"
- "fmt"
-)
-
-var (
- ErrUnknownProvider = errors.New("unknown provider")
- ErrInvalidConfig = errors.New("failed parsing trace config(s)")
-)
-
-func newUnknownProviderError(provider string) error {
- return fmt.Errorf("%w: %s", ErrUnknownProvider, provider)
-}
-
-func newTraceConfigError(err error) error {
- return fmt.Errorf("%w: %w", ErrInvalidConfig, err)
-}
diff --git a/pkg/otelx/otel.go b/pkg/otelx/otel.go
deleted file mode 100644
index 0f225bad..00000000
--- a/pkg/otelx/otel.go
+++ /dev/null
@@ -1,159 +0,0 @@
-package otelx
-
-import (
- "context"
- "net/url"
- "time"
-
- "go.opentelemetry.io/otel"
- "go.opentelemetry.io/otel/attribute"
- "go.opentelemetry.io/otel/exporters/otlp/otlptrace"
- "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
- "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
- "go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
- "go.opentelemetry.io/otel/propagation"
- "go.opentelemetry.io/otel/sdk/resource"
- sdktrace "go.opentelemetry.io/otel/sdk/trace"
- semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
- "go.uber.org/zap"
-)
-
-const (
- StdOutProvider = "stdout"
- OTLPHTTPProvider = "otlphttp"
- OTLPGRPCProvider = "otlpgrpc"
-)
-
-// Config defines the configuration settings for opentelemetry tracing
-type Config struct {
- // Enabled to enable tracing
- Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
- // Provider to use for tracing
- Provider string `json:"provider" koanf:"provider" default:"stdout"`
- // Environment to set for the service
- Environment string `json:"environment" koanf:"environment" default:"development"`
- // StdOut settings for the stdout provider
- StdOut StdOut `json:"stdout" koanf:"stdout"`
- // OTLP settings for the otlp provider
- OTLP OTLP `json:"otlp" koanf:"otlp"`
-}
-
-// StdOut settings for the stdout provider
-type StdOut struct {
- // Pretty enables pretty printing of the output
- Pretty bool `json:"pretty" koanf:"pretty" default:"true"`
- // DisableTimestamp disables the timestamp in the output
- DisableTimestamp bool `json:"disableTimestamp" koanf:"disableTimestamp" default:"false"`
-}
-
-// OTLP settings for the otlp provider
-type OTLP struct {
- // Endpoint to send the traces to
- Endpoint string `json:"endpoint" koanf:"endpoint" default:"localhost:4317"`
- // Insecure to disable TLS
- Insecure bool `json:"insecure" koanf:"insecure" default:"true"`
- // Certificate to use for TLS
- Certificate string `json:"certificate" koanf:"certificate"`
- // Headers to send with the request
- Headers []string `json:"headers" koanf:"headers"`
- // Compression to use for the request
- Compression string `json:"compression" koanf:"compression"`
- // Timeout for the request
- Timeout time.Duration `json:"timeout" koanf:"timeout" default:"10s"`
-}
-
-func NewTracer(c Config, name string, logger *zap.SugaredLogger) error {
- if !c.Enabled {
- logger.Debug("Tracing disabled")
- return nil
- }
-
- exp, err := newTraceExporter(c)
- if err != nil {
- logger.Debugw("Failed to create trace exporter", "error", err)
- return err
- }
-
- opts := []sdktrace.TracerProviderOption{
- sdktrace.WithSampler(sdktrace.AlwaysSample()),
- // Record information about this application in a resource.
- sdktrace.WithResource(resource.NewWithAttributes(
- semconv.SchemaURL,
- semconv.ServiceNameKey.String(name),
- attribute.String("environment", c.Environment),
- )),
- }
-
- if exp != nil {
- opts = append(opts, sdktrace.WithBatcher(exp))
- }
-
- tp := sdktrace.NewTracerProvider(opts...)
- otel.SetTracerProvider(tp)
- otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}))
-
- return nil
-}
-
-func newTraceExporter(c Config) (sdktrace.SpanExporter, error) {
- switch c.Provider {
- case StdOutProvider:
- return newStdoutProvider(c)
- case OTLPHTTPProvider:
- return newOTLPHTTPProvider(c)
- case OTLPGRPCProvider:
- return newOTLPGRPCProvider(c)
- default:
- return nil, newUnknownProviderError(c.Provider)
- }
-}
-
-func newStdoutProvider(c Config) (sdktrace.SpanExporter, error) {
- opts := []stdouttrace.Option{}
-
- if c.StdOut.Pretty {
- opts = append(opts, stdouttrace.WithPrettyPrint())
- }
-
- if c.StdOut.DisableTimestamp {
- opts = append(opts, stdouttrace.WithoutTimestamps())
- }
-
- return stdouttrace.New(opts...)
-}
-
-func newOTLPHTTPProvider(c Config) (sdktrace.SpanExporter, error) {
- _, err := url.Parse(c.OTLP.Endpoint)
- if err != nil {
- return nil, newTraceConfigError(err)
- }
-
- opts := []otlptracehttp.Option{
- otlptracehttp.WithEndpoint(c.OTLP.Endpoint),
- otlptracehttp.WithTimeout(c.OTLP.Timeout),
- }
-
- if c.OTLP.Insecure {
- opts = append(opts, otlptracehttp.WithInsecure())
- }
-
- return otlptrace.New(context.Background(), otlptracehttp.NewClient(opts...))
-}
-
-func newOTLPGRPCProvider(c Config) (sdktrace.SpanExporter, error) {
- _, err := url.Parse(c.OTLP.Endpoint)
- if err != nil {
- return nil, newTraceConfigError(err)
- }
-
- opts := []otlptracegrpc.Option{
- otlptracegrpc.WithEndpoint(c.OTLP.Endpoint),
- otlptracegrpc.WithTimeout(c.OTLP.Timeout),
- }
-
- if c.OTLP.Insecure {
- opts = append(opts, otlptracegrpc.WithInsecure())
- }
-
- return otlptrace.New(context.Background(), otlptracegrpc.NewClient(opts...))
-}
diff --git a/pkg/otelx/otel_test.go b/pkg/otelx/otel_test.go
deleted file mode 100644
index ad42cbee..00000000
--- a/pkg/otelx/otel_test.go
+++ /dev/null
@@ -1,115 +0,0 @@
-package otelx_test
-
-import (
- "testing"
-
- "github.com/theopenlane/core/pkg/otelx"
-
- "github.com/stretchr/testify/assert"
- "go.uber.org/zap"
-)
-
-func TestNewTracer(t *testing.T) {
- testCases := []struct {
- name string
- config otelx.Config
- expectedError error
- }{
- {
- name: "enabled",
- config: otelx.Config{
- Enabled: true,
- Provider: otelx.OTLPHTTPProvider,
- Environment: "development",
- OTLP: otelx.OTLP{
- Endpoint: "localhost:4317",
- Insecure: true,
- },
- },
- },
- {
- name: "disabled",
- config: otelx.Config{
- Enabled: false,
- Provider: otelx.OTLPHTTPProvider,
- Environment: "development",
- OTLP: otelx.OTLP{
- Endpoint: "localhost:4317",
- Insecure: true,
- },
- },
- },
- {
- name: "otlphttp - invalid endpoint",
- config: otelx.Config{
- Enabled: true,
- Provider: otelx.OTLPHTTPProvider,
- Environment: "development",
- OTLP: otelx.OTLP{
- Endpoint: " a-b-://1234",
- Insecure: true,
- },
- },
- expectedError: otelx.ErrInvalidConfig,
- },
- {
- name: "otlpgrpc",
- config: otelx.Config{
- Enabled: true,
- Provider: otelx.OTLPGRPCProvider,
- Environment: "development",
- OTLP: otelx.OTLP{
- Endpoint: "localhost:4317",
- Insecure: true,
- },
- },
- },
- {
- name: "otlpgrpc - invalid endpoint",
- config: otelx.Config{
- Enabled: true,
- Provider: otelx.OTLPGRPCProvider,
- Environment: "development",
- OTLP: otelx.OTLP{
- Endpoint: " a-b-://1234",
- Insecure: true,
- },
- },
- expectedError: otelx.ErrInvalidConfig,
- },
- {
- name: "stdout",
- config: otelx.Config{
- Enabled: true,
- Provider: otelx.StdOutProvider,
- Environment: "development",
- StdOut: otelx.StdOut{
- Pretty: true,
- DisableTimestamp: true,
- },
- },
- },
- {
- name: "invalid provider",
- config: otelx.Config{
- Enabled: true,
- Provider: "invalid",
- Environment: "development",
- },
- expectedError: otelx.ErrUnknownProvider,
- },
- }
-
- for _, tc := range testCases {
- t.Run("Trace "+tc.name, func(t *testing.T) {
- err := otelx.NewTracer(tc.config, "test", zap.NewNop().Sugar())
-
- if tc.expectedError != nil {
- assert.NotNil(t, err)
- assert.ErrorContains(t, err, tc.expectedError.Error())
- } else {
- assert.Nil(t, err)
- }
- })
- }
-}