-
Notifications
You must be signed in to change notification settings - Fork 63
[feat] Adding Tracing(otel) to csi driver #309
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
Merged
Merged
Changes from all commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
f51cf78
- installed otel libraries
prajwalvathreya bd6e4ee
- added tracing to the grpc and https metrics endpoint process
prajwalvathreya 6581860
- created new tracker.go file in package metrics for tracing
prajwalvathreya 093b7b0
- added tracing elements to create volume function for testing
prajwalvathreya 1f520fb
- fixed lint errors
prajwalvathreya af9fd1d
- fixed import error from IDE
prajwalvathreya d5b3a39
- updated tracing to store into otel-collector backend
prajwalvathreya baf165c
- updated libraries
prajwalvathreya 0bc2eb9
- added check for pre-existing span
prajwalvathreya b359270
- upgraded InitOtelTracing function to incorporate resources
prajwalvathreya d8966d4
- initilizeing tracer in driver.go
prajwalvathreya d59fbbd
- updated createvolume functions with new span records
prajwalvathreya eedcc6d
- added WithInsecure() flag to allow connection without TLS handshake…
prajwalvathreya e3e036f
Merge branch 'main' into otel-tracing
prajwalvathreya 4a9b038
- installed otel libraries
prajwalvathreya 287b1c9
- added tracing to the grpc and https metrics endpoint process
prajwalvathreya 3e23b60
- created new tracker.go file in package metrics for tracing
prajwalvathreya 0bd34d6
- added tracing elements to create volume function for testing
prajwalvathreya 13b86ca
- fixed lint errors
prajwalvathreya f86a5c9
- fixed import error from IDE
prajwalvathreya 0c3fe85
- updated tracing to store into otel-collector backend
prajwalvathreya d9609f9
- updated libraries
prajwalvathreya f82fb39
- added check for pre-existing span
prajwalvathreya 38ce8b8
- upgraded InitOtelTracing function to incorporate resources
prajwalvathreya d552f05
- initilizeing tracer in driver.go
prajwalvathreya 287caaf
- updated createvolume functions with new span records
prajwalvathreya 21dcb86
- added WithInsecure() flag to allow connection without TLS handshake…
prajwalvathreya 1d6b42d
Merge remote-tracking branch 'origin/otel-tracing' into otel-tracing
prajwalvathreya 934b7c5
- fixed lint error
prajwalvathreya 52d880b
- switched form grpc endpoint to http endpoint
prajwalvathreya ff14322
- removed http from the url while setting endpoint
prajwalvathreya 8a81f5a
- updated service name
prajwalvathreya fc6f9b3
- added sub function calls to be stored in trace
prajwalvathreya b801c38
- added child span to record function to ensure all subfunction calls…
prajwalvathreya 9d76759
- moved subfunction call tracing to within function
prajwalvathreya 85eb934
- updated charts
prajwalvathreya efded8a
- added entry point for tracing in main.go
prajwalvathreya c7eb310
- utilized tracing variables to conditionally enable tracing for func…
prajwalvathreya 81cd3f7
- refactored to move everything to tracker.go package
prajwalvathreya fbda586
- added more resource attributes
prajwalvathreya d2ec23e
- added tracing for delete volume
prajwalvathreya 7a7da77
- removed finish child span processes
prajwalvathreya b53cd02
Merge branch 'main' into otel-tracing
prajwalvathreya c8c278a
- fixed pointer dereferencing
prajwalvathreya 93f3294
Merge remote-tracking branch 'origin/otel-tracing' into otel-tracing
prajwalvathreya e3b76ca
- fixed pointer dereferencing v2
prajwalvathreya 3128595
- added tracing for publish and unpublish volume
prajwalvathreya ecf4953
- added tracing to remainign functions in controller and nodeserver
prajwalvathreya 44df3af
- testing span depth
prajwalvathreya e4b7da8
- removed duplicate parent spans
prajwalvathreya 8d41ec8
- removed duplicate parent spans
prajwalvathreya 5d1cc70
- added tracing to functions with linodego calls
prajwalvathreya 6e3ea37
- added more subfunction tracing
prajwalvathreya 737261e
Merge branch 'main' into otel-tracing
prajwalvathreya de32e9e
- updated go mod
prajwalvathreya 72ed48e
- added check for duplicate spans
prajwalvathreya f1eaf5f
- update check for duplicate spans
prajwalvathreya 6fa824f
- updated package name from metrics to observability
prajwalvathreya f543746
- manually creating a parent span
prajwalvathreya 81e5f5d
- manually creating a parent span
prajwalvathreya ec5c12d
- updated formatting
prajwalvathreya 0568a43
- added SkipObservability flag for tests to isolate testing
prajwalvathreya cc86eef
- test to check is base span is created
prajwalvathreya bc21af4
- refactored span creation to manual spans
prajwalvathreya 0516a72
- added else spans
prajwalvathreya b2ad1db
- updated new spans for each function call
prajwalvathreya 7b73740
- updated serialzerequest to seralize obj
prajwalvathreya d09f579
- removing context
prajwalvathreya ded76e2
- updated spans
prajwalvathreya 2e7b7f0
- reverted nodeserver.go to original file, with change from metrics p…
prajwalvathreya d0db8fe
- working span handling in createvolume function in controllerserver.go
prajwalvathreya f7e8401
- updated validate create volume request
prajwalvathreya 70f44d5
- reverted files to main branch
prajwalvathreya e295030
- updated package tracker to store observability data more effectively
prajwalvathreya 793c150
- added custom grpc function parameter storage
prajwalvathreya 5201306
- added spans to level 2 functions
prajwalvathreya 1505cd1
Merge branch 'main' into otel-tracing
prajwalvathreya 4376ae5
- updaed go mod
prajwalvathreya 8fc5b09
- added skip observability to avoid nil pointer span creations
prajwalvathreya a6f3624
- added files required to setup otel-collector and jaeger
prajwalvathreya 5327167
- added make target for setting up tracing
prajwalvathreya ff71691
- added documentation for tracing
prajwalvathreya a3fbff1
Merge branch 'main' into otel-tracing
prajwalvathreya a14057e
- added links to README.md for tracing and metrics
prajwalvathreya 3c43cd1
- added option for port-forwarding
prajwalvathreya 8630729
- added meaningful lines to improve doc
prajwalvathreya 777287d
Merge branch 'main' into otel-tracing
prajwalvathreya cdfcd08
- go vet fix
prajwalvathreya 42ec7d3
- updated script with retry logic
prajwalvathreya ca7d995
Merge branch 'main' into otel-tracing
prajwalvathreya 4dce97b
- fixed go vet error
prajwalvathreya a4cd2e6
- updated doc
prajwalvathreya 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -119,7 +119,8 @@ linters: | |
| - usestdlibvars | ||
| - varnamelen | ||
| - whitespace | ||
|
|
||
| disable: | ||
| - spancheck | ||
| presets: | ||
| - bugs | ||
| - unused | ||
|
|
||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,237 @@ | ||
| # Using the Jaeger Dashboard for Linode CSI Driver | ||
|
|
||
| This guide provides a step-by-step explanation of how to use the Jaeger dashboard to analyze traces in the Linode CSI Driver. It includes visual examples for both the **landing page** and an example trace for the `createvolume` operation. | ||
|
|
||
| --- | ||
|
|
||
| ## 1. Accessing the Jaeger Dashboard | ||
|
|
||
| To access the Jaeger dashboard: | ||
| 1. Open the Jaeger dashboard in your browser using the external IP (e.g., `http://<external-ip>:16686`). | ||
| 2. The landing page will appear, providing options to search and analyze traces. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. Landing Page Overview | ||
|
|
||
| The landing page is the first screen you see upon accessing the Jaeger dashboard. Here's an example: | ||
|
|
||
| **Example Landing Page Screenshot**: | ||
|  | ||
|
|
||
| ### Key Features of the Landing Page: | ||
| - **Search Panel**: | ||
| - **Service**: Select the service you want to analyze (e.g., `linode-csi-driver`). | ||
| - **Operation**: Choose a specific operation to filter traces, such as `createvolume` or `listvolumes`. By default, all operations are shown. | ||
| - **Tags**: Filter traces by tags like `http.status_code=200` or other metadata. | ||
| - **Lookback**: Select a time range for trace results (e.g., "Last Hour"). | ||
| - **Max/Min Duration**: Specify duration filters for traces to focus on slow or fast requests. | ||
| - **Limit Results**: Set the maximum number of traces to display. | ||
|
|
||
| - **Results Table**: | ||
| - Lists all traces matching the search criteria. | ||
| - Displays the following information: | ||
| - **Service and Operation**: The service (e.g., `linode-csi-driver`) and the operation (e.g., `createvolume` or `listvolumes`). | ||
| - **Duration**: Total time taken by the trace. | ||
| - **Spans**: Number of sub-operations (spans) in the trace. | ||
| - **Timestamp**: The time the trace started. | ||
|
|
||
| ### Example Analysis: | ||
| From the landing page example: | ||
| - Two traces are displayed: | ||
| 1. **Trace ID: 042abeb**: | ||
| - **Operation**: `csi.v1.controller/createvolume`. | ||
| - **Duration**: `3.37s`. | ||
| - **Spans**: `9`. | ||
| 2. **Trace ID: a039cb1**: | ||
| - **Operation**: `csi.v1.controller/listvolumes`. | ||
| - **Duration**: `77.35ms`. | ||
| - **Spans**: `1`. | ||
|
|
||
| To analyze a trace in detail, click on its row (e.g., `042abeb` for `createvolume`). | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Viewing a Trace for `createvolume` | ||
|
|
||
| Clicking on a trace opens a detailed view of all operations (spans) involved in the request. Here's an example trace for `createvolume`: | ||
|
|
||
| **Example `createvolume` Trace Screenshot**: | ||
|  | ||
|  | ||
|
|
||
| ### Trace View Key Features: | ||
| 1. **Trace Timeline**: | ||
| - Visualizes the entire flow of the request as a timeline. | ||
| - Horizontal bars represent spans, showing the relative time and duration of each operation. | ||
| - The black line represents the critical path of the selected operation. | ||
| - Total trace duration is displayed at the top (e.g., `3.37s`). | ||
|
|
||
| 2. **Service & Operation Breakdown**: | ||
| - Displays a hierarchical list of operations executed during the trace. | ||
| - **Parent Span**: Represents the top-level operation (e.g., `csi.v1.controller/createvolume`). | ||
| - **Child Spans**: Nested operations under the parent span. | ||
|
|
||
| ### Example Breakdown: | ||
| For the `createvolume` trace: | ||
| - **Parent Span**: | ||
| - **Operation**: `csi.v1.controller/createvolume`. | ||
| - **Duration**: `3.37s`. | ||
| - Includes the following sub-operations: | ||
| 1. **`validatecreatevolumerequest`**: | ||
| - **Duration**: `2µs`. | ||
| - **Purpose**: Validates the incoming request for required parameters. | ||
| 2. **`preparevolumeparams`**: | ||
| - **Duration**: `2µs`. | ||
| - **Purpose**: Prepares necessary parameters for volume creation. | ||
| 3. **`getcontentsourcevolume`**: | ||
| - **Duration**: `1µs`. | ||
| - **Purpose**: Retrieves existing content sources (if applicable). | ||
| 4. **`createandwaitforvolume`**: | ||
| - **Duration**: `3.37s`. | ||
| - **Purpose**: Creates the volume in Linode and waits for the operation to complete. | ||
| - Sub-operations include: | ||
| - **`attemptcreatelinodevolume`**: | ||
| - **Duration**: `232.64ms`. | ||
| - **Purpose**: It checks for existing volumes with the same label and either returns the existing volume or creates a new one, optionally cloning from a source volume. | ||
| - **`createLinodeVolume`**: | ||
| - **Duration**: `155.47ms`. | ||
| - **Purpose**: creates a new Linode volume with the specified label, size, and tags. It returns the created volume or an error if the creation fails. | ||
| 5. **`createvolumecontext`**: | ||
| - Prepares the context for the created volume and adds necessary attributes. | ||
| - - **Duration**: `4µs`. | ||
| 6. **`preparecreatevolumeresponse`**: | ||
| - **Duration**: `4µs`. | ||
| - **Purpose**: Prepares the response to return to the caller. | ||
|
|
||
| --- | ||
|
|
||
| # Updating spans to provide additional information | ||
|
|
||
| If you want to track additional information in a span, you can utilize the functions `TraceFunctionData` and `SerializeObject` in `pkg/observability/tracker.go` to your advantage. | ||
|
|
||
| ## 1. `TraceFunctionData`: Tracing Function Calls | ||
|
|
||
| The `TraceFunctionData` function simplifies the process of tracing the behavior of your functions. It captures key information about function execution, including parameters, success or error status, and error details (if any). | ||
|
|
||
| ### **Function Signature** | ||
|
|
||
| ```go | ||
| func TraceFunctionData(span tracer.Span, operationName string, params map[string]string, err error) error | ||
| ``` | ||
|
|
||
| ### **Key Features** | ||
| - **Span Attributes**: | ||
| - Adds key-value pairs from the `params` map as attributes to the span for better trace details. | ||
| - **Success or Error Handling**: | ||
| - Sets the span status to `codes.Ok` for successful execution or `codes.Error` for failures. | ||
| - Logs the result (`success` or `error`) along with the `operationName` and `params`. | ||
| - **Error Recording**: | ||
| - Captures error details in the span using `span.RecordError`. | ||
|
|
||
| ### **Example Usage** | ||
|
|
||
| You can use `TraceFunctionData` in any function to add tracing with custom parameters: | ||
|
|
||
| ```go | ||
| observability.TraceFunctionData(span, "ValidateCreateVolumeRequest", map[string]string{ | ||
| "volume_name": req.GetName(), | ||
| "requestBody": observability.SerializeObject(req)}, err) | ||
| ``` | ||
|
|
||
| Here: | ||
| - `span`: The current tracing span. | ||
| - `"ValidateCreateVolumeRequest"`: The name of the operation being traced. | ||
| - `map[string]string`: A map of custom parameters to include in the trace. Add any details you want to capture, like volume names, request IDs, or serialized objects returned by API calls. | ||
| - `err`: The error object (if any) from the function being traced. | ||
|
|
||
| --- | ||
|
|
||
| ## 2. `SerializeObject`: Serializing Objects for Tracing | ||
|
|
||
| The `SerializeObject` function converts complex objects into JSON strings, making it easier to include them in trace parameters or logs. | ||
|
|
||
| ### **Function Signature** | ||
|
|
||
| ```go | ||
| func SerializeObject(obj interface{}) string | ||
| ``` | ||
|
|
||
| ### **Key Features** | ||
| - Converts any object (`struct`, `map`, etc.) into a JSON string. | ||
| - Handles serialization errors gracefully and logs the issue. | ||
| - Useful for including large or complex objects in the trace parameters. | ||
|
|
||
| ### **Example Usage** | ||
|
|
||
| You can serialize objects like a request body and append them to the `params` map: | ||
|
|
||
| ```go | ||
| observability.TraceFunctionData(span, "CreateVolume", map[string]string{ | ||
| "requestBody": observability.SerializeObject(req), | ||
| "volume_type": "block-storage", | ||
| }, nil) | ||
| ``` | ||
| Here: | ||
| - The request object `req` is serialized into a JSON string using `SerializeObject`. | ||
| - The serialized string is added to the `params` map as `"requestBody"`. | ||
|
|
||
| --- | ||
|
|
||
| ## 3. Adding tracing to a function | ||
|
|
||
| To integrate `TraceFunctionData` and `SerializeObject` into your function: | ||
|
|
||
| 1. Create a Span: | ||
| - Use the `StartFunctionSpan` function from tracker.go to create a span at the beginning of your function | ||
| 2. Capture Parameters: | ||
| - Use a `map[string] string` to include parameters you want to capture. | ||
| - Serialize objects using `SerializeObject` if needed. | ||
| 3. Call `TraceFunctionData`: | ||
| - Pass the span, operation name, parameters, and any error to `TraceFunctionData` wherever necessary. | ||
|
|
||
| ### **Example** | ||
|
|
||
| ```go | ||
| func CreateVolumeRequest(ctx context.Context, req *csi.CreateVolumeRequest) error { | ||
| // Step 1: Create a Span | ||
| _, span := observability.StartFunctionSpan(ctx) | ||
| defer span.End() // Ensure the span ends when the function exits | ||
|
|
||
| // Step 2: Capture Parameters | ||
| // Initialize a map to hold custom trace parameters | ||
| params := map[string]string{ | ||
| "volume_name": req.GetName(), | ||
| "capacity_range": observability.SerializeObject(req.GetCapacityRange()), | ||
| "parameters": observability.SerializeObject(req.GetParameters()), | ||
| } | ||
|
|
||
| // Simulate parameter validation | ||
| if req.GetName() == "" { | ||
| err := fmt.Errorf("volume name is missing") | ||
|
|
||
| // Step 3: Call TraceFunctionData with error | ||
| observability.TraceFunctionData(span, "ValidateCreateVolumeRequest", params, err) | ||
| return err | ||
| } | ||
|
|
||
| // On success | ||
| // Step 3: Call TraceFunctionData with no error | ||
| observability.TraceFunctionData(span, "CreateVolumeRequest", params, nil) | ||
| return nil | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Benefits of Using This Approach | ||
|
|
||
| - **Detailed Traces**: | ||
| - Include all relevant details about function execution, making it easier to debug issues. | ||
| - **Error Visibility**: | ||
| - Automatically records errors and logs them with context. | ||
| - **Flexibility**: | ||
| - Add or modify parameters dynamically based on your function's needs. | ||
| - **Serialization**: | ||
| - Handles complex objects seamlessly without additional manual string conversion. | ||
| --- |
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.