diff --git a/Part_4.md b/Part_4.md index 154481b..94a0d28 100644 --- a/Part_4.md +++ b/Part_4.md @@ -1167,28 +1167,81 @@ Enable K8's engine API Enable Cloud Trace API [Python Code for Cloud Trace](./img/cloud_trace_python_code.png) +
-[Python Code for Cloud Trace Middleware](./img/cloud_trace_python_middleware.png) + +[Python Code for Cloud Trace Middleware](./img/cloud_trace_python_code_middleware.png) + +
+ +[Python Code for Cloud Trace Execute Trace](./img/cloud_trace_python_code_trace_execute.png) + +> Everytime the app executes, the trace executes + +Dashboard outputs the full trace, with waterfall graph showing component parts (spans - to help identify latency bottlenecks) #### Accessing the Cloud Trace APIs - - +Instrumenting Your Code for Cloud Trace + +3x methods + +| Client Libraries | Open Telemetry | OpenCensus | +| ---------------- | --------------------- | ---------- | +| Ruby | Node.js, Python (now) | Python | +| Node.js | Go | Java | +| C# ASP.NET Core | In Active development | Go | +| C# ASP.NET | Recommended by Google | PHP | + + +Comparing APIs + +| V1 | vs | V2 | +| -------------------------------------------------------------------------------- | --- | -------------------------------------------------------------- | +| Send traces to Cloud Trace | - | Send traces to Cloud Trace | +| Update existing traces | - | - | +| Get lists of traces | - | - | +| get the details of a single trace | - | - | +| Supports v1 REST and v2 REST as well as v1 and v2 RPC | - | Supports v1 REST and v2 REST as well as v1 and v2 RPC | +| A trace is represented by a Trace resource (REST) and Trace message (RPC) | - | No explicit trace object; include trace ID in span to identify | +| A span is represented by a TraceSpan resource (REST) and TraceSpan message (RPC) | - | A span in represented by the Span resource | +| Uses Labels fields | - | Uses attributes fields | #### Setting Up Your App with Cloud Profiler - - +Cloud Profiler Supported Environments +- Compute Engine +- App Engine Standard Environment +- App Engine Flexible Environment +- Kubernetes Engine +- Outside of Google Cloud + +[Python Code to enable Cloud Profiler to track CPU](https://cloud.google.com/profiler/docs/profiling-python) + +3 Steps to Setting up Cloud Profiler Outside GCP +- Enable profiler API inside GC Project +- Get credentials for the profiling agent + - Service account with private-key auth + - Application default credentials (ADC) +- Configure the agent + - Pass in the project ID via a `Config()` or similar method #### Analyzing Cloud Profiler Data +As Go is the most supported language, the demo in this video uses Go. + +TLDR: Analyze Code with graphs, IO, CPU, locks, etc, cool if you're coding with running your apps within GKE or on GCP + #### Section Review +Cloud Trace: Latency - Demo app with 3x Load Balancers, Spans, OpenTelemetry +Cloud Profiler: Continuously analyzing CPU & Memory Performance, Supported services, Code necessary for implementation, Examine flame graphs for profile types, threads, alloc etc + #### Milestone: It All Adds Up! #### Hands-On Lab: Discovering Latency with Google Cloud Trace @@ -1199,12 +1252,110 @@ Enable Cloud Trace API #### Troubleshooting with Cloud Debugger +_"Inspect code in real time, without stopping or slowing it down"_ _(killer feature_) + +- Multiple Source Options + - Cloud Source repositories + - GitHub + - BitBucket + - GitLab +- Code Search + - Quickly find code in a specific file, function, method or by line number +- Code Share + - Debug sessions can be shared with any teammate for collaborative debugging +- IDE Integration + - Integrates with IntelliJ IDE, as well as VSCode and Atom + +> Completely Free to Use + +![Cloud Debugger Language Support Per Service](./img/cloud_debugger_language_support_per_service.png) + +Key Workflows + +Two Key Cloud Debugger Tools + +| Snapshots | vs. | Logpoints | +| -------------------------------------------------------- | --- | ------------------------------------------------------------------------------- | +| - Captures application state at a specific line location | - | - Inject logs into running apps without redeployment | +| - Captures local variables | - | - Logpoints remain active for 24 hours if not deleted or service not redeployed | +| - Captures call stack | - | - Supports canarying | +| - Take snapshots conditionally (Java, Python and Go) | - | - Add Logpoints conditionally | +| - Supports canarying | - | Output ent to target's appropriate environment | + +> Demo of Code debugging in Python + + + + #### Establishing Error Reporting for Your App +Error Reporting Supported Languages + +- php +- Java +- Python +- .NET +- Node.js +- Ruby +- Go + +- Compute Engine + - Cloud Logging + - Error Reporting API +- App Engine + - Automatic set-up + - Standard Environment: + - Additional set-up may be neccessary + - Only errors with stack trace processed + - Flexible Environment: + - No additional setup required + - Analyzes messages to stderr +- Cloud Run + - Automatic setup + - Analyzes messages written to stderr, stdout, or other logs that have stack trace +- Kubernetes Engine + - Use Cloud Logging + - Use Error Reporting API +- Cloud Functions + - Automatic setup + - Unhandled JavaScript exceptions processed + +Working with the Error Reporting API in Python +1. Import `error_reporting` library +2. Instantiate `Client()` +3. Call `report()` method, passing in any string + +> Python example in Video + #### Managing Errors and Handling Notifications +Error Reporting Entries Explained + +Occurances (withing selected time/day range) +Users affected (Within selected time/day range) +Error (Extracted from stack trace with code location, linked if in CSR) +Seen In (service and version, if any) +First Seen (time/date first appeared) +Last Seen +Response Code (HTTP Status code, if any) +Link to issue URL (Optional text field) + +Error Reporting Notifications +- Enabled per project +- Must have Project Owner, Project Editor, Project Viewer role, or custom role with `cloudnotifications.activities.list` permission +- Sent to email of specified roles +- May be forwared to alias or Slack channel +- Send to mobile app, if enabled and subscribed (Cloud Console App) + + + + #### Section Review + + + + #### Milestone: Come Together - Reprise (Debug Is De Solution) #### Hands-On Lab: Correcting Code with Cloud Debugger diff --git a/img/cloud_debugger_language_support_per_service.png b/img/cloud_debugger_language_support_per_service.png new file mode 100644 index 0000000..1d064c5 Binary files /dev/null and b/img/cloud_debugger_language_support_per_service.png differ diff --git a/img/cloud_trace_python_code_trace_execute.png b/img/cloud_trace_python_code_trace_execute.png new file mode 100644 index 0000000..9ad8655 Binary files /dev/null and b/img/cloud_trace_python_code_trace_execute.png differ