Skip to content

Commit

Permalink
export ToZipkinSpanModels for use outside this library
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Jun 22, 2021
1 parent d6e8f60 commit a2f0d2b
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 @@ -12,6 +12,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed

- SpanModels renamed to be exported from exporters/zipkin package

### 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 a2f0d2b

Please sign in to comment.