-
Notifications
You must be signed in to change notification settings - Fork 198
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
Change recording to create a span of type "record_root" #1703
base: garett/move-span-out
Are you sure you want to change the base?
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
9ab5db6
to
049b404
Compare
712f97b
to
c9db9a1
Compare
27bcac5
to
e1b685c
Compare
6e3c22f
to
6b063f5
Compare
6b063f5
to
d300f67
Compare
14869e1
to
8527ed1
Compare
try: | ||
ret = func(*args, **kwargs) | ||
except Exception as e: | ||
# We want to get into the next clause to allow the users to still add attributes. | ||
# It's on the user to deal with None as a return value. | ||
func_exception = e | ||
|
||
if span_type == SpanAttributes.SpanType.MAIN: | ||
all_args = list(args) + list(kwargs.values()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this for like 15 minutes just now because I don't love this for a few reasons, but I honestly can't think of a good solution to the things that bother me. My main issues are:
- If there are kwargs we won't know what keyword they map to.
- It's quite likely the first arg is self which I doubt anyone cares to see the string representation of.
- I'm not sure if we should just error out if theres multiple inputs (e.g. if
all_args
is `[self, "hi", "bye"]).
Anyway if you can think of a nicer way I'm all ears but I'm not blocking this approach since it's not like I can see a good approach to replace it with.
e1e15cd
to
7ae9b24
Compare
39ad3b8
to
01bf338
Compare
04b6c50
to
83c4d06
Compare
01bf338
to
5013461
Compare
83c4d06
to
c6a8462
Compare
|
||
def set_main_span_attributes( | ||
span: Span, | ||
/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the remaining args to be positional and kwargs for code readability, happy to change this
5013461
to
65544c9
Compare
54488fa
to
f3c9e22
Compare
Description
Updated the app context manager to be able to create a span of type "record_root"
Other details good to know for developers
The general approach is the following:
TruApp
's context manager - we create a span of typeRECORD_ROOT
. This is necessary because:a. we're relying on the context manager to do things such as running/deferring the feedback function on record completion
b. The user might already be actively tracing, so we need a point for which we identify the calls that belong to the record
MAIN
, intended for the main entrypoint into the app's calls.a. This is because we do not have control over what happens within the recording context, so there might be scenarios where the user can call non-instrumented functions, that we have no way of tracking the input/outputs of.
Type of change
not work as expected)
Important
Add
RECORD_ROOT
andMAIN
span types toTruApp
context manager for improved recording and tracing.RECORD_ROOT
span type inTruApp
context manager inapp.py
to manage recording contexts.MAIN
span type ininstrument.py
for main entry points.instrument()
ininstrument.py
to handleMAIN
span type.set_main_span_attributes()
inspan.py
to set attributes forMAIN
spans.test_otel_instrument.py
to test new span types and attributes.MAIN
andRECORD_ROOT
spans.tokens
andspan_context
attributes toApp
class inapp.py
for context management.app.py
to useOTELApp
frominstrument.py
.This description was created by for f3c9e22. It will automatically update as commits are pushed.