| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package component_test |
| 5 |
|
| 6 |
import ( |
| 7 |
"fmt" |
| 8 |
|
| 9 |
"go.opentelemetry.io/collector/component" |
| 10 |
) |
| 11 |
|
| 12 |
func ExampleNewType() { |
| 13 |
t, err := component.NewType("exampleexporter") |
| 14 |
if err != nil { |
| 15 |
fmt.Println("error:", err) |
| 16 |
return |
| 17 |
} |
| 18 |
fmt.Println(t.String()) |
| 19 |
|
| 20 |
// Output: |
| 21 |
// exampleexporter |
| 22 |
} |
| 23 |
|
| 24 |
func ExampleMustNewType() { |
| 25 |
t := component.MustNewType("examplereceiver") |
| 26 |
fmt.Println(t.String()) |
| 27 |
|
| 28 |
// Output: |
| 29 |
// examplereceiver |
| 30 |
} |
| 31 |
|
| 32 |
func ExampleNewID() { |
| 33 |
t := component.MustNewType("exampleprocessor") |
| 34 |
id := component.NewID(t) |
| 35 |
fmt.Println(id.String()) |
| 36 |
|
| 37 |
// Output: |
| 38 |
// exampleprocessor |
| 39 |
} |
| 40 |
|
| 41 |
func ExampleMustNewID() { |
| 42 |
id := component.MustNewID("examplereceiver") |
| 43 |
fmt.Println(id.String()) |
| 44 |
|
| 45 |
// Output: |
| 46 |
// examplereceiver |
| 47 |
} |
| 48 |
|
| 49 |
func ExampleNewIDWithName() { |
| 50 |
t := component.MustNewType("exampleexporter") |
| 51 |
id := component.NewIDWithName(t, "customname") |
| 52 |
fmt.Println(id.String()) |
| 53 |
|
| 54 |
// Output: |
| 55 |
// exampleexporter/customname |
| 56 |
} |
| 57 |
|
| 58 |
func ExampleMustNewIDWithName() { |
| 59 |
id := component.MustNewIDWithName("exampleprocessor", "customproc") |
| 60 |
fmt.Println(id.String()) |
| 61 |
|
| 62 |
// Output: |
| 63 |
// exampleprocessor/customproc |
| 64 |
} |