Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pkg/telemetryquerylanguage] Move contexts to package #12589

Merged
merged 11 commits into from
Jul 27, 2022
Merged
11 changes: 11 additions & 0 deletions pkg/telemetryquerylanguage/contexts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Telemetry Query Language Contexts

The Telemetry Query Language uses Contexts to bridge the gap between a [Path](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/telemetryquerylanguage/tql#paths) and an underlying data model.

A Context must provide a struct that implements `tql.TransformContext`. A context must also define a `PathExpressionParser` and a `EnumParser`.

A Context's `PathExpressionParser` is what the TQL will use to interpret a Path. For the data model being represented, it should be able to handle any incoming path and return a `GetSetter` that will be able to accurately interact with the path's corresponding field. It should return an error if the Path is not known. The `GetSetter` functions will use the Context's implementation of `tql.TransformContext` to interact with the correct item(s) during processing.

A Context's `EnumParser` is what the TQL will use to interpret an Enum Symbol. For the data model being represented, it should be able to handle any incoming Enum Symbol and return the appropriate Enum value. It should return an error if the Enum Symbol is not known.

Context implementations for Traces, Metrics, and Logs are provided by this module. It is recommended to use these contexts when using the TQL to interact with OpenTelemetry traces, metrics, and logs.
25 changes: 25 additions & 0 deletions pkg/telemetryquerylanguage/contexts/logs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Logs Context

The Logs Context is a Context implementation for [pdata Logs](https://github.com/open-telemetry/opentelemetry-collector/tree/main/pdata/plog), the collector's internal representation for OTLP log data. This Context should be used when interacted with OTLP logs.

## Paths
In general, the Logs Context supports accessing pdata using the field names from the [logs proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/logs/v1/logs.proto). All integers are returned and set via `int64`. All doubles are returned and set via `float64`.

The following fields are the exception.

| path | field accessed | type |
|-------------------------------|-----------------------------------------------------------------|-------------------------------------------------------------------------|
| resource | resource of the log being processed | pcommon.Resource |
| resource.attributes | resource attributes of the log being processed | pcommon.Map |
| resource.attributes\[""\] | the value of the resource attribute of the log being processed | string, bool, int64, float64, pcommon.Map, pcommon.Slice, []byte or nil |
| instrumentation_scope | instrumentation scope of the log being processed | pcommon.InstrumentationScope |
| instrumentation_scope.name | name of the instrumentation scope of the log being processed | string |
| instrumentation_scope.version | version of the instrumentation scope of the log being processed | string |
| attributes | attributes of the log being processed | pcommon.Map |
| attributes\[""\] | the value of the attribute of the log being processed | string, bool, int64, float64, pcommon.Map, pcommon.Slice, []byte or nil |
| trace_id.string | a string representation of the trace id | string |
| span_id.string | a string representation of the span id | string |

## Enums

The Logs Context supports the enum names from the [logs proto](https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/logs/v1/logs.proto).
Loading