You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
768e930779
a part of #7020 ```txt goos: windows goarch: amd64 pkg: go.opentelemetry.io/otel/exporters/stdout/stdoutlog/internal/observ cpu: Intel(R) Core(TM) i7-14700 │ result.txt │ │ sec/op │ InstrumentationExportLogs/NoError-28 47.68n ± 5% InstrumentationExportLogs/PartialError-28 471.6n ± 2% InstrumentationExportLogs/FullError-28 471.9n ± 10% geomean 219.7n │ result.txt │ │ B/op │ InstrumentationExportLogs/NoError-28 0.000 ± 0% InstrumentationExportLogs/PartialError-28 305.0 ± 0% InstrumentationExportLogs/FullError-28 305.0 ± 0% geomean ¹ ¹ summaries must be >0 to compute geomean │ result.txt │ │ allocs/op │ InstrumentationExportLogs/NoError-28 0.000 ± 0% InstrumentationExportLogs/PartialError-28 4.000 ± 0% InstrumentationExportLogs/FullError-28 4.000 ± 0% geomean ¹ ¹ summaries must be >0 to compute geomean ``` --------- Co-authored-by: Damien Mathieu <42@dmathieu.com>
35 lines
912 B
Go
35 lines
912 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package internal
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func requireErrorString(t *testing.T, expect string, err error) {
|
|
t.Helper()
|
|
require.Error(t, err)
|
|
require.ErrorIs(t, err, PartialSuccess{})
|
|
|
|
const pfx = "stdoutlog partial success: "
|
|
|
|
msg := err.Error()
|
|
require.True(t, strings.HasPrefix(msg, pfx))
|
|
require.Equal(t, expect, msg[len(pfx):])
|
|
}
|
|
|
|
func TestPartialSuccessFormat(t *testing.T) {
|
|
requireErrorString(t, "empty message (0 logs failed)", LogPartialSuccessError(0, ""))
|
|
requireErrorString(t, "help help (0 logs failed)", LogPartialSuccessError(0, "help help"))
|
|
requireErrorString(
|
|
t,
|
|
"what happened (10 logs failed)",
|
|
LogPartialSuccessError(10, "what happened"),
|
|
)
|
|
requireErrorString(t, "what happened (15 logs failed)", LogPartialSuccessError(15, "what happened"))
|
|
}
|