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/ottl] Add SpanEvent context #14907

Merged
merged 14 commits into from
Oct 31, 2022

Conversation

TylerHelmuth
Copy link
Member

Description:
Adds a new context specific to Span Events to allow for specific and efficient access to Span Event telemetry.

Link to tracking Issue:
#14578

Testing:
Added unit tests

Documentation:
Added context documentation

@TylerHelmuth TylerHelmuth requested a review from a team October 12, 2022 18:22
@bogdandrutu
Copy link
Member

I don't think "span event" needs to be a context... Do you have any use-case in mind?

@TylerHelmuth
Copy link
Member Author

TylerHelmuth commented Oct 12, 2022

I don't think "span event" needs to be a context... Do you have any use-case in mind?

@bogdandrutu filtering SpanEvents is my current goal. But in general, if someone wants to modify SpanEvents with OTTL it'll need a context.

@bogdandrutu
Copy link
Member

filtering SpanEvents is my current goal

If only one use-case for the moment, can we find a workaround?

@TylerHelmuth
Copy link
Member Author

If only one use-case for the moment, can we find a workaround?

It might be possible to add a function that would allow users to pass in the names or attributes that the should be dropped, but I think it would be messier, and not as functional, as a context. The traces context provides no access to individual span values, so users could not do spanevent.name == "test" or spanevent.attributes["test"] == "test".

If you want, I can build out what I want drop to look like to show you how this context helps significantly. On top of the benefit it provides to transform span events, which is currently impossible in the transformprocess/ottl,

Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

Looks good to me from a code perspective, just a few nitpicks.

I think this makes sense as a separate context, as there is no map function or looping construct in the OTTL that would permit transformations on a slice of span events within another context. Even if we could loop over slice values, this should simplify things when doing transformations focused on span events.

pkg/ottl/contexts/ottlspanevents/README.md Outdated Show resolved Hide resolved
pkg/ottl/contexts/ottlspanevents/span_events.go Outdated Show resolved Hide resolved
pkg/ottl/contexts/ottltraces/traces.go Outdated Show resolved Hide resolved
@TylerHelmuth
Copy link
Member Author

Even if we could loop over slice values, this should simplify things when doing transformations focused on span events.

I think this is the key value that this contexts adds. There are situations where individual manipulation of SpanEvents will be necessary, and a context provides a user-friendly syntax that allows reusing all the ottl's existing functions and its condition framework.

We will also run into similar needs with SpanLinks, Examplars, and QuartileValues. Each of these objects, like SpanEvents, cannot currently be manipulated. I think the context concept built into the OTTL provides the perfect mechanism for gaining access to these objects for transformation.

Copy link
Member

@kentquirk kentquirk left a comment

Choose a reason for hiding this comment

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

Tyler and I reviewed this on a zoom call:

  • Someday we'd like to refactor the big switch statement in the *PathGetSetter() function(s) but not as part of this.
  • Similarly, I would like to think harder about trying to reduce the redundancy in the StandardGetSetter functions if possible, but it's a separate refactor.
  • Much of this PR is just moving code around so it looks bigger than it is.
  • This is step 1 of a multi-stage collection of changes.

In terms of "do we need a new context here" I think the answer is definitely yes. A context is the fundamental tool that we use to access elements of the data in OTTL, and we should be creating all the contexts we need to do everything. There is work ongoing to reduce the size and complexity of contexts by making them more general and resuable, and that's the direction we should continue.

@TylerHelmuth
Copy link
Member Author

@bogdandrutu please review

// See the License for the specific language governing permissions and
// limitations under the License.

package ottlspanevents // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlspanevents"
Copy link
Member

Choose a reason for hiding this comment

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

Should we use ottlspanevent instead? True for other places like the datapoint?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ya we aren't consistent. I agree singular is better. I will get this PR updated and then update other contexts in another PR. Also, I think we should rename ottltraces to ottlspan.

@TylerHelmuth TylerHelmuth added the ready to merge Code review completed; ready to merge by maintainers label Oct 31, 2022
@bogdandrutu bogdandrutu merged commit 889c321 into open-telemetry:main Oct 31, 2022
@TylerHelmuth TylerHelmuth deleted the ottl-spanevents-context branch October 31, 2022 23:35
shalper2 pushed a commit to shalper2/opentelemetry-collector-contrib that referenced this pull request Dec 6, 2022
* Add SpanEvent context

* add changelog entry and fix lint

* ran make goporto

* Apply feedback

* Fix test

* Share span symbol table

* fix lint

* Rename to ottlspanevent
@plantfansam plantfansam mentioned this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants