-
Notifications
You must be signed in to change notification settings - Fork 4
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
Added snowflake connector code to python application observability example #38
base: main
Are you sure you want to change the base?
Conversation
…o fixed spcs spec.
@@ -80,14 +81,19 @@ | |||
callbacks=[lambda options: [Observation(value=len(stock_prices))]] | |||
) | |||
|
|||
# Get authorization token from SPCS environment | |||
def get_login_token(): | |||
with open('/snowflake/session/token', 'r') as f: |
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.
Can we update README with instructions about how to generate this file? Also, a comment about trace propagation in the README with the corresponding event table queries would be nice.
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.
Left some comments. Have we tested this and seen query trace spans nested correctly beneath the service's calling span?
conn.commit() | ||
|
||
except Exception as e: | ||
print(str(e)) |
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.
Just raise this exception instead of wrapping in print
.
# Alternatively, retrieve the stock price from your Snowflake account | ||
# The connector library is equipped with trace propagation |
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.
Can you create a separate endpoint for this? Seems kind of funky to just append this after the alternative way of retrieving this data.
Also, explain at least at a high level why this data is available in the account (pretend that you are a customer reading this documentation. For example:
"Alternatively, the below example shows how you would retrieve data from a Snowflake table. The snowflake.connector library automatically propagates the trace id to snowflake query engine. This ensures that queries generated by Snowflake query engine will be properly nested within this calling function span."
@@ -80,14 +81,19 @@ | |||
callbacks=[lambda options: [Observation(value=len(stock_prices))]] | |||
) | |||
|
|||
# Get authorization token from SPCS environment |
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.
"Containers managed by Snowpark Container Services makes an oauth login token available at the following path. This token authenticates as the service role, which inherits permissions from the service creator."
Changes
Testing
Notes to reviewers
I tried to integrate the snowflake connector code in a natural way - as an alternative way to retrieve a stock price for a symbol. Let me know if something else would make more sense!