Skip to content

Commit

Permalink
export ToZipkinSpanModels for use outside this library (open-telemetr…
Browse files Browse the repository at this point in the history
…y#2027)

* export ToZipkinSpanModels for use outside this library

* Update CHANGELOG.md
  • Loading branch information
coryb authored Jun 23, 2021
1 parent d5d4c87 commit 16f83ce
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion exporters/zipkin/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion exporters/zipkin/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion exporters/zipkin/zipkin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 16f83ce

Please sign in to comment.