@@ -39,7 +39,7 @@ func ReadMetrics(filePath string) (pmetric.Metrics, error) {
39
39
40
40
// WriteMetrics writes a pmetric.Metrics to the specified file in YAML format.
41
41
func WriteMetrics (tb testing.TB , filePath string , metrics pmetric.Metrics , opts ... WriteMetricsOption ) error {
42
- if err := writeMetrics (filePath , metrics , opts ... ); err != nil {
42
+ if err := WriteMetricsToFile (filePath , metrics , opts ... ); err != nil {
43
43
return err
44
44
}
45
45
tb .Logf ("Golden file successfully written to %s." , filePath )
@@ -68,8 +68,9 @@ func MarshalMetricsYAML(metrics pmetric.Metrics) ([]byte, error) {
68
68
return b .Bytes (), nil
69
69
}
70
70
71
- // writeMetrics writes a pmetric.Metrics to the specified file in YAML format.
72
- func writeMetrics (filePath string , metrics pmetric.Metrics , opts ... WriteMetricsOption ) error {
71
+ // WriteMetricsToFile writes a pmetric.Metrics to the specified file in YAML format.
72
+ // Prefer using WriteMetrics in tests.
73
+ func WriteMetricsToFile (filePath string , metrics pmetric.Metrics , opts ... WriteMetricsOption ) error {
73
74
optsStruct := writeMetricsOptions {
74
75
normalizeTimestamps : true ,
75
76
}
@@ -112,7 +113,7 @@ func ReadLogs(filePath string) (plog.Logs, error) {
112
113
113
114
// WriteLogs writes a plog.Logs to the specified file in YAML format.
114
115
func WriteLogs (tb testing.TB , filePath string , logs plog.Logs ) error {
115
- if err := writeLogs (filePath , logs ); err != nil {
116
+ if err := WriteLogsToFile (filePath , logs ); err != nil {
116
117
return err
117
118
}
118
119
tb .Logf ("Golden file successfully written to %s." , filePath )
@@ -121,8 +122,9 @@ func WriteLogs(tb testing.TB, filePath string, logs plog.Logs) error {
121
122
return nil
122
123
}
123
124
124
- // writeLogs writes a plog.Logs to the specified file in YAML format.
125
- func writeLogs (filePath string , logs plog.Logs ) error {
125
+ // WriteLogsToFile writes a plog.Logs to the specified file in YAML format.
126
+ // Prefer using WriteLogs in tests.
127
+ func WriteLogsToFile (filePath string , logs plog.Logs ) error {
126
128
unmarshaler := & plog.JSONMarshaler {}
127
129
fileBytes , err := unmarshaler .MarshalLogs (logs )
128
130
if err != nil {
@@ -163,7 +165,7 @@ func ReadTraces(filePath string) (ptrace.Traces, error) {
163
165
164
166
// WriteTraces writes a ptrace.Traces to the specified file in YAML format.
165
167
func WriteTraces (tb testing.TB , filePath string , traces ptrace.Traces ) error {
166
- if err := writeTraces (filePath , traces ); err != nil {
168
+ if err := WriteTracesToFile (filePath , traces ); err != nil {
167
169
return err
168
170
}
169
171
tb .Logf ("Golden file successfully written to %s." , filePath )
@@ -172,8 +174,9 @@ func WriteTraces(tb testing.TB, filePath string, traces ptrace.Traces) error {
172
174
return nil
173
175
}
174
176
175
- // writeTraces writes a ptrace.Traces to the specified file
176
- func writeTraces (filePath string , traces ptrace.Traces ) error {
177
+ // WriteTracesToFile writes a ptrace.Traces to the specified file
178
+ // Prefer using WriteTraces in tests.
179
+ func WriteTracesToFile (filePath string , traces ptrace.Traces ) error {
177
180
unmarshaler := & ptrace.JSONMarshaler {}
178
181
fileBytes , err := unmarshaler .MarshalTraces (traces )
179
182
if err != nil {
@@ -214,7 +217,7 @@ func ReadProfiles(filePath string) (pprofile.Profiles, error) {
214
217
215
218
// WriteProfiles writes a pprofile.Profiles to the specified file in YAML format.
216
219
func WriteProfiles (tb testing.TB , filePath string , profiles pprofile.Profiles ) error {
217
- if err := writeProfiles (filePath , profiles ); err != nil {
220
+ if err := WriteProfilesToFile (filePath , profiles ); err != nil {
218
221
return err
219
222
}
220
223
tb .Logf ("Golden file successfully written to %s." , filePath )
@@ -223,8 +226,9 @@ func WriteProfiles(tb testing.TB, filePath string, profiles pprofile.Profiles) e
223
226
return nil
224
227
}
225
228
226
- // writeProfiles writes a pprofile.Profiles to the specified file in YAML format.
227
- func writeProfiles (filePath string , profiles pprofile.Profiles ) error {
229
+ // WriteProfilesToFile writes a pprofile.Profiles to the specified file in YAML format.
230
+ // Prefer using WriteProfiles in tests.
231
+ func WriteProfilesToFile (filePath string , profiles pprofile.Profiles ) error {
228
232
unmarshaler := & pprofile.JSONMarshaler {}
229
233
fileBytes , err := unmarshaler .MarshalProfiles (profiles )
230
234
if err != nil {
0 commit comments