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

PoC: Telemetry for Data.read #12385

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data.enso
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import project.Any.Any
import project.Data.Download.Download_Mode.Download_Mode
import project.Data.Dictionary.Dictionary
import project.Data.Pair.Pair
import project.Data.Read.Many_Files_List.Many_Files_List
import project.Data.Read.Return_As.Return_As
Expand All @@ -16,6 +17,7 @@ import project.Errors.File_Error.File_Error
import project.Errors.Illegal_Argument.Illegal_Argument
import project.Errors.Problem_Behavior.Problem_Behavior
import project.Internal.Data_Read_Helpers
import project.Logging.Telemetry
import project.Meta
import project.Network.HTTP.Cache_Policy.Cache_Policy
import project.Network.HTTP.Header.Header
Expand Down Expand Up @@ -91,11 +93,16 @@ read : Text | URI | File -> File_Format -> Problem_Behavior -> Any ! File_Error
read path=(Missing_Argument.throw "path") format=Auto_Detect (on_problems : Problem_Behavior = ..Report_Warning) = case path of
_ : Text -> if Data_Read_Helpers.looks_like_uri path then Data_Read_Helpers.fetch_following_data_links path format=format else
read (File.new path) format on_problems
uri : URI -> fetch uri format=format
uri : URI ->
response = fetch uri format=format
Telemetry.log "Data.read" "fetching from URI" (Dictionary.from_vector [["content_length", response.content_length]])
response
_ ->
file_obj = File.new path
if file_obj.is_directory then Error.throw (Illegal_Argument.Error "Cannot `read` a directory, use `Data.list`.") else
file_obj.read format on_problems
file_content = file_obj.read format on_problems
Telemetry.log "Data.read" "read from file" (Dictionary.from_vector [["path", file_obj.path]])
Copy link
Member

Choose a reason for hiding this comment

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

Sending home the file path might reveal customer internals we are not interested in. File size and mime type should be generic enough, however.

file_content

## ALIAS load, open
GROUP Input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,9 @@ public String payload() {
}

protected abstract String kind();

@Override
public String toString() {
return payload();
}
}
Loading