Skip to content

Commit d2ec70e

Browse files
Make Span kind an enum in otel.stef (#202)
Resolves #200
1 parent 0baad35 commit d2ec70e

File tree

7 files changed

+48
-12
lines changed

7 files changed

+48
-12
lines changed

go/otel/otel.stef

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct Span {
4242
ParentSpanID bytes
4343
Flags uint64
4444
Name string dict(SpanName)
45-
Kind uint64
45+
Kind SpanKind
4646
StartTimeUnixNano uint64
4747
EndTimeUnixNano uint64
4848
Attributes Attributes
@@ -52,6 +52,15 @@ struct Span {
5252
Status SpanStatus
5353
}
5454

55+
enum SpanKind {
56+
Unspecified = 0
57+
Internal = 1
58+
Server = 2
59+
Client = 3
60+
Producer = 4
61+
Consumer = 5
62+
}
63+
5564
oneof PointValue {
5665
Int64 int64
5766
Float64 float64

go/otel/oteltef/common.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/otel/oteltef/span.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/otel/oteltef/spankind.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/pdata/traces/otlp2stef_unsorted.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func span2span(src ptrace.Span, dst *oteltef.Span, otlp2tef *otlptools.Otlp2Stef
125125
dst.SetFlags(uint64(src.Flags()))
126126
dst.SetStartTimeUnixNano(uint64(src.StartTimestamp()))
127127
dst.SetEndTimeUnixNano(uint64(src.EndTimestamp()))
128-
dst.SetKind(uint64(src.Kind()))
128+
dst.SetKind(oteltef.SpanKind(src.Kind()))
129129
dst.SetTraceState(src.TraceState().AsRaw())
130130
if sorted {
131131
otlp2tef.MapSorted(src.Attributes(), dst.Attributes())

java/src/main/java/com/example/oteltef/Span.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ void mutateRandom(Random random) {
703703
}
704704

705705
if (random.nextInt(fieldCount) == 0) {
706-
this.setKind(Types.Uint64Random(random));
706+
this.setKind((Types.Uint64Random(random) & 0x7FFFFFFFFFFFFFFFL) % 6);
707707
}
708708

709709
if (random.nextInt(fieldCount) == 0) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Code generated by stefc. DO NOT EDIT.
2+
package com.example.oteltef;
3+
4+
public class SpanKind {
5+
public static final long Unspecified = 0;
6+
public static final long Internal = 1;
7+
public static final long Server = 2;
8+
public static final long Client = 3;
9+
public static final long Producer = 4;
10+
public static final long Consumer = 5;
11+
12+
// Private constructor to prevent instantiation
13+
private SpanKind() {}
14+
}

0 commit comments

Comments
 (0)