Skip to content

Commit

Permalink
docs for python
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankcorn committed Nov 24, 2023
1 parent 36dd4cb commit 4495be0
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 132 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions assets/images/logos/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions sending-data/languages/python.md
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

79 changes: 79 additions & 0 deletions sending-data/platforms/aws/aws-lambda/traces/index.md
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.
2 changes: 0 additions & 2 deletions sending-data/platforms/aws/aws-lambda/traces/index.yml

This file was deleted.

60 changes: 1 addition & 59 deletions sending-data/platforms/aws/aws-lambda/traces/node.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,14 @@ label: Node.js

The [Baselime Node.js OpenTelemetry tracer for AWS Lambda](https://github.com/Baselime/lambda-node-opentelemetry) instruments your Node.js AWS Lambda functions with OpenTelemetry and automatically sends OpenTelemetry traces to Baselime. This is the most powerful and flexible way to instrument your Node.js AWS Lambda functions.


---

## Automatic Instrumentation

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 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"
```
+++
That's all you are all set with OpenTelemetry on Node.js AWS Lambda functions.
!!!
OpenTelemetry automatic instrumentation is available only once you have connected your AWS Account to Baselime. Adding the tag to AWS Lambda functions in an AWS Account not connected to Baselime will not have any effect.
!!!
!!!
We recommended a miminum of 512mb of memory configured on AWS Lambda functions with the automatic OpenTelemetry instrumentation. AWS Lambda functions with less memory may experience higher latencies as the traces are being processed.
!!!
!!!
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.
!!!

!!!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.
!!!
For detailed instructions on how to add the tag to for your framework go to the [OpenTelemetry for AWS Lambda](./index.md) Guide

---

Expand Down
74 changes: 3 additions & 71 deletions sending-data/platforms/aws/aws-lambda/traces/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,9 @@ The [Baselime Python OpenTelemetry tracer for AWS Lambda](https://github.com/Bas

## Automatic Instrumentation

To automatically instrument your AWS Lambda functions with the [Baselime Python OpenTelemetry tracer for AWS Lambda](https://github.com/Baselime/python-opentelemetry), set the following tag to your AWS Lambda functions: `baselime:tracing=true`.
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 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"
```
+++
That's all you are all set with OpenTelemetry on Python AWS Lambda functions.
!!!
OpenTelemetry automatic instrumentation is available only once you have connected your AWS Account to Baselime. Adding the tag to AWS Lambda functions in an AWS Account not connected to Baselime will not have any effect.
!!!
!!!
We recommended a miminum of 512mb of memory configured on AWS Lambda functions with the automatic OpenTelemetry instrumentation. AWS Lambda functions with less memory may experience higher latencies as the traces are being processed.
!!!
!!!
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.
!!!

!!!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.
!!!
For detailed instructions on how to add the tag to for your framework go to the [OpenTelemetry for AWS Lambda](./index.md) Guide

---

Expand Down Expand Up @@ -120,14 +62,4 @@ def handler(event, context)
}


```

---

## Sending data to another OpenTelemetry backend

OpenTelemetry is an open standard, and you can use the [Baselime Python OpenTelemetry tracer for AWS Lambda](https://github.com/Baselime/python-opentelemetry) to send telemetry data to another backend of your choice.

Set environment variable `COLLECTOR_URL` to your observability backend.

---
```

0 comments on commit 4495be0

Please sign in to comment.