@@ -13,7 +13,7 @@ resource_metrics:
13
13
- attributes :
14
14
a_resource_attribute : a_value
15
15
another_resource_attribute : another_value
16
- ilms :
16
+ instrumentation_library_metrics :
17
17
- instrumentation_library :
18
18
name : a library
19
19
version : some version
@@ -32,7 +32,7 @@ resource_metrics:
32
32
label_one : value_one
33
33
label_two : value_two
34
34
value : -123.456
35
- - ilms :
35
+ - instrumentation_library_metrics :
36
36
- instrumentation_library :
37
37
name : an instrumentation library from a different resource without attributes
38
38
metrics :
@@ -60,3 +60,38 @@ Using `PDataToResourceMetrics(myReceivedPDataMetrics)` you can use the assertion
60
60
` ResourceMetrics` are the same as those received in your test case. `FlattenResourceMetrics()` is a good way to "normalize"
61
61
metrics received over time to ensure that only unique datapoints are represented, and that all unique Resources and
62
62
Instrumentation Libraries have a single item.
63
+
64
+ # ## Test Containers
65
+
66
+ The Testcontainers project is a popular testing resource for easy container creation and usage for a number of languages
67
+ including [Go](https://github.com/testcontainers/testcontainers-go). The `testutils` package provides a helpful [container
68
+ builder and wrapper library](./container.go) to avoid needing direct Docker api usage :
69
+
70
+ ` ` ` go
71
+ import "github.com/signafx/splunk-otel-collector/tests/testutils"
72
+
73
+ myContainerFromImageName := testutils.NewContainer().WithImage(
74
+ "my-docker-image:123.4-alpine",
75
+ ).WithEnvVar("MY_ENV_VAR", "ENV_VAR_VALUE",
76
+ ).WithExposedPorts("12345:12345").WillWaitForPorts("12345",
77
+ ).WillWaitForLogs(
78
+ "My container is running and ready for interaction"
79
+ ).Build()
80
+
81
+ // After building, ` myContainerFromImageName` implements the testscontainer.Container interface
82
+ err := myContainerFromImageName.Start(context.Background())
83
+
84
+ myContainerFromBuildContext := testutils.NewContainer().WithContext(
85
+ " ./directory_with_dockerfile_and_resources" ,
86
+ ).WithEnv(map[string]string{
87
+ " MY_ENV_VAR_1 " : " value1" ,
88
+ " MY_ENV_VAR_2 " : " value2" ,
89
+ " MY_ENV_VAR_3 " : " value3" ,
90
+ }).WithExposedPorts("23456:23456", "34567:34567",
91
+ ).WillWaitForPorts("23456", "34567",
92
+ ).WillWaitForLogs(
93
+ " My container is running." , "My container is ready for interaction"
94
+ ).Build()
95
+
96
+ err = myContainerFromBuildContext.Start(context.Background())
97
+ ```
0 commit comments