-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
169 additions
and
132 deletions.
There are no files selected for viewing
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 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,62 @@ | ||
--- | ||
order: 1 | ||
label: Python | ||
--- | ||
|
||
# OpenTelemetry for Python | ||
|
||
The [Baselime Python OpenTelemetry SDK](https://github.com/baselime/python-opentelemetry) enables you to instrument your Python services with OpenTelemetry without the boilerplate of using the OpenTelemetry SDK directly. | ||
|
||
This SDK uses [OpenTelemetry for Python](https://opentelemetry.io/docs/instrumentation/python/) and provides a layer that facilitates instrumenting your Python applications. | ||
|
||
!!! | ||
If your application is already instrumented with [OpenTelemetry](https://opentelemetry.io/), you can start sending your tracing data to Baselime without any additional code changes. | ||
|
||
Add the Baselime OpenTelemetry endpoint to your exporter: | ||
- Endpoint `https://otel.baselime.io/v1/` | ||
- Header: `x-api-key: <BASELIME_API_KEY>` | ||
!!! | ||
|
||
--- | ||
|
||
## Instrumentation | ||
|
||
### Step 1: Install the SDKs | ||
|
||
Install the [Baselime Python OpenTelemetry SDK](https://github.com/baselime/python-opentelemetry). | ||
|
||
```bash # :icon-terminal: terminal | ||
poetry add baselime-opentelemetry | ||
``` | ||
|
||
### Step 2: Install Instrumentations | ||
|
||
Automatically install instrumentation for the python libraries you use with `opentelemetry-bootstrap` | ||
|
||
```bash # :icon-terminal: terminal | ||
poetry add baselime-opentelemetry | ||
``` | ||
|
||
### Step 3: Set the Baselime environment variables | ||
|
||
Set the environment variables of your comntainer service to include the Baselime API Key | ||
|
||
```bash # :icon-terminal: terminal | ||
export BASELIME_API_KEY=<YOUR_API_KEY> | ||
export OTEL_SERVICE_NAME='<NAME_OF_YOUR_APP_OR_SERVICE>' | ||
``` | ||
|
||
### Step 4: Run the Opentelemetry Instrumentation | ||
|
||
``` # :icon-terminal: terminal | ||
poetry run opentelemetry-instrument python myapp.py | ||
``` | ||
|
||
Once these steps are completed, distributed traces from your Python container applications should be available in Baselime to query via the console or the Baselime CLI. | ||
|
||
--- | ||
|
||
## Configuration | ||
|
||
When running your application locally you can set the environment variable `EXPORT_CONSOLE=TRUE` to print all the telemetry to the console. This can help make sure you have instrumented your application correctly | ||
|
This file contains 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,79 @@ | ||
--- | ||
order: -1 | ||
label: OpenTelemetry for AWS Lambda | ||
--- | ||
|
||
# OpenTelemetry for AWS Lambda | ||
|
||
To automatically instrument your AWS Lambda functions with the [Baselime Node.js OpenTelemetry tracer for AWS Lambda](https://github.com/Baselime/lambda-node-opentelemetry), set the following tag to your AWS Lambda functions: `baselime:tracing=true`. | ||
|
||
|
||
![AWS Lambda Tracing](../../../../../assets/images/illustrations/sending-data/otel-lambda-python.png) | ||
|
||
|
||
+++ AWS CDK | ||
|
||
To add the Baselime tag to all your AWS Lambda functions in a service or stack add this line to your AWS CDK code. | ||
|
||
```typescript # | ||
Tags.of(app).add("baselime:tracing", `true`); | ||
``` | ||
|
||
+++ SST | ||
|
||
To add the Baselime tag to all your AWS Lambda functions in a service or stack add this line to your `sst.config.ts` file. | ||
|
||
```typescript # | ||
Tags.of(app).add("baselime:tracing", `true`); | ||
``` | ||
|
||
+++ Serverless Framework | ||
|
||
To add the Baselime tag to all your AWS Lambda functions in a add this snippet to your `serverless.yml` file. | ||
|
||
```yaml # | ||
provider: | ||
name: aws | ||
tags: | ||
"baselime:tracing": "true" | ||
``` | ||
+++ AWS SAM | ||
To add the Baselime tag to all your AWS Lambda functions in a add this snippet to your AWS SAM configuration file. | ||
```yaml # | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: "Gets data from the xxxxx API." | ||
Globals: | ||
Function: | ||
Tags: | ||
"baselime:tracing": "true" | ||
``` | ||
+++ | ||
!!!warning | ||
Other observability tool layers and tags can adversely interact with the Baselime OpenTelemetry layer. We recommend to disable all other observability layers and tags before instrumenting your AWS Lambda functions with the Baselime OpenTelemetry layer. Failing to do so could result in down-time. | ||
!!! | ||
--- | ||
## Runtimes | ||
[!ref icon="../../../../../assets/images/logos/node.svg"](./node.js.md) | ||
[!ref icon="../../../../../assets/images/logos/python.svg"](./python.md) | ||
--- | ||
## Remove OpenTelemetry | ||
To remove the OpenTelemetry instrumentation from your AWS Lambda functions, remove the `baselime:tracing=true` tag from the function and Baselime will revert the function to un-instrumentate state. | ||
|
||
--- | ||
|
||
## Sending data to another OpenTelemetry backend | ||
|
||
OpenTelemetry is an open standard, and you can use the [Baselime Node.js OpenTelemetry tracer for AWS Lambda](https://github.com/Baselime/lambda-node-opentelemetry) to send telemetry data to another backend of your choice. | ||
|
||
Set environment variable `COLLECTOR_URL` to your observability backend. |
This file was deleted.
Oops, something went wrong.
This file contains 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 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