diff --git a/lesson-3-2/content.md b/lesson-3-2/content.md index 143694d..9558aa0 100644 --- a/lesson-3-2/content.md +++ b/lesson-3-2/content.md @@ -1,6 +1,4 @@ -url - `opentelemetry-python-example` - ---- +# Lesson 3.2: OpenTelemetry Manual Instrumentation of Python Application In the previous tutorial, we set up auto-instrumentation for our Flask application with OpenTelemetry without any code changes. In this tutorial, we will manually configure the agent. @@ -67,7 +65,7 @@ Now, let's see how to run the application. ```bash OTEL_RESOURCE_ATTRIBUTES=service.name=my-application \ OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.in.signoz.cloud:443" \ -OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=72282c07-60ad-45ff-9131-3b8819f9cdc3" \ +OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=" \ python lesson-3-2/app.py ``` @@ -77,7 +75,9 @@ Interact with the Flask application to generate tracing data and send it to SigN ## Step 5: See Trace Data in SigNoz - +Once you've created some dummy telemetry by interacting with your application, you will be able to find your application under the `Services` tab of SigNoz. + +![Application being monitored in SigNoz](static/images/application-monitored.png) ## Next Steps diff --git a/lesson-4/app.py b/lesson-4/app.py index 5e10c64..9c643eb 100644 --- a/lesson-4/app.py +++ b/lesson-4/app.py @@ -88,7 +88,7 @@ def action(): desc = request.values.get("desc") date = request.values.get("date") pr = request.values.get("pr") - span.set_attribute("name", name) + span.set_attribute("task_name", name) span.add_event("Adding a Task") todos_coll.insert_one( {"name": name, "desc": desc, "date": date, "pr": pr, "done": "no"} diff --git a/lesson-4/content.md b/lesson-4/content.md index 0cbb616..52cce9b 100644 --- a/lesson-4/content.md +++ b/lesson-4/content.md @@ -1,6 +1,4 @@ -url - `opentelemetry-python-manual-instrumentation` - ---- +# Lesson 4: Create Manual Spans in Python application using OpenTelemetry In the previous tutorials, we set up out of the box tracing, metrics and logs in our Flask application. In this tutorial, we will show you how to manually create spans. @@ -187,7 +185,22 @@ def my_function(): ## Step 6: See your Spans in SigNoz - +The sample code for lesson 4 has a manual span named `add_task` which gets created whenever you create a new task in the to-do application. To see this span go to the `Traces` tab and apply filters for your application. + +```bash +OTEL_RESOURCE_ATTRIBUTES=service.name=my-application \ +OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" \ +OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=" \ +python lesson-4/app.py +``` + +Once you run the application and add a task, you will be able to see it in SigNoz. + +![Manual span in the list view of traces](static/images/manual-spans.png) + +You can see your span in the trace detail view too which will show how the request flowed and how much it took for the `add_task` operation. + +![See your span in detailed trace view](static/images/manual-spans.png) ## Next Steps diff --git a/lesson-5/content.md b/lesson-5/content.md index 475769b..4b0281f 100644 --- a/lesson-5/content.md +++ b/lesson-5/content.md @@ -1,6 +1,4 @@ -url - `opentelemetry-python-manual-instrumentation` - ---- +# Lesson 5: Creating custom metrics in Python Application using OpenTelemetry In the previous tutorials, we have seen how to manually create spans in a Python application. In this tutorial, we will look at how to create custom metrics using OpenTelemetry. @@ -101,7 +99,33 @@ The `create_gauge()` method creates a gauge instrument with the given name, unit ## Step 6: See your metrics in SigNoz - +The sample code for lesson 5 has a custom metric named `todo_counter` which keeps a track of number of To-Dos added by the user. You can create customized dashboards to monitor your custom metrics. + +In order to see your custom metric in SigNoz, run the updated code with custom metric in Lesson 5. + +```bash +OTEL_RESOURCE_ATTRIBUTES=service.name=my-application \ +OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" \ +OTEL_EXPORTER_OTLP_HEADERS="signoz-access-token=" \ +python lesson-5/app.py +``` + +Let's suppose you add 6 tasks in your to-do application. + +![6 tasks added in the to-do application](static/images/6-tasks.png) + +You can go to `Dashboards` in SigNoz and create a new panel to monitor the number of tasks in your to-do application using the `todo_counter` metric. + +![todo_counter metric](static/images/custom-metrics-opentelemetry-python.png) + +You can create a value panel type and monitor the number of tasks being created. + +![Value panel type](static/images/no-of-tasks-added.png) + +You can also set alerts on metrics based on your use-case directly from these panels. + +![Value panel type](static/images/create-alerts-custom-metrics.png) + ## Next Steps diff --git a/static/images/6-tasks.png b/static/images/6-tasks.png new file mode 100644 index 0000000..c280c8c Binary files /dev/null and b/static/images/6-tasks.png differ diff --git a/static/images/create-alerts-custom-metrics.png b/static/images/create-alerts-custom-metrics.png new file mode 100644 index 0000000..4a6ec4c Binary files /dev/null and b/static/images/create-alerts-custom-metrics.png differ diff --git a/static/images/custom-metrics-opentelemetry-python.png b/static/images/custom-metrics-opentelemetry-python.png new file mode 100644 index 0000000..a2ee89f Binary files /dev/null and b/static/images/custom-metrics-opentelemetry-python.png differ diff --git a/static/images/manual-span-fullscreen.png b/static/images/manual-span-fullscreen.png new file mode 100644 index 0000000..7673354 Binary files /dev/null and b/static/images/manual-span-fullscreen.png differ diff --git a/static/images/manual-spans.png b/static/images/manual-spans.png new file mode 100644 index 0000000..209d606 Binary files /dev/null and b/static/images/manual-spans.png differ diff --git a/static/images/no-of-tasks-added.png b/static/images/no-of-tasks-added.png new file mode 100644 index 0000000..f93e521 Binary files /dev/null and b/static/images/no-of-tasks-added.png differ diff --git a/static/images/trace-details-manual-span.png b/static/images/trace-details-manual-span.png new file mode 100644 index 0000000..6c58a18 Binary files /dev/null and b/static/images/trace-details-manual-span.png differ