fnproject / fdk-python

Python Function Development Kit
http://fnproject.io/
Apache License 2.0
45 stars 24 forks source link

Add support for Oracle Cloud Infrastructure tracing solution by providing a tracing context #117

Closed isaaclipszyc closed 3 years ago

isaaclipszyc commented 3 years ago

OVERVIEW Oracle Functions will soon release a feature providing an integration with the Oracle Application Performance Monitoring (APM) service. This service supports the sending of Zipkin formatted tracing data to a collector endpoint.

The service will provide the function code with data which includes:

This information is accessible by the function code in a Tracing Context provided by the FDK.

This change has no effect on existing functions, except that the keys "OCI_TRACING_ENABLED" and "OCI_TRACE_COLLECTOR_URL" are now reserved for this tracing integration and cannot be used for function configuration.

FDK SPECIFIC CHANGES This change adds an additional tracing context to the invoke context. This can be accessed by users to configure tracing in their functions using the zipkin libraries of their choice (py_zipkin seems to be the most popular). The tracing context contains methods to access the extracted zipkin B3 headers as well as the trace collector URL, tracing enabled flag and a few extra helper methods specific to py_zipkin (service name, annotations and zipkin attributes).

Additionally, methods to retrieve the app and fn name were added to the invoke context.

Changes have been made to constants.py and context.py and unit tests have been added to test_tracing.py

This change should not affect existing functions.