-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new_sdk/main
- Loading branch information
Showing
49 changed files
with
429 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# OpenTelemetry Exporters | ||
|
||
Once the OpenTelemetry SDK has created and processed telemetry, it needs to be exported. | ||
This package contains exporters for this purpose. | ||
|
||
## Exporter Packages | ||
|
||
The following exporter packages are provided with the following OpenTelemetry signal support. | ||
|
||
| Exporter Package | Metrics | Traces | | ||
| :-----------------------------------------------------------------------------: | :-----: | :----: | | ||
| [go.opentelemetry.io/otel/exporters/jaeger](./jaeger) | | ✓ | | ||
| [go.opentelemetry.io/otel/exporters/otlp/otlpmetric](./otlp/otlpmetric) | ✓ | | | ||
| [go.opentelemetry.io/otel/exporters/otlp/otlptrace](./otlp/otlptrace) | | ✓ | | ||
| [go.opentelemetry.io/otel/exporters/prometheus](./prometheus) | ✓ | | | ||
| [go.opentelemetry.io/otel/exporters/stdout/stdoutmetric](./stdout/stdoutmetric) | ✓ | | | ||
| [go.opentelemetry.io/otel/exporters/stdout/stdouttrace](./stdout/stdouttrace) | | ✓ | | ||
| [go.opentelemetry.io/otel/exporters/zipkin](./zipkin) | | ✓ | | ||
|
||
See the [OpenTelemetry registry] for 3rd-part exporters compatible with this project. | ||
|
||
[OpenTelemetry registry]: https://opentelemetry.io/registry/?language=go&component=exporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal" | ||
|
||
import "fmt" | ||
|
||
// PartialSuccessDropKind indicates the kind of partial success error | ||
// received by an OTLP exporter, which corresponds with the signal | ||
// being exported. | ||
type PartialSuccessDropKind string | ||
|
||
const ( | ||
// TracingPartialSuccess indicates that some spans were rejected. | ||
TracingPartialSuccess PartialSuccessDropKind = "spans" | ||
|
||
// MetricsPartialSuccess indicates that some metric data points were rejected. | ||
MetricsPartialSuccess PartialSuccessDropKind = "metric data points" | ||
) | ||
|
||
// PartialSuccess represents the underlying error for all handling | ||
// OTLP partial success messages. Use `errors.Is(err, | ||
// PartialSuccess{})` to test whether an error passed to the OTel | ||
// error handler belongs to this category. | ||
type PartialSuccess struct { | ||
ErrorMessage string | ||
RejectedItems int64 | ||
RejectedKind PartialSuccessDropKind | ||
} | ||
|
||
var _ error = PartialSuccess{} | ||
|
||
// Error implements the error interface. | ||
func (ps PartialSuccess) Error() string { | ||
msg := ps.ErrorMessage | ||
if msg == "" { | ||
msg = "empty message" | ||
} | ||
return fmt.Sprintf("OTLP partial success: %s (%d %s rejected)", msg, ps.RejectedItems, ps.RejectedKind) | ||
} | ||
|
||
// Is supports the errors.Is() interface. | ||
func (ps PartialSuccess) Is(err error) bool { | ||
_, ok := err.(PartialSuccess) | ||
return ok | ||
} | ||
|
||
// PartialSuccessToError produces an error suitable for passing to | ||
// `otel.Handle()` out of the fields in a partial success response, | ||
// independent of which signal produced the outcome. | ||
func PartialSuccessToError(kind PartialSuccessDropKind, itemsRejected int64, errorMessage string) error { | ||
return PartialSuccess{ | ||
ErrorMessage: errorMessage, | ||
RejectedItems: itemsRejected, | ||
RejectedKind: kind, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package internal // import "go.opentelemetry.io/otel/exporters/otlp/internal" | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func requireErrorString(t *testing.T, expect string, err error) { | ||
t.Helper() | ||
require.NotNil(t, err) | ||
require.Error(t, err) | ||
require.True(t, errors.Is(err, PartialSuccess{})) | ||
|
||
const pfx = "OTLP 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 metric data points rejected)", PartialSuccessToError(MetricsPartialSuccess, 0, "")) | ||
requireErrorString(t, "help help (0 metric data points rejected)", PartialSuccessToError(MetricsPartialSuccess, 0, "help help")) | ||
requireErrorString(t, "what happened (10 metric data points rejected)", PartialSuccessToError(MetricsPartialSuccess, 10, "what happened")) | ||
requireErrorString(t, "what happened (15 spans rejected)", PartialSuccessToError(TracingPartialSuccess, 15, "what happened")) | ||
requireErrorString(t, "empty message (7 log records rejected)", PartialSuccessToError("log records", 7, "")) | ||
} |
Oops, something went wrong.