Skip to content

Conversation

@aaron-steinfeld
Copy link
Contributor

Description

We previously allowed defining an attribute based on its string key, but certain fields in a span and trace are treated as first class and only accessible through those concrete fields. This change adds support to the attribute definition schema to access those values.

Testing

Schema change only (but used this functionality as part of an e2e verification)

Checklist:

  • My changes generate no new warnings
  • [N/A] I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@codecov
Copy link

codecov bot commented Mar 31, 2021

Codecov Report

Merging #82 (bc01bf9) into main (caef0e4) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##               main      #82   +/-   ##
=========================================
  Coverage     80.71%   80.71%           
  Complexity      222      222           
=========================================
  Files            27       27           
  Lines           752      752           
  Branches         56       56           
=========================================
  Hits            607      607           
  Misses           98       98           
  Partials         47       47           
Flag Coverage Δ Complexity Δ
integration 80.71% <ø> (ø) 0.00 <ø> (ø)
unit 67.77% <ø> (ø) 0.00 <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update caef0e4...bc01bf9. Read the comment docs.

@github-actions

This comment has been minimized.

SourceField source_field = 3;
}

enum SourceField {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be a new projection definition?

Copy link
Contributor Author

@aaron-steinfeld aaron-steinfeld Mar 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all attribute definitions eventually resolve down to data - so for example, an attribute like span.startTime needs to be able to specify it's source_field = SOURCE_FIELD_START_TIME while something like span.requestUri could already do source_path = "http.request.uri" (or whatever tag that would correspond to). The projections come in when we go a level up. So for example, let's say we introduce an alias for span.startTime called span.timestamp - that'd use an attribute_id type projection or span.duration might use an expression projection like MINUS(Span.endTime, Span.startTime). Does that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By a level up you mean like in Pinot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessarily. When we read attributes using the attribute reader ( https://github.com/hypertrace/hypertrace-ingester/blob/main/hypertrace-trace-enricher/trace-reader/src/main/java/org/hypertrace/trace/reader/attributes/DefaultValueResolver.java ), it uses the definition and recursively resolves it. So taking parts of the example before, we could imagine something like (pseudocode for brevity):

{
  id: span.startTime,
  definition: {
    source_field = SOURCE_FIELD_START_TIME
  }
},
{
  id: span.endTime,
  definition: {
    source_field = SOURCE_FIELD_END_TIME
  }
},
{
  id: span.duration,
  definition: {
    projection: {
      expression: {
        operator: MINUS,
        arguments: [
           {
              attribute_id: span.startTime,
              attribute_id: span.endTime
           }
        ]
      }
   }
}

To resolve a projection, we have to first resolve its arguments - walking down the tree until we get to the leaves which are either literals, source_path (that is, tag keys), or the new feature added here, source_field - that is, first class fields on a span/trace. Without that resolution, any projections could not use values from fields like startTime, endTime, spanId, traceId etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As to the pinot question, query service does not read source_path or source_field, it only reads projections (since those can be rewritten as new queries) .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Totally overlooked source_path. Makes sense.

@aaron-steinfeld
Copy link
Contributor Author

Updated deps first in #83

@github-actions

This comment has been minimized.

@aaron-steinfeld aaron-steinfeld merged commit a974b62 into main Mar 31, 2021
@aaron-steinfeld aaron-steinfeld deleted the first-class-attribute-projection branch March 31, 2021 20:34
@github-actions
Copy link
Contributor

Unit Test Results

20 files  ±0  20 suites  ±0   12s ⏱️ ±0s
75 tests ±0  75 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit a974b62. ± Comparison against base commit caef0e4.

@aaron-steinfeld aaron-steinfeld added the enhancement New feature or request label Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants