MCPcopy Create free account
hub / github.com/google/go-github / main

Function main

example/otel/main.go:22–64  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20)
21
22func main() {
23 // Initialize stdout exporter to see traces in console
24 exporter, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
25 if err != nil {
26 log.Fatalf("failed to initialize stdouttrace exporter: %v", err)
27 }
28
29 tp := trace.NewTracerProvider(
30 trace.WithBatcher(exporter),
31 )
32 defer func() {
33 if err := tp.Shutdown(context.Background()); err != nil {
34 log.Fatal(err)
35 }
36 }()
37
38 // Configure OTel transport
39 t := otel.NewTransport(
40 http.DefaultTransport,
41 otel.WithTracerProvider(tp),
42 )
43
44 client, err := github.NewClient(github.WithTransport(t))
45 if err != nil {
46 log.Fatalf("Error creating GitHub client: %v", err)
47 }
48
49 // Make a request (Get Rate Limits is public and cheap)
50 limits, resp, err := client.RateLimit.Get(context.Background())
51 if err != nil {
52 log.Printf("Error fetching rate limits: %v", err)
53 } else {
54 fmt.Printf("Core Rate Limit: %v/%v (Resets at %v)\n",
55 limits.GetCore().Remaining,
56 limits.GetCore().Limit,
57 limits.GetCore().Reset)
58 }
59
60 // Print the HTTP response status when available.
61 if resp != nil {
62 fmt.Printf("Response Status: %v\n", resp.Status)
63 }
64}

Callers

nothing calls this directly

Calls 4

NewClientFunction · 0.92
WithTransportFunction · 0.92
GetCoreMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…