-
Notifications
You must be signed in to change notification settings - Fork 163
fix: Redact sensitive data from OTEL traces and fix env var parsing #1553
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
base: main
Are you sure you want to change the base?
Conversation
7c4be24
to
91f04b2
Compare
val = os.environ.get(name, None) | ||
if val is None: | ||
return default | ||
return str(val).strip().lower() in {"1", "true", "yes", "on"} |
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.
nit: coercing to str is not required. Just val.strip().lower()
should work fine because output from os.environ.get
is always str or None. If None, it's caught in line35 and default
is returned.
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.
We need to add one more unit test . It should test that tracing are disabled when a user sets ENABLE_GCS_PYTHON_CLIENT_OTEL_TRACES
to False (or any value other than {1, true, on, yes} )
ie negative unit test of test_enable_trace_yield_span
full_url = client._connection.build_api_url(request.get("path")) | ||
attr.update(_get_opentelemetry_attributes_from_url(full_url, strip_query=True)) | ||
if "timeout" in request: | ||
attr["connect_timeout,read_timeout"] = str(request.get("timeout")) |
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.
there's no need to change timeout section of the code and convert into str()
"server.address": "testOtel.org", | ||
"url.path": "/foo/bar/baz", | ||
"url.scheme": "https", | ||
"connect_timeout,read_timeout": str((100, 100)), |
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.
if we don't change timeout
param in the production file, we need not change the same here in test file.
fix: Redact sensitive data from OTEL traces and fix env var parsing
Summary
This PR addresses two key improvements:
Redaction of Sensitive Data in OTEL Traces:
Robust Environment Variable Parsing:
Details
Motivation
Related Links
Please let me know if further changes or clarifications are needed.