Completed all content, except for 2x labs and the practice exam

This commit is contained in:
Alex Soul 2021-02-17 13:07:37 +00:00
parent 30838121dc
commit 00c61824c0
3 changed files with 156 additions and 5 deletions

161
Part_4.md
View File

@ -1167,28 +1167,81 @@ Enable K8's engine API
Enable Cloud Trace API
[Python Code for Cloud Trace](./img/cloud_trace_python_code.png)
<br>
[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)
<br>
[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)
<u></u>
<u></u>
#### Accessing the Cloud Trace APIs
<u></u>
<u></u>
<u>Instrumenting Your Code for Cloud Trace</u>
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 |
<u>Comparing APIs</u>
| 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
<u></u>
<u></u>
<u>Cloud Profiler Supported Environments</u>
- 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
<u></u>
<u></u>
#### 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)
<u>Key Workflows</u>
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
<u></u>
<u></u>
#### Establishing Error Reporting for Your App
<u>Error Reporting Supported Languages</u>
- 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
<u>Working with the Error Reporting API in Python</u>
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
<u>Error Reporting Entries Explained</u>
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)
<u></u>
<u></u>
#### Section Review
<u></u>
<u></u>
<u></u>
#### Milestone: Come Together - Reprise (Debug Is De Solution)
#### Hands-On Lab: Correcting Code with Cloud Debugger

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB