mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* add jaeger support, link hot container & req span * adds jaeger support now with FN_JAEGER_URL, there's a simple tutorial in the operating/metrics.md file now and it's pretty easy to get up and running. * links a hot request span to a hot container span. when we change this to sample at a lower ratio we'll need to finagle the hot container span to always sample or something, otherwise we'll hide that info. at least, since we're sampling at 100% for now if this is flipped on, can see freeze/unfreeze etc. if they hit. this is useful for debugging. note that zipkin's exporter does not follow the link at all, hence jaeger... and they're backed by the Cloud Empire now (CNCF) so we'll probably use it anyway. * vendor: add thrift for jaeger
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
|
|
calendar "google.golang.org/api/calendar/v3"
|
|
)
|
|
|
|
func init() {
|
|
registerDemo("calendar", calendar.CalendarScope, calendarMain)
|
|
}
|
|
|
|
// calendarMain is an example that demonstrates calling the Calendar API.
|
|
// Its purpose is to test out the ability to get maps of struct objects.
|
|
//
|
|
// Example usage:
|
|
// go build -o go-api-demo *.go
|
|
// go-api-demo -clientid="my-clientid" -secret="my-secret" calendar
|
|
func calendarMain(client *http.Client, argv []string) {
|
|
if len(argv) != 0 {
|
|
fmt.Fprintln(os.Stderr, "Usage: calendar")
|
|
return
|
|
}
|
|
|
|
svc, err := calendar.New(client)
|
|
if err != nil {
|
|
log.Fatalf("Unable to create Calendar service: %v", err)
|
|
}
|
|
|
|
c, err := svc.Colors.Get().Do()
|
|
if err != nil {
|
|
log.Fatalf("Unable to retrieve calendar colors: %v", err)
|
|
}
|
|
|
|
log.Printf("Kind of colors: %v", c.Kind)
|
|
log.Printf("Colors last updated: %v", c.Updated)
|
|
|
|
for k, v := range c.Calendar {
|
|
log.Printf("Calendar[%v]: Background=%v, Foreground=%v", k, v.Background, v.Foreground)
|
|
}
|
|
|
|
for k, v := range c.Event {
|
|
log.Printf("Event[%v]: Background=%v, Foreground=%v", k, v.Background, v.Foreground)
|
|
}
|
|
|
|
listRes, err := svc.CalendarList.List().Fields("items/id").Do()
|
|
if err != nil {
|
|
log.Fatalf("Unable to retrieve list of calendars: %v", err)
|
|
}
|
|
for _, v := range listRes.Items {
|
|
log.Printf("Calendar ID: %v\n", v.Id)
|
|
}
|
|
|
|
if len(listRes.Items) > 0 {
|
|
id := listRes.Items[0].Id
|
|
res, err := svc.Events.List(id).Fields("items(updated,summary)", "summary", "nextPageToken").Do()
|
|
if err != nil {
|
|
log.Fatalf("Unable to retrieve calendar events list: %v", err)
|
|
}
|
|
for _, v := range res.Items {
|
|
log.Printf("Calendar ID %q event: %v: %q\n", id, v.Updated, v.Summary)
|
|
}
|
|
log.Printf("Calendar ID %q Summary: %v\n", id, res.Summary)
|
|
log.Printf("Calendar ID %q next page token: %v\n", id, res.NextPageToken)
|
|
}
|
|
}
|