Skip to content

Commit 24d0378

Browse files
authored
Improvements (#2)
This pull request includes significant refactoring and improvements to the telemetry-forwarder project. The changes focus on modularizing the code, introducing a provider-based architecture, and implementing a circuit breaker for better error handling. The most important changes include the removal of the old forwarder implementation, the addition of a new handler and provider architecture, and the introduction of a circuit breaker for HTTP requests. ### Modularization and Provider-Based Architecture: * [`internal/handler/handler.go`](diffhunk://#diff-0097c8e59074fdb549fd2466fb349b2814b208df005f9ccf97b14568d51a5f0aR1-R42): Added a new `TelemetryCollectHandler` that processes incoming telemetry events and forwards them to registered providers. * [`internal/provider/provider.go`](diffhunk://#diff-58d6a027753b50994deb7e11e4a99dde423f35844986019bd9cea5e0c94aba22R1-R12): Introduced a `Provider` interface to standardize how different telemetry providers are implemented. * [`internal/provider/honeycomb.go`](diffhunk://#diff-0a4059d1666875108ae0797ecbc236e285440360a95850065d986d30f1eb42fcR1-R128): Added a `HoneycombProvider` implementation that sends telemetry data to Honeycomb and uses a circuit breaker for error handling. * [`internal/provider/registry.go`](diffhunk://#diff-a231fa6f8b8a230986dd3f4ccedb0321744a72bc2107a3c4dc9efb924d038661R1-R44): Created a `ProviderRegistry` to manage and register different providers. ### Circuit Breaker Implementation: * [`internal/http/circuit.go`](diffhunk://#diff-d28422209ad2fb4e430d7c1ef22035aeb971daa75279a1c3b8727c39922677e9R1-R83): Implemented a `CircuitBreaker` to manage the state of external API calls and prevent overwhelming the service during failures. ### HTTP Client Improvements: * [`internal/http/client.go`](diffhunk://#diff-b1ec3c3f83844ecd593fa3830bfa5cb65065fd1e6ceaf3b097eb5cfdc9db2146R1-R27): Added a singleton HTTP client with optimized connection settings to be shared across the application. ### Removal of Old Forwarder Implementation: * [`internal/forwarder/forwarder.go`](diffhunk://#diff-f481af681da9b356ae21c822ba11295d9f8f6121c0456c24ccffda986c3c962dL1-L133): Removed the old forwarder implementation that handled telemetry events and forwarded them to Honeycomb. * [`internal/forwarder/types.go`](diffhunk://#diff-d24022fc65012bfc246f190746659a81b158103d850031f9f7f835929c59e664L1-L15): Removed the old `OTelEvent` type definition. * [`internal/forwarder/forwarder_test.go`](diffhunk://#diff-bcbc6b3f04155439c57d91040344f602f72bc7f2d9dba4f2cf64e8ca6c367108L1-L267): Removed the old tests related to the forwarder implementation. ### Dependency Updates: * [`go.mod`](diffhunk://#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6L5-R15): Added new dependencies for testing and YAML processing.
1 parent 02ab0ae commit 24d0378

File tree

14 files changed

+519
-418
lines changed

14 files changed

+519
-418
lines changed

go.mod

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@ module github.com/shaharia-lab/telemetry-forwarder
22

33
go 1.24.1
44

5-
require github.com/kelseyhightower/envconfig v1.4.0
5+
require (
6+
github.com/kelseyhightower/envconfig v1.4.0
7+
github.com/stretchr/testify v1.10.0
8+
)
9+
10+
require (
11+
github.com/davecgh/go-spew v1.1.1 // indirect
12+
github.com/pmezard/go-difflib v1.0.0 // indirect
13+
github.com/stretchr/objx v0.5.2 // indirect
14+
gopkg.in/yaml.v3 v3.0.1 // indirect
15+
)

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
24
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
5+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
8+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
9+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
10+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
11+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
12+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
13+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
14+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/forwarder/forwarder.go

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)