...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package tag_test
17
18 import (
19 "context"
20 "log"
21
22 "go.opencensus.io/tag"
23 )
24
25 var (
26 tagMap *tag.Map
27 ctx context.Context
28 key tag.Key
29 )
30
31 func ExampleNewKey() {
32
33 key, err := tag.NewKey("example.com/keys/user-os")
34 if err != nil {
35 log.Fatal(err)
36 }
37 _ = key
38 }
39
40 func ExampleMustNewKey() {
41 key := tag.MustNewKey("example.com/keys/user-os")
42 _ = key
43 }
44
45 func ExampleNew() {
46 osKey := tag.MustNewKey("example.com/keys/user-os")
47 userIDKey := tag.MustNewKey("example.com/keys/user-id")
48
49 ctx, err := tag.New(ctx,
50 tag.Insert(osKey, "macOS-10.12.5"),
51 tag.Upsert(userIDKey, "cde36753ed"),
52 )
53 if err != nil {
54 log.Fatal(err)
55 }
56
57 _ = ctx
58 }
59
60 func ExampleNew_replace() {
61 ctx, err := tag.New(ctx,
62 tag.Insert(key, "macOS-10.12.5"),
63 tag.Upsert(key, "macOS-10.12.7"),
64 )
65 if err != nil {
66 log.Fatal(err)
67 }
68
69 _ = ctx
70 }
71
72 func ExampleNewContext() {
73
74 ctx := tag.NewContext(context.Background(), tagMap)
75
76 _ = ctx
77 }
78
79 func ExampleFromContext() {
80 tagMap := tag.FromContext(ctx)
81
82 _ = tagMap
83 }
84
85 func ExampleDo() {
86 ctx, err := tag.New(ctx,
87 tag.Insert(key, "macOS-10.12.5"),
88 tag.Upsert(key, "macOS-10.12.7"),
89 )
90 if err != nil {
91 log.Fatal(err)
92 }
93 tag.Do(ctx, func(ctx context.Context) {
94 _ = ctx
95 })
96 }
97
View as plain text