Skip to content

Commit

Permalink
Add TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrannajaryan committed Mar 8, 2022
1 parent e1ac17b commit f01d14a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 7 additions & 0 deletions processor/schemaprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type factory struct {
schemas map[string]*ast.Schema
}

// TODO: check if storage extension is available on the Host and use the storage
// as a cache for downloaded schemas. Load cached schemas when the processor is started.

// NewFactory returns a new factory for the schema processor.
func NewFactory() component.ProcessorFactory {
return newFactoryWithFetcher(downloadSchema)
Expand Down Expand Up @@ -120,6 +123,10 @@ func downloadSchema(context context.Context, schemaURL string) (*ast.Schema, err

schema, err := schemas.Parse(resp.Body)

// TODO: compile schema into a form that makes data transformation more efficient
// todo perform. See for example as an inspiration:
// https://github.com/tigrannajaryan/telemetry-schema/tree/main/schema/compiled

return schema, err
}

Expand Down
21 changes: 20 additions & 1 deletion processor/schemaprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,38 @@ func newSchemaProcessor(ctx context.Context, factory *factory, cfg *Config) *sch
return &schemaProcessor{factory: factory}
}

func (a *schemaProcessor) processTraces(_ context.Context, td pdata.Traces) (pdata.Traces, error) {
func (a *schemaProcessor) processTraces(ctx context.Context, td pdata.Traces) (pdata.Traces, error) {
rss := td.ResourceSpans()
for i := 0; i < rss.Len(); i++ {
rs := rss.At(i)
resource := rs.Resource()

resourceSchema, err := a.factory.getSchema(ctx, rs.SchemaUrl())
if err != nil {
// TODO: what do we do if we can't fetch the schema?
}
// TODO: use resourceSchema to transform the Resource.
// See as an inspiration for example:
// https://github.com/tigrannajaryan/telemetry-schema/blob/main/schema/converter/converter.go
_ = resourceSchema

ilss := rs.InstrumentationLibrarySpans()
for j := 0; j < ilss.Len(); j++ {
ils := ilss.At(j)
spans := ils.Spans()
library := ils.InstrumentationLibrary()

libSchema, err := a.factory.getSchema(ctx, ils.SchemaUrl())
if err != nil {
// TODO: what do we do if we can't fetch the schema?
}
_ = libSchema

for k := 0; k < spans.Len(); k++ {
span := spans.At(k)

// TODO: use resourceSchema and libSchema to transform the span.

_ = resource
_ = library
_ = span
Expand Down

0 comments on commit f01d14a

Please sign in to comment.