-
Notifications
You must be signed in to change notification settings - Fork 130
[PECOBLR-441] Added classes required for telemetry #566
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
489c82d
PECOBLR-86 Improve logging for debug level
saishreeeee c8a8045
PECOBLR-86 Improve logging for debug level
saishreeeee 0adfedd
fixed format
saishreeeee 5117787
used lazy logging
saishreeeee a194089
changed debug to error logs
saishreeeee 786a7b0
added classes required for telemetry
saishreeeee a48881f
removed TelemetryHelper
saishreeeee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import os | ||
| import databricks.sql as sql | ||
|
|
||
| # Create connection with telemetry enabled | ||
| conn = sql.connect( | ||
| server_hostname=os.environ["DATABRICKS_SERVER_HOSTNAME"], | ||
| http_path=os.environ["DATABRICKS_HTTP_PATH"], | ||
| access_token=os.environ["DATABRICKS_TOKEN"], | ||
| enable_telemetry=True, # Enable telemetry | ||
| telemetry_batch_size=1 # Set batch size to 1 | ||
| ) | ||
|
|
||
| # Execute a simple query to generate telemetry | ||
| cursor = conn.cursor() | ||
| cursor.execute("SELECT * FROM main.eng_lumberjack.staging_frontend_log_sql_driver_log limit 1") | ||
| cursor.fetchall() | ||
|
|
||
| # Close the connection | ||
| cursor.close() | ||
| conn.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/databricks/sql/telemetry/DriverConnectionParameters.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from databricks.sql.telemetry.HostDetails import HostDetails | ||
| from databricks.sql.telemetry.enums.AuthMech import AuthMech | ||
| from databricks.sql.telemetry.enums.AuthFlow import AuthFlow | ||
| from databricks.sql.telemetry.enums.DatabricksClientType import DatabricksClientType | ||
|
|
||
|
|
||
| @dataclass | ||
| class DriverConnectionParameters: | ||
| http_path: str | ||
| driver_mode: DatabricksClientType | ||
| host_details: HostDetails | ||
| auth_mech: AuthMech | ||
| auth_flow: AuthFlow | ||
| auth_scope: str | ||
| discovery_url: str | ||
| allowed_volume_ingestion_paths: str | ||
| enable_complex_datatype_support: bool | ||
saishreeeee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| azure_tenant_id: str | ||
| socket_timeout: int | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
|
|
||
|
|
||
| @dataclass | ||
| class DriverErrorInfo: | ||
| error_name: str | ||
| stack_trace: str | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| import platform | ||
| import sys | ||
| import locale | ||
| from databricks.sql import __version__ | ||
|
|
||
|
|
||
| @dataclass | ||
| class DriverSystemConfiguration: | ||
| driver_version: str | ||
| os_name: str | ||
| os_version: str | ||
| os_arch: str | ||
| runtime_name: str | ||
| runtime_version: str | ||
| runtime_vendor: str | ||
| client_app_name: str | ||
| locale_name: str | ||
| driver_name: str | ||
| char_set_encoding: str | ||
|
|
||
| def __init__(self): | ||
| self.driver_version = __version__ | ||
| self.os_name = platform.system() | ||
| self.os_version = platform.version() | ||
| self.os_arch = platform.machine() | ||
| self.runtime_name = platform.python_implementation() | ||
| self.runtime_version = platform.python_version() | ||
| self.runtime_vendor = sys.implementation.name | ||
| self.client_app_name = "databricks-sql-python" | ||
| self.locale_name = locale.getdefaultlocale()[0] | ||
| self.driver_name = "databricks-sql-python" | ||
| self.char_set_encoding = "UTF-8" | ||
saishreeeee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from databricks.sql.telemetry.enums.DriverVolumeOperationType import ( | ||
| DriverVolumeOperationType, | ||
| ) | ||
|
|
||
|
|
||
| @dataclass | ||
| class DriverVolumeOperation: | ||
| volume_operation_type: DriverVolumeOperationType | ||
| volume_path: str | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from databricks.sql.telemetry.TelemetryClientContext import TelemetryClientContext | ||
|
|
||
|
|
||
| @dataclass | ||
| class FrontendLogContext: | ||
| client_context: TelemetryClientContext | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from databricks.sql.telemetry.TelemetryEvent import TelemetryEvent | ||
|
|
||
|
|
||
| @dataclass | ||
| class FrontendLogEntry: | ||
| sql_driver_log: TelemetryEvent | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
|
|
||
|
|
||
| @dataclass | ||
| class HostDetails: | ||
| host_url: str | ||
| port: int | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from databricks.sql.telemetry.enums.StatementType import StatementType | ||
| from databricks.sql.telemetry.enums.ExecutionResultFormat import ExecutionResultFormat | ||
|
|
||
|
|
||
| @dataclass | ||
| class SqlExecutionEvent: | ||
| statement_type: StatementType | ||
| is_compressed: bool | ||
| execution_result: ExecutionResultFormat | ||
| retry_count: int | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from dataclasses import dataclass, asdict | ||
| import json | ||
|
|
||
|
|
||
| @dataclass | ||
| class TelemetryClientContext: | ||
| timestamp_millis: int | ||
| user_agent: str | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from databricks.sql.telemetry.DriverSystemConfiguration import DriverSystemConfiguration | ||
| from databricks.sql.telemetry.DriverConnectionParameters import ( | ||
| DriverConnectionParameters, | ||
| ) | ||
| from databricks.sql.telemetry.DriverVolumeOperation import DriverVolumeOperation | ||
| from databricks.sql.telemetry.SqlExecutionEvent import SqlExecutionEvent | ||
| from databricks.sql.telemetry.DriverErrorInfo import DriverErrorInfo | ||
|
|
||
|
|
||
| @dataclass | ||
| class TelemetryEvent: | ||
| session_id: str | ||
| sql_statement_id: str | ||
| system_configuration: DriverSystemConfiguration | ||
| driver_connection_params: DriverConnectionParameters | ||
| auth_type: str | ||
| vol_operation: DriverVolumeOperation | ||
| sql_operation: SqlExecutionEvent | ||
| error_info: DriverErrorInfo | ||
| latency: int | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from databricks.sql.telemetry.FrontendLogContext import FrontendLogContext | ||
| from databricks.sql.telemetry.FrontendLogEntry import FrontendLogEntry | ||
|
|
||
|
|
||
| @dataclass | ||
| class TelemetryFrontendLog: | ||
| workspace_id: int | ||
| frontend_log_event_id: str | ||
| context: FrontendLogContext | ||
| entry: FrontendLogEntry | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from typing import List, Optional | ||
|
|
||
|
|
||
| @dataclass | ||
| class TelemetryRequest: | ||
| uploadTime: int | ||
| items: List[str] | ||
| protoLogs: Optional[List[str]] | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import json | ||
| from dataclasses import dataclass, asdict | ||
| from typing import List, Optional | ||
|
|
||
|
|
||
| @dataclass | ||
| class TelemetryResponse: | ||
| errors: List[str] | ||
| numSuccess: int | ||
| numProtoSuccess: int | ||
|
|
||
| def to_json(self): | ||
| return json.dumps(asdict(self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class AuthFlow(Enum): | ||
| TOKEN_PASSTHROUGH = "token_passthrough" | ||
| CLIENT_CREDENTIALS = "client_credentials" | ||
| BROWSER_BASED_AUTHENTICATION = "browser_based_authentication" | ||
| AZURE_MANAGED_IDENTITIES = "azure_managed_identities" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class AuthMech(Enum): | ||
| OTHER = "other" | ||
| PAT = "pat" | ||
| OAUTH = "oauth" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class DatabricksClientType(Enum): | ||
| SEA = "SEA" | ||
| THRIFT = "THRIFT" |
10 changes: 10 additions & 0 deletions
10
src/databricks/sql/telemetry/enums/DriverVolumeOperationType.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class DriverVolumeOperationType(Enum): | ||
| TYPE_UNSPECIFIED = "type_unspecified" | ||
| PUT = "put" | ||
| GET = "get" | ||
| DELETE = "delete" | ||
| LIST = "list" | ||
| QUERY = "query" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class ExecutionResultFormat(Enum): | ||
| FORMAT_UNSPECIFIED = "format_unspecified" | ||
| INLINE_ARROW = "inline_arrow" | ||
| EXTERNAL_LINKS = "external_links" | ||
| COLUMNAR_INLINE = "columnar_inline" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class StatementType(Enum): | ||
| NONE = "none" | ||
| QUERY = "query" | ||
| SQL = "sql" | ||
| UPDATE = "update" | ||
| METADATA = "metadata" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.