Skip to content

Commit

Permalink
Switch generator to use STEF IDL (#53)
Browse files Browse the repository at this point in the history
The generator now uses STEF IDL format as the input instead of JSON.
I regenerated all serializers and the diff is 0, we got exact match.

There are a few remaining schema tests that still use the JSON
format as testdata. I will clean this up in a future PR, it will
require a bit of refactoring.
  • Loading branch information
tigrannajaryan authored Feb 27, 2025
1 parent 2d112e0 commit 636488c
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 758 deletions.
2 changes: 1 addition & 1 deletion go/otel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Otel/STEF is a representation of OpenTelemetry data model in
[STEF](/stef-spec/specification.md) format.

OTEL/STEF schema definition is [here](oteltef.wire.json). Reader/Writer Go code is generated from the
OTEL/STEF schema definition is [here](otel.stef). Reader/Writer Go code is generated from the
schema and is placed in [oteltef](oteltef) directory.

To re-generate Reader/Writer run `make generate`.
2 changes: 1 addition & 1 deletion go/otel/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ build:

generate:
cd ../../stefgen && make build
../../stefgen/bin/stefgen oteltef.wire.json
../../stefgen/bin/stefgen otel.stef
151 changes: 151 additions & 0 deletions go/otel/otel.stef
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// This is Otel/STEF schema: a representation of OpenTelemetry data model
// as STEF records. Data model is virtually a direct mapping from OpenTelemetry
// Protobuf IDL for metrics and traces, see: https://github.com/open-telemetry/opentelemetry-proto/tree/main/opentelemetry/proto
// TODO: add Logs and Profiles.

package oteltef

multimap Attributes {
key string dict(AttributeKey)
value AnyValue
}

multimap EnvelopeAttributes {
key string
value bytes
}

multimap KeyValueList {
key string
value AnyValue
}

struct Resource dict(Resource) {
// All SchemaURL fields use the same (shared) dict.
SchemaURL string dict(SchemaURL)
Attributes Attributes
DroppedAttributesCount uint64
}

// Point represents a metric data point.
struct Point {
StartTimestamp uint64
Timestamp uint64
Value PointValue
Exemplars []Exemplar
}

struct Span {
TraceID bytes
SpanID bytes
TraceState string
ParentSpanID bytes
Flags uint64
Name string dict(SpanName)
Kind uint64
StartTimeUnixNano uint64
EndTimeUnixNano uint64
Attributes Attributes
DroppedAttributesCount uint64
Events []Event
Links []Link
Status SpanStatus
}

oneof PointValue {
Int64 int64
Float64 float64
Histogram HistogramValue
// TODO: Add Summary and Exponential Histogram value support.
}

struct Metric dict(Metric) {
Name string dict(MetricName)
Description string dict(MetricDescription)
Unit string dict(MetricUnit)
Type uint64
Metadata Attributes
HistogramBounds []float64
AggregationTemporality uint64
Monotonic bool
}

struct Metrics root {
Envelope Envelope
Metric Metric
Resource Resource
Scope Scope
Attributes Attributes
Point Point
}

struct Scope dict(Scope) {
Name string dict(ScopeName)
Version string dict(ScopeVersion)
SchemaURL string dict(SchemaURL)
Attributes Attributes
DroppedAttributesCount uint64
}

struct Link {
TraceID bytes
SpanID bytes
TraceState string
Flags uint64
Attributes Attributes
DroppedAttributesCount uint64
}

struct HistogramValue {
Count int64
Sum float64 optional
Min float64 optional
Max float64 optional
BucketCounts []int64
}

oneof AnyValue {
String string dict(AnyValueString)
Bool bool
Int64 int64
Float64 float64
Array []AnyValue
KVList KeyValueList
Bytes bytes
}

struct Event {
Name string dict(SpanEventName)
TimeUnixNano uint64
Attributes Attributes
DroppedAttributesCount uint64
}

struct SpanStatus {
Message string
Code uint64
}

struct Spans root {
Envelope Envelope
Resource Resource
Scope Scope
Span Span
}

struct Envelope {
Attributes EnvelopeAttributes
}

struct Exemplar {
Timestamp uint64
Value ExemplarValue
SpanID bytes
TraceID bytes
FilteredAttributes Attributes
}

oneof ExemplarValue {
Int64 int64
Float64 float64
}
Loading

0 comments on commit 636488c

Please sign in to comment.