diff --git a/CHANGELOG.md b/CHANGELOG.md index 3891d7ba275..7f48318f753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Changed +- The `SpanModels` function is now exported from the `go.opentelemetry.io/otel/exporters/zipkin` package to convert OpenTelemetry spans into Zipkin model spans. (#2027) + ### Deprecated ### Removed diff --git a/exporters/zipkin/model.go b/exporters/zipkin/model.go index 55c991fb3ff..93f5e64ada3 100644 --- a/exporters/zipkin/model.go +++ b/exporters/zipkin/model.go @@ -51,7 +51,9 @@ func init() { } } -func toZipkinSpanModels(batch []tracesdk.ReadOnlySpan) []zkmodel.SpanModel { +// SpanModels converts OpenTelemetry spans into Zipkin model spans. +// This is used for exporting to Zipkin compatible tracing services. +func SpanModels(batch []tracesdk.ReadOnlySpan) []zkmodel.SpanModel { models := make([]zkmodel.SpanModel, 0, len(batch)) for _, data := range batch { models = append(models, toZipkinSpanModel(data)) diff --git a/exporters/zipkin/model_test.go b/exporters/zipkin/model_test.go index 970040a0a1d..7ee136951a7 100644 --- a/exporters/zipkin/model_test.go +++ b/exporters/zipkin/model_test.go @@ -715,7 +715,7 @@ func TestModelConversion(t *testing.T) { Tags: nil, // should be omitted }, } - gottenOutputBatch := toZipkinSpanModels(inputBatch) + gottenOutputBatch := SpanModels(inputBatch) require.Equal(t, expectedOutputBatch, gottenOutputBatch) } diff --git a/exporters/zipkin/zipkin.go b/exporters/zipkin/zipkin.go index 5d09a47355a..d9fb1604fda 100644 --- a/exporters/zipkin/zipkin.go +++ b/exporters/zipkin/zipkin.go @@ -126,7 +126,7 @@ func (e *Exporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpa e.logf("no spans to export") return nil } - models := toZipkinSpanModels(spans) + models := SpanModels(spans) body, err := json.Marshal(models) if err != nil { return e.errf("failed to serialize zipkin models to JSON: %v", err)