func main()

in recipes/beyla-service-graph/graphgen/main.go [39:75]


func main() {
	flag.Parse()
	if *projectId == "" {
		fmt.Println("You must set the -projectId flag!")
		os.Exit(1)
	}

	ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
	defer cancel()

	client, err := createPromApiClient(ctx)
	if err != nil {
		slog.ErrorContext(ctx, "Got error creating prometheus api client")
		panic(err)
	}

	graph, err := internal.QueryPrometheus(
		ctx,
		client,
		internal.QueryArgs{
			QueryWindow: *queryWindow,
			Cluster:     *cluster,
			Namespace:   *namespace,
		},
	)
	if err != nil {
		slog.ErrorContext(ctx, "Got error querying prometheus", "err", err)
		panic(err)
	}
	slog.InfoContext(ctx, "Got graph list", "graph", graph)

	err = graph.Render(os.Stdout)
	if err != nil {
		slog.ErrorContext(ctx, "Got error rendering graph", "err", err)
		panic(err)
	}
}