mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-10 00:29:12 +02:00
export ToZipkinSpanModels for use outside this library (#2027)
* export ToZipkinSpanModels for use outside this library * Update CHANGELOG.md
This commit is contained in:
parent
d5d4c87f6d
commit
16f83ce689
@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||||||
|
|
||||||
### Changed
|
### 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
|
### Deprecated
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
@ -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))
|
models := make([]zkmodel.SpanModel, 0, len(batch))
|
||||||
for _, data := range batch {
|
for _, data := range batch {
|
||||||
models = append(models, toZipkinSpanModel(data))
|
models = append(models, toZipkinSpanModel(data))
|
||||||
|
@ -715,7 +715,7 @@ func TestModelConversion(t *testing.T) {
|
|||||||
Tags: nil, // should be omitted
|
Tags: nil, // should be omitted
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
gottenOutputBatch := toZipkinSpanModels(inputBatch)
|
gottenOutputBatch := SpanModels(inputBatch)
|
||||||
require.Equal(t, expectedOutputBatch, gottenOutputBatch)
|
require.Equal(t, expectedOutputBatch, gottenOutputBatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ func (e *Exporter) ExportSpans(ctx context.Context, spans []sdktrace.ReadOnlySpa
|
|||||||
e.logf("no spans to export")
|
e.logf("no spans to export")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
models := toZipkinSpanModels(spans)
|
models := SpanModels(spans)
|
||||||
body, err := json.Marshal(models)
|
body, err := json.Marshal(models)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return e.errf("failed to serialize zipkin models to JSON: %v", err)
|
return e.errf("failed to serialize zipkin models to JSON: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user