Installation steps

  1. Install Atatus Go Agent and RPC module

    copy
    icon/buttons/copy
    go get go.atatus.com/agent
    go get go.atatus.com/agent/module/atgrpc
    
  2. Set up tracer and instrument the RPC client/server

    • Instrumenting gRPC Server in Go using Atatus Agent
    copy
    icon/buttons/copy
    import (
        "google.golang.org/grpc"
    
        "go.go.atatus.com/agent"
        "go.go.atatus.com/agent/module/atgrpc"
    )
    
    func main() {
        // Initialize Atatus tracer with values from environment
        tracer := atatus.DefaultTracer
        tracer.Service.LicenseKey = os.Getenv("ATATUS_LICENSE_KEY")
        tracer.Service.AppName = os.Getenv("ATATUS_APP_NAME")
        tracer.Service.Tracing = os.Getenv("ATATUS_TRACING")
        tracer.Service.Analytics = os.Getenv("ATATUS_ANALYTICS")
    
        // Setup gRPC server with Atatus middleware
        server := grpc.NewServer(
            grpc.UnaryInterceptor(atgrpc.NewUnaryServerInterceptor()),
            grpc.StreamInterceptor(atgrpc.NewStreamServerInterceptor()),
        )
    
        // Register your gRPC services here
        // pb.RegisterYourService(server, ...)
    
        // Start server
        // lis, _ := net.Listen("tcp", ":50051")
        // server.Serve(lis)
    }
    
    • Instrumenting gRPC Client in Go using Atatus Agent
    copy
    icon/buttons/copy
    import (
        "google.golang.org/grpc"
    
        "go.go.atatus.com/agent"
        "go.go.atatus.com/agent/module/atgrpc"
    )
    
    func main() {
        // Initialize Atatus tracer with values from environment
        tracer := atatus.DefaultTracer
        tracer.Service.LicenseKey = os.Getenv("ATATUS_LICENSE_KEY")
        tracer.Service.AppName = os.Getenv("ATATUS_APP_NAME")
        tracer.Service.Tracing = os.Getenv("ATATUS_TRACING")
        tracer.Service.Analytics = os.Getenv("ATATUS_ANALYTICS")
    
        // Setup gRPC client with Atatus interceptors
        conn, _ := grpc.Dial("localhost:50051",
            grpc.WithInsecure(),
            grpc.WithUnaryInterceptor(atgrpc.NewUnaryClientInterceptor()),
            grpc.WithStreamInterceptor(atgrpc.NewStreamClientInterceptor()),
        )
    
        // Create client and make RPC calls
        // client := pb.NewYourServiceClient(conn)
        // client.YourMethod(ctx, &pb.YourRequest{})
    }
    
  3. Clean Up Dependencies

    copy
    icon/buttons/copy

    go mod tidy
    
  4. Run the Application

    copy
    icon/buttons/copy

    go run client.go
    go run server.go