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

Added snowflake connector code to python application observability example #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sfc-gh-mkarjikar
Copy link
Collaborator

@sfc-gh-mkarjikar sfc-gh-mkarjikar commented Feb 18, 2025

Changes

  • Added Snowflake Connector code to Python example, equipped with trace propagation.
  • In README, the SPCS spec image name now matches the build.sh files

Testing

  • Tested in SPCS using QA6, Trace Propagation is working.

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!

@@ -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:

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.

Copy link
Collaborator

@sfc-gh-mdrach sfc-gh-mdrach left a 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))
Copy link
Collaborator

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.

Comment on lines +117 to +118
# Alternatively, retrieve the stock price from your Snowflake account
# The connector library is equipped with trace propagation
Copy link
Collaborator

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
Copy link
Collaborator

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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants