Skip to content

Commit b99e526

Browse files
committed
Update to use autoinstument library TFO-Go-SDK
1 parent 191a091 commit b99e526

6 files changed

Lines changed: 2066 additions & 4 deletions

File tree

examples/http-server/main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Package main demonstrates TelemetryFlow SDK v1.1.2 integration with an HTTP server.
22
//
33
// This example shows:
4-
// - HTTP middleware for automatic request tracing
4+
// - HTTP auto-instrumentation middleware for automatic request tracing
55
// - Request duration histograms
66
// - Error counting and logging
77
// - TFO v2 API with collector identity
@@ -28,6 +28,7 @@ import (
2828
"time"
2929

3030
"github.com/telemetryflow/telemetryflow-go-sdk/pkg/telemetryflow"
31+
"github.com/telemetryflow/telemetryflow-go-sdk/pkg/telemetryflow/instrumentation"
3132
)
3233

3334
var client *telemetryflow.Client
@@ -65,15 +66,22 @@ func main() {
6566
log.Fatalf("Failed to initialize TelemetryFlow: %v", err)
6667
}
6768

68-
// Create HTTP server with telemetry middleware
69+
// Create HTTP server with auto-instrumentation middleware
6970
mux := http.NewServeMux()
7071
mux.HandleFunc("/", handleHome)
7172
mux.HandleFunc("/api/users", handleUsers)
7273
mux.HandleFunc("/api/orders", handleOrders)
7374
mux.HandleFunc("/health", handleHealth)
7475

75-
// Wrap with telemetry middleware
76-
handler := TelemetryMiddleware(mux)
76+
// Create auto-instrumentation middleware with TelemetryFlow
77+
httpMiddleware := instrumentation.NewHTTPMiddleware(
78+
instrumentation.WithServiceInfo("http-server-example", "1.1.2"),
79+
instrumentation.WithMetrics(true),
80+
instrumentation.WithTracing(true),
81+
)
82+
83+
// Wrap with auto-instrumentation middleware
84+
handler := httpMiddleware.Handler(mux)
7785

7886
server := &http.Server{
7987
Addr: ":8080",

0 commit comments

Comments
 (0)