Skip to content

Commit e1bb09b

Browse files
kinyoklionVadman97
andauthored
Scaffold python observability plugin. (#97)
## Summary Scaffolds the project for the python observability plugin. ## How did you test this change? <!-- Frontend - Leave a screencast or a screenshot to visually describe the changes. --> ## Are there any deployment considerations? <!-- Backend - Do we need to consider migrations or backfilling data? --> ## Does this work require review from our design team? <!-- Request review from julian-highlight / our design team --> --------- Co-authored-by: Vadim Korolik <vkorolik@gmail.com>
1 parent a419d20 commit e1bb09b

File tree

6 files changed

+3527
-0
lines changed

6 files changed

+3527
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Python Observability Plugin
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
pull_request:
7+
types: [opened, synchronize]
8+
paths:
9+
- 'sdk/@launchdarkly/observability-python/**'
10+
- '.github/workflows/python-plugin.yml'
11+
# - 'e2e/tests/**'
12+
13+
concurrency: ${{ github.workflow }}-${{ github.ref }}
14+
jobs:
15+
build:
16+
permissions:
17+
id-token: write # for python PyPI OIDC login
18+
contents: write
19+
pull-requests: write
20+
repository-projects: write
21+
name: Quality Check and Publish
22+
runs-on: ubuntu-22.04-8core-32gb
23+
defaults:
24+
run:
25+
working-directory: ./sdk/@launchdarkly/observability-python
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
- name: Install poetry
31+
run: pipx install poetry
32+
- uses: actions/setup-python@v4
33+
with:
34+
python-version: '3.12'
35+
cache: 'poetry'
36+
- run: poetry install --all-extras
37+
- name: Lint
38+
run: poetry run black --check .
39+
# - name: Test
40+
# run: poetry run pytest --cov=ldobserve --cov-branch --cov-report xml
41+
# - name: Get Cover
42+
# if: github.event_name == 'pull_request'
43+
# uses: orgoro/coverage@v3
44+
# with:
45+
# coverageFile: ./sdk/@launchdarkly/observability-python/coverage.xml
46+
# token: ${{ secrets.GITHUB_TOKEN }}
47+
- name: Build
48+
run: poetry build
49+
#- name: Validate PyProject
50+
# working-directory: ./e2e/python/setuptools
51+
# run: |
52+
# python -m pip install -U pip pip-tools;
53+
# python -m piptools compile --upgrade pyproject.toml;
54+
#- name: Publish
55+
# if: github.ref == 'refs/heads/main'
56+
# uses: pypa/gh-action-pypi-publish@release/v1
57+
# with:
58+
# packages-dir: ./sdk/@launchdarkly/observability-python/dist/
59+
# skip-existing: true
60+
61+
# e2e:
62+
# name: Validate E2E tests
63+
# runs-on: ubuntu-22.04-8core-32gb
64+
# defaults:
65+
# run:
66+
# working-directory: ./e2e/tests
67+
68+
# steps:
69+
# - uses: actions/checkout@v4
70+
# with:
71+
# token: ${{ secrets.GITHUB_TOKEN }}
72+
# - name: Install poetry
73+
# run: pipx install poetry
74+
# - uses: actions/setup-python@v4
75+
# with:
76+
# python-version: '3.10'
77+
# cache: 'poetry'
78+
# - run: poetry install --all-extras
79+
# - name: Lint
80+
# run: poetry run black --check .
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
LaunchDarkly Observability SDK for Python
2+
===========================
3+
4+
[![Actions Status][pyplugin-sdk-ci-badge]][pyplugin-sdk-ci]
5+
[![readthedocs][readthedocs-badge]][readthedocs-link]
6+
7+
[![PyPI][pypi-version-badge]][pypi-link]
8+
[![PyPI][pypi-versions-badge]][pypi-link]
9+
10+
# Early Access Preview️
11+
12+
**NB: APIs are subject to change until a 1.x version is released.**
13+
14+
LaunchDarkly overview
15+
-------------------------
16+
[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves trillions of feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!
17+
18+
[![Twitter Follow](https://img.shields.io/twitter/follow/launchdarkly.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/intent/follow?screen_name=launchdarkly)
19+
20+
## Contributing
21+
22+
We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.
23+
24+
## About LaunchDarkly
25+
26+
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
27+
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
28+
* Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
29+
* Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
30+
* Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
31+
* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/docs) for a complete list.
32+
* Explore LaunchDarkly
33+
* [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
34+
* [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
35+
* [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
36+
* [launchdarkly.com/blog](https://launchdarkly.com/blog/ "LaunchDarkly Blog Documentation") for the latest product updates
37+
38+
[pyplugin-sdk-ci-badge]: https://github.com/launchdarkly/observability-sdk/actions/workflows/python-plugin.yml/badge.svg
39+
[pyplugin-sdk-ci]: https://github.com/launchdarkly/observability-sdk/actions/workflows/python-plugin.yml
40+
[readthedocs-badge]: https://readthedocs.org/projects/launchdarkly-observability/badge/
41+
[readthedocs-link]: https://launchdarkly-observability.readthedocs.io/en/latest/
42+
[pypi-version-badge]: https://img.shields.io/pypi/v/launchdarkly-observability.svg?maxAge=2592000
43+
[pypi-versions-badge]: https://img.shields.io/pypi/pyversions/launchdarkly-observability.svg
44+
[pypi-link]: https://pypi.python.org/pypi/launchdarkly-observability
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from typing import Optional
2+
3+
from ldobserve.config import ObservabilityConfig
4+
5+
6+
def init(project_id: str, config: Optional[ObservabilityConfig] = None):
7+
pass
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
from dataclasses import dataclass
2+
import logging
3+
from typing import Optional
4+
5+
6+
DEFAULT_OTLP_ENDPOINT = "https://otel.observability.app.launchdarkly.com:4317"
7+
DEFAULT_INSTRUMENT_LOGGING = True
8+
DEFAULT_LOG_LEVEL = logging.INFO
9+
DEFAULT_SERVICE_NAME = ""
10+
DEFAULT_SERVICE_VERSION = ""
11+
DEFAULT_ENVIRONMENT = ""
12+
DEFAULT_DISABLE_EXPORT_ERROR_LOGGING = False
13+
14+
15+
@dataclass(kw_only=True)
16+
class ObservabilityConfig:
17+
otlp_endpoint: Optional[str] = None
18+
"""
19+
Used to set a custom OTLP endpoint.
20+
21+
Alternatively, set the OTEL_EXPORTER_OTLP_ENDPOINT environment variable.
22+
"""
23+
24+
instrument_logging: Optional[bool] = None
25+
"""
26+
If True, the OpenTelemetry logging instrumentation will be enabled.
27+
28+
If False, the OpenTelemetry logging instrumentation will be disabled.
29+
30+
Alternatively, set the OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED environment variable.
31+
32+
Defaults to True.
33+
"""
34+
35+
log_level: Optional[int] = None
36+
"""
37+
The log level to use for the OpenTelemetry logging instrumentation.
38+
39+
Defaults to logging.INFO.
40+
"""
41+
42+
service_name: Optional[str] = None
43+
"""
44+
The name of the service to use for the OpenTelemetry resource.
45+
"""
46+
47+
service_version: Optional[str] = None
48+
"""
49+
The version of the service to use for the OpenTelemetry resource.
50+
"""
51+
52+
environment: Optional[str] = None
53+
"""
54+
The environment of the service to use for the OpenTelemetry resource.
55+
"""
56+
57+
disable_export_error_logging: Optional[bool] = None
58+
"""
59+
If True, the OpenTelemetry export error logging will be disabled.
60+
61+
Defaults to False.
62+
"""
63+
64+
def __getitem__(self, key: str):
65+
return getattr(self, key)

0 commit comments

Comments
 (0)