Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel

Table of Contents
maxLevel3

Prerequisites

It is assumed the following are installed and configured properly:

  • Opentelemetry Collector
  • Jaeger
  • Prometheus
  • Grafana
  • Universal Agent 7.5.0.0 or higher
  • Universal Controller 7.5.0.0 or higher
  • UIP-CLI

It is highly recommended to first go through The Basics, if this is the first time you are creating an Extension.

Introduction

To showcase the Opentelemetry functionality, we will be working with a basic File Monitor Extension that can monitor for creation and deletion of files.

Step 1 - Create the Extension

To create a custom starter template, we will first make use of the built-in ue-task template. Open up the terminal to the demo_template folder and run

...

Introduction

To showcase the Opentelemetry functionality, we will be creating a basic Extension that serves up some HTTP endpoints using the Flask framework.

Specifically, the Extension will create three endpoints:

  • /upload
  • /files
  • /delete

The /upload endpoint will accept payload using a POST request. The payload must be a JSON object with two fields: filename and data. Upon receiving valid payload, the Extension will create a file with name and contents specified by filename and data respectively.

The /files endpoint will read the saved files and return them as a JSON array. The array will contain JSON objects with two fields: filename and data.

The /delete endpoint will delete all the saved files.


Step 1 - Import the Extension Template

Go ahead and navigate to a directory where you would like to store the Extension. Download the attached Extension template below.

View file
nameOtelDemoTemplate.zip
height150

Open up the terminal to that folder and run

Code Block
 uip template add <path to OtelDemoTemplate.zip>


Info
titleReference

If you are unfamiliar with custom Extension templates, refer to Customizing Starter Templates.

You should now have the OtelDemo Extension template imported. To verify, run

Code Block
 uip template list

and you should see the OtelDemo template in the table.

OtelDemoTemplate.zip is no longer needed; it can be deleted.

Step 2 - Initializing the OtelDemo Extension

Now, we will create an Extension based off the OtelDemo Extension template. Go ahead and run

Code Block
uip init -t ue-task -e "extension_name=my_custom_ext" -e "universal_template_name=my_custom_template"

...

OtelDemo OtelDemoExt

This command should create a folder named OtelDemoExt with the Extension inside of it. 

Info
titleTemplate Variables

The OtelDemo Extension template has two customizable variables: host and port. For more information, run uip template list OtelDemo

Now would be a good time to go through src/extension.py and see how/what it's doing.

Step 3 - Testing the Extension

Go ahead and push the Extension to the Controller using

Code Block
uip push -a

The requirements.txt contains an entry for Flask. It will be downloaded and packaged with the Extension automatically. 

Once the Extension is in the Controller, create a task for it and run it. The Extension runs indefinitely until it's cancelled.

...

To interface with the web server, we will use the Web Service tasks that are built into the Controller, but other applications like Postman, Curl, etc. can also be used. Go ahead and create three Web Service tasks:

  1. OtelDemoGetFiles
    Image Added
  2. OtelDemoUploadFile
    Image Added
  3. OtelDemoDeleteFiles
    Image Added

The host part of the URL will need to be changed according to how your Agent and Controller are set up.

...

Now, run the OtelDemoGetFiles task, and it should succeed with the output being an empty array since we haven't uploaded any files yet. Next, run the OtelDemoUploadFile task followed by the OtelDemoGetFiles task. Both tasks should succeed, and the output of the OtelDemoGetFiles task should be:

Image Added

You can run the OtelDemoDeleteFiles task now, which will delete test1.txt.


Next >