File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright The OpenTelemetry Authors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ package otelsdk_test
5
+
6
+ import (
7
+ "context"
8
+ "os/signal"
9
+ "sync"
10
+ "syscall"
11
+
12
+ "go.opentelemetry.io/auto"
13
+ "go.opentelemetry.io/auto/pipeline/otelsdk"
14
+ )
15
+
16
+ func Example_multiplex () {
17
+ ctx := context .Background ()
18
+ m , err := otelsdk .NewMultiplexer (ctx )
19
+ if err != nil {
20
+ panic (err )
21
+ }
22
+
23
+ pids := []int {1297 , 1331 , 9827 } // Simulated PIDs
24
+
25
+ var wg sync.WaitGroup
26
+ for _ , pid := range pids {
27
+ wg .Add (1 )
28
+ go func (id int ) {
29
+ defer wg .Done ()
30
+
31
+ ctx , stop := signal .NotifyContext (ctx , syscall .SIGTERM )
32
+ defer stop ()
33
+
34
+ // Note: do not ignore errors in normal use.
35
+ inst , _ := auto .NewInstrumentation (
36
+ ctx , auto .WithPID (id ), auto .WithHandler (m .Handler (id )),
37
+ )
38
+ _ = inst .Load (ctx )
39
+ _ = inst .Run (ctx )
40
+ }(pid )
41
+ }
42
+
43
+ wg .Wait ()
44
+ _ = m .Shutdown (ctx )
45
+ }
You can’t perform that action at this time.
0 commit comments