Skip to content

Commit bea78dd

Browse files
committed
formatting
1 parent af431bd commit bea78dd

23 files changed

Lines changed: 305 additions & 229 deletions

.devcontainer/devcontainer.json

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
22
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.0/containers/python-3
33
{
4-
"name": "Python 3",
5-
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",
4+
"name": "Python 3",
5+
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",
66

7-
// Configure tool-specific properties.
8-
"customizations": {
9-
// Configure properties specific to VS Code.
10-
"vscode": {
11-
// Set *default* container specific settings.json values on container create.
12-
"settings": {
13-
"python.defaultInterpreterPath": "/usr/local/bin/python",
14-
"python.testing.pytestEnabled": true,
15-
"python.testing.unittestEnabled": false,
16-
"files.exclude": {
17-
".coverage": true,
18-
".pytest_cache": true,
19-
"__pycache__": true
20-
}
21-
},
22-
23-
// Add the IDs of extensions you want installed when the container is created.
24-
"extensions": [
25-
"ms-python.python",
26-
"charliermarsh.ruff",
27-
"ms-python.black-formatter"
28-
]
7+
// Configure tool-specific properties.
8+
"customizations": {
9+
// Configure properties specific to VS Code.
10+
"vscode": {
11+
// Set *default* container specific settings.json values on container create.
12+
"settings": {
13+
"python.defaultInterpreterPath": "/usr/local/bin/python",
14+
"python.testing.pytestEnabled": true,
15+
"python.testing.unittestEnabled": false,
16+
"files.exclude": {
17+
".coverage": true,
18+
".pytest_cache": true,
19+
"__pycache__": true
2920
}
30-
},
21+
},
22+
23+
// Add the IDs of extensions you want installed when the container is created.
24+
"extensions": [
25+
"ms-python.python",
26+
"charliermarsh.ruff",
27+
"ms-python.black-formatter"
28+
]
29+
}
30+
},
3131

32-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
33-
// "forwardPorts": [],
32+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
33+
// "forwardPorts": [],
3434

35-
// Use 'postCreateCommand' to run commands after the container is created.
36-
"postCreateCommand": "pip3 install --user -r requirements-dev.txt && pre-commit install",
35+
// Use 'postCreateCommand' to run commands after the container is created.
36+
"postCreateCommand": "pip3 install --user -r requirements-dev.txt && pre-commit install",
3737

38-
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
39-
"remoteUser": "vscode"
38+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
39+
"remoteUser": "vscode"
4040
}

CHANGELOG.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
## [project-title] Changelog
22

33
<a name="x.y.z"></a>
4+
45
# x.y.z (yyyy-mm-dd)
56

6-
*Features*
7-
* ...
7+
_Features_
8+
9+
- ...
10+
11+
_Bug Fixes_
12+
13+
- ...
814

9-
*Bug Fixes*
10-
* ...
15+
_Breaking Changes_
1116

12-
*Breaking Changes*
13-
* ...
17+
- ...

CONTRIBUTING.md

Lines changed: 68 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,93 @@
11
# Contributing to [project-title]
22

3-
This project welcomes contributions and suggestions. Most contributions require you to agree to a
4-
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
5-
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
6-
7-
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
8-
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
9-
provided by the bot. You will only need to do this once across all repos using our CLA.
10-
11-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
12-
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
13-
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
14-
15-
- [Code of Conduct](#coc)
16-
- [Issues and Bugs](#issue)
17-
- [Feature Requests](#feature)
18-
- [Submission Guidelines](#submit)
3+
This project welcomes contributions and suggestions. Most contributions require
4+
you to agree to a Contributor License Agreement (CLA) declaring that you have
5+
the right to, and actually do, grant us the rights to use your contribution. For
6+
details, visit https://cla.opensource.microsoft.com.
7+
8+
When you submit a pull request, a CLA bot will automatically determine whether
9+
you need to provide a CLA and decorate the PR appropriately (e.g., status check,
10+
comment). Simply follow the instructions provided by the bot. You will only need
11+
to do this once across all repos using our CLA.
12+
13+
This project has adopted the
14+
[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
15+
For more information see the
16+
[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
17+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any
18+
additional questions or comments.
19+
20+
- [Code of Conduct](#coc)
21+
- [Issues and Bugs](#issue)
22+
- [Feature Requests](#feature)
23+
- [Submission Guidelines](#submit)
1924

2025
## <a name="coc"></a> Code of Conduct
21-
Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
26+
27+
Help us keep this project open and inclusive. Please read and follow our
28+
[Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
2229

2330
## <a name="issue"></a> Found an Issue?
24-
If you find a bug in the source code or a mistake in the documentation, you can help us by
25-
[submitting an issue](#submit-issue) to the GitHub Repository. Even better, you can
26-
[submit a Pull Request](#submit-pr) with a fix.
31+
32+
If you find a bug in the source code or a mistake in the documentation, you can
33+
help us by [submitting an issue](#submit-issue) to the GitHub Repository. Even
34+
better, you can [submit a Pull Request](#submit-pr) with a fix.
2735

2836
## <a name="feature"></a> Want a Feature?
29-
You can *request* a new feature by [submitting an issue](#submit-issue) to the GitHub
30-
Repository. If you would like to *implement* a new feature, please submit an issue with
31-
a proposal for your work first, to be sure that we can use it.
3237

33-
* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
38+
You can _request_ a new feature by [submitting an issue](#submit-issue) to the
39+
GitHub Repository. If you would like to _implement_ a new feature, please submit
40+
an issue with a proposal for your work first, to be sure that we can use it.
41+
42+
- **Small Features** can be crafted and directly
43+
[submitted as a Pull Request](#submit-pr).
3444

3545
## <a name="submit"></a> Submission Guidelines
3646

3747
### <a name="submit-issue"></a> Submitting an Issue
38-
Before you submit an issue, search the archive, maybe your question was already answered.
48+
49+
Before you submit an issue, search the archive, maybe your question was already
50+
answered.
3951

4052
If your issue appears to be a bug, and hasn't been reported, open a new issue.
4153
Help us to maximize the effort we can spend fixing issues and adding new
42-
features, by not reporting duplicate issues. Providing the following information will increase the
43-
chances of your issue being dealt with quickly:
44-
45-
* **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
46-
* **Version** - what version is affected (e.g. 0.1.2)
47-
* **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you
48-
* **Browsers and Operating System** - is this a problem with all browsers?
49-
* **Reproduce the Error** - provide a live example or a unambiguous set of steps
50-
* **Related Issues** - has a similar issue been reported before?
51-
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
52-
causing the problem (line of code or commit)
53-
54-
You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/[organization-name]/[repository-name]/issues/new].
54+
features, by not reporting duplicate issues. Providing the following information
55+
will increase the chances of your issue being dealt with quickly:
56+
57+
- **Overview of the Issue** - if an error is being thrown a non-minified stack
58+
trace helps
59+
- **Version** - what version is affected (e.g. 0.1.2)
60+
- **Motivation for or Use Case** - explain what are you trying to do and why the
61+
current behavior is a bug for you
62+
- **Browsers and Operating System** - is this a problem with all browsers?
63+
- **Reproduce the Error** - provide a live example or a unambiguous set of steps
64+
- **Related Issues** - has a similar issue been reported before?
65+
- **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point
66+
to what might be causing the problem (line of code or commit)
67+
68+
You can file new issues by providing the above information at the corresponding
69+
repository's issues link:
70+
https://github.com/[organization-name]/[repository-name]/issues/new].
5571

5672
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
73+
5774
Before you submit your Pull Request (PR) consider the following guidelines:
5875

59-
* Search the repository (https://github.com/[organization-name]/[repository-name]/pulls) for an open or closed PR
60-
that relates to your submission. You don't want to duplicate effort.
76+
- Search the repository
77+
(https://github.com/[organization-name]/[repository-name]/pulls) for an open
78+
or closed PR that relates to your submission. You don't want to duplicate
79+
effort.
80+
81+
- Make your changes in a new git fork:
6182

62-
* Make your changes in a new git fork:
83+
- Commit your changes using a descriptive commit message
84+
- Push your fork to GitHub:
85+
- In GitHub, create a pull request
86+
- If we suggest changes then:
6387

64-
* Commit your changes using a descriptive commit message
65-
* Push your fork to GitHub:
66-
* In GitHub, create a pull request
67-
* If we suggest changes then:
68-
* Make the required updates.
69-
* Rebase your fork and force push to your GitHub repository (this will update your Pull Request):
88+
- Make the required updates.
89+
- Rebase your fork and force push to your GitHub repository (this will update
90+
your Pull Request):
7091

7192
```shell
7293
git rebase master -i

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
<!-- prettier-ignore-end -->
2828

29-
This library adds basic telemetry to Python projects that traces the usage and run time of Python functions within a given scope.
29+
This library adds basic telemetry to Python projects that traces the usage and
30+
run time of Python functions within a given scope.
3031

3132
## Installation
3233

@@ -46,16 +47,13 @@ To track usage of one or more existing Python projects, run:
4647
from opentelemetry.instrumentation.auto_instrumentation import initialize
4748
from telemetric import install
4849

49-
install(
50-
[
51-
my_project.my_module
52-
]
53-
)
50+
install([my_project.my_module])
5451
initialize()
55-
start_span_processor('my-project-service')
52+
start_span_processor("my-project-service")
5653
```
5754

58-
To explicitly add instrumentation to functions you want to trace, use the `span` decorator:
55+
To explicitly add instrumentation to functions you want to trace, use the `span`
56+
decorator:
5957

6058
```python
6159
from telemetric import span, start_span_processor
@@ -65,14 +63,16 @@ from telemetric import span, start_span_processor
6563
def foo(bar):
6664
print(bar)
6765

66+
6867
if __name__ == "__main__":
6968
start_span_processor("test-service")
7069
foo(bar="baz")
7170
```
7271

7372
## Start collector
7473

75-
To start a collector that prints each log message to stdout, run `cd tests/collector` and run
74+
To start a collector that prints each log message to stdout, run
75+
`cd tests/collector` and run
7676

7777
```bash
7878
docker run -p 4317:4317 -p 4318:4318 --rm -v $(pwd)/collector-config.yaml:/etc/otelcol/config.yaml otel/opentelemetry-collector
@@ -88,5 +88,3 @@ docker run --name jaeger \
8888
-p 4318:4318 \
8989
jaegertracing/all-in-one:1.35
9090
```
91-
92-

build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
class CustomBuildHook(BuildHookInterface):
99
def initialize(self, version, build_data):
10-
build_data['ext_modules'] = [
10+
build_data["ext_modules"] = [
1111
Extension(
1212
"telemetric._stats_wrapper",
1313
["src/telemetric/_stats_wrapper.c"],
1414
),
1515
]
16-
build_data['cmdclass'] = {"build_ext": build_ext}
16+
build_data["cmdclass"] = {"build_ext": build_ext}

examples/test_scipy.ipynb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,23 @@
2828
"scrolled": true
2929
},
3030
"outputs": [],
31-
"source": "from opentelemetry.instrumentation.auto_instrumentation import initialize\n\nfrom telemetric import install\nfrom telemetric.console import setup_console\n\n# Set up which modules should be instrumented\ninstall([\n \"scipy.stats._correlation\",\n \"scipy.stats._distn_infrastructure\"\n])\n\n# Set up Grafana Cloud logging\ninitialize()\n\n# Set up Console logging\nsetup_console()"
31+
"source": [
32+
"from __future__ import annotations\n",
33+
"\n",
34+
"from opentelemetry.instrumentation.auto_instrumentation import initialize\n",
35+
"\n",
36+
"from telemetric import install\n",
37+
"from telemetric.console import setup_console\n",
38+
"\n",
39+
"# Set up which modules should be instrumented\n",
40+
"install([\"scipy.stats._correlation\", \"scipy.stats._distn_infrastructure\"])\n",
41+
"\n",
42+
"# Set up Grafana Cloud logging\n",
43+
"initialize()\n",
44+
"\n",
45+
"# Set up Console logging\n",
46+
"setup_console()"
47+
]
3248
},
3349
{
3450
"cell_type": "code",
@@ -92,4 +108,4 @@
92108
},
93109
"nbformat": 4,
94110
"nbformat_minor": 5
95-
}
111+
}

examples/test_scipy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# from opentelemetry.instrumentation.auto_instrumentation import initialize
2+
from __future__ import annotations
3+
24
from telemetric import install
35

46
# from telemetric.console import setup_console
@@ -21,7 +23,7 @@
2123
# How many calls (errors, and how often something was odd with the args)
2224
print("counts: ", stats.norm.pdf._get_counts())
2325

24-
# Detailed statics for each parameter. How often was it passed
26+
# Detailed statistics for each parameter. How often was it passed
2527
# and how often were "a" and 3 passed (or something equal to them,
2628
# I do not consider types right now, although one could)?
2729
print("param stats: ", stats.norm.pdf._get_param_stats())

examples/test_span.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from time import sleep
24

35
from telemetric.console import setup_console

examples/test_stats_uploader.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""Test script for the stats uploader module"""
22

3+
from __future__ import annotations
4+
35
import logging
46

5-
from telemetric.statswrapper import stats_deco
67
from telemetric.ga4.stats_uploader import StatsUploader
8+
from telemetric.statswrapper import stats_deco
79

810
logging.basicConfig(level=logging.DEBUG)
911

@@ -45,7 +47,9 @@ def another_func(x=1, y=True):
4547
print("=== Testing Stats Uploader ===")
4648

4749
# Use a dummy proxy URL for testing (won't actually send data unless configured)
48-
uploader = StatsUploader(proxy_url="https://analytics-proxy-production-665e.up.railway.app")
50+
uploader = StatsUploader(
51+
proxy_url="https://analytics-proxy-production-665e.up.railway.app"
52+
)
4953

5054
print("Analytics client enabled:", uploader.analytics.enabled)
5155

@@ -65,9 +69,7 @@ def another_func(x=1, y=True):
6569

6670
# Test custom stats upload
6771
print("\nUploading custom stats...")
68-
custom_result = uploader.upload_custom_stats("custom_metric", {
69-
"metric_name": "test_metric",
70-
"value": 42,
71-
"category": "testing"
72-
})
72+
custom_result = uploader.upload_custom_stats(
73+
"custom_metric", {"metric_name": "test_metric", "value": 42, "category": "testing"}
74+
)
7375
print("Custom upload result:", custom_result)

0 commit comments

Comments
 (0)