Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Fix the webhook container

Acho Arnold24c5caf0a285
diff --git a/api/pkg/di/container.go b/api/pkg/di/container.go
index 2ceadc25..91eb9920 100644
--- a/api/pkg/di/container.go
+++ b/api/pkg/di/container.go
@@ -828,7 +828,10 @@ func (container *Container) WebhookService() (service *services.WebhookService)
return services.NewWebhookService(
container.Logger(),
container.Tracer(),
- container.HTTPClient("webhook"),
+ &http.Client{
+ Timeout: 6 * time.Second,
+ Transport: container.HTTPRoundTripperWithoutRetry("webhook"),
+ },
container.WebhookRepository(),
container.EventDispatcher(),
)
@@ -865,6 +868,16 @@ func (container *Container) HTTPRoundTripper(name string) http.RoundTripper {
)
}
+// HTTPRoundTripperWithoutRetry creates an open telemetry http.RoundTripper without retry
+func (container *Container) HTTPRoundTripperWithoutRetry(name string) http.RoundTripper {
+ container.logger.Debug(fmt.Sprintf("Debug: initializing %s %T", name, http.DefaultTransport))
+ return otelroundtripper.New(
+ otelroundtripper.WithName(name),
+ otelroundtripper.WithMeter(otel.GetMeterProvider().Meter(container.projectID)),
+ otelroundtripper.WithAttributes(container.OtelResources(container.version, container.projectID).Attributes()...),
+ )
+}
+
// OtelResources generates default open telemetry resources
func (container *Container) OtelResources(version string, namespace string) *resource.Resource {
return resource.NewWithAttributes(