rebrandly-otel 0.2.4__py3-none-any.whl → 0.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rebrandly-otel might be problematic. Click here for more details.
- rebrandly_otel/fastapi_support.py +1 -1
- rebrandly_otel/flask_support.py +1 -1
- rebrandly_otel/http_utils.py +2 -1
- rebrandly_otel/otel_utils.py +12 -2
- rebrandly_otel/rebrandly_otel.py +8 -2
- {rebrandly_otel-0.2.4.dist-info → rebrandly_otel-0.2.6.dist-info}/METADATA +37 -1
- rebrandly_otel-0.2.6.dist-info/RECORD +15 -0
- rebrandly_otel-0.2.4.dist-info/RECORD +0 -15
- {rebrandly_otel-0.2.4.dist-info → rebrandly_otel-0.2.6.dist-info}/WHEEL +0 -0
- {rebrandly_otel-0.2.4.dist-info → rebrandly_otel-0.2.6.dist-info}/licenses/LICENSE +0 -0
- {rebrandly_otel-0.2.4.dist-info → rebrandly_otel-0.2.6.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# fastapi_integration.py
|
|
2
2
|
"""FastAPI integration for Rebrandly OTEL SDK."""
|
|
3
3
|
import json
|
|
4
|
-
from
|
|
4
|
+
from opentelemetry.trace import Status, StatusCode, SpanKind
|
|
5
5
|
from .http_utils import filter_important_headers
|
|
6
6
|
from fastapi import HTTPException, Depends
|
|
7
7
|
from starlette.requests import Request
|
rebrandly_otel/flask_support.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"""Flask integration for Rebrandly OTEL SDK."""
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
|
-
from
|
|
5
|
+
from opentelemetry.trace import Status, StatusCode, SpanKind
|
|
6
6
|
from .http_utils import filter_important_headers
|
|
7
7
|
|
|
8
8
|
from flask import request, jsonify
|
rebrandly_otel/http_utils.py
CHANGED
rebrandly_otel/otel_utils.py
CHANGED
|
@@ -6,7 +6,7 @@ import sys
|
|
|
6
6
|
import grpc
|
|
7
7
|
import json
|
|
8
8
|
|
|
9
|
-
from opentelemetry.sdk.resources import Resource, SERVICE_NAMESPACE
|
|
9
|
+
from opentelemetry.sdk.resources import Resource, SERVICE_NAMESPACE, DEPLOYMENT_ENVIRONMENT
|
|
10
10
|
from opentelemetry.semconv.attributes import service_attributes, telemetry_attributes
|
|
11
11
|
from opentelemetry.semconv.resource import ResourceAttributes
|
|
12
12
|
from opentelemetry.semconv._incubating.attributes import process_attributes, deployment_attributes
|
|
@@ -21,11 +21,14 @@ def create_resource(name: str = None, version: str = None) -> Resource:
|
|
|
21
21
|
if version is None:
|
|
22
22
|
version = get_service_version()
|
|
23
23
|
|
|
24
|
+
env = os.environ.get('ENV', os.environ.get('ENVIRONMENT', os.environ.get('NODE_ENV', 'local')))
|
|
25
|
+
|
|
24
26
|
resources_attributes = {
|
|
25
27
|
service_attributes.SERVICE_NAME: name,
|
|
26
28
|
service_attributes.SERVICE_VERSION: version,
|
|
27
29
|
process_attributes.PROCESS_RUNTIME_VERSION: f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
|
|
28
|
-
SERVICE_NAMESPACE:
|
|
30
|
+
SERVICE_NAMESPACE: env,
|
|
31
|
+
DEPLOYMENT_ENVIRONMENT: env,
|
|
29
32
|
telemetry_attributes.TELEMETRY_SDK_LANGUAGE: "python"
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -41,6 +44,13 @@ def create_resource(name: str = None, version: str = None) -> Resource:
|
|
|
41
44
|
resources_attributes[k.strip()] = v.strip()
|
|
42
45
|
except Exception as e:
|
|
43
46
|
print(f"[OTEL Utils] Warning: Invalid OTEL_RESOURCE_ATTRIBUTES value: {e}")
|
|
47
|
+
|
|
48
|
+
if os.environ.get('OTEL_REPO_NAME', None) is not None:
|
|
49
|
+
resources_attributes['repository.name'] = os.environ.get('OTEL_REPO_NAME')
|
|
50
|
+
|
|
51
|
+
if os.environ.get('OTEL_COMMIT_ID', None) is not None:
|
|
52
|
+
resources_attributes[service_attributes.SERVICE_VERSION] = os.environ.get('OTEL_COMMIT_ID')
|
|
53
|
+
|
|
44
54
|
resource = Resource.create(
|
|
45
55
|
resources_attributes
|
|
46
56
|
)
|
rebrandly_otel/rebrandly_otel.py
CHANGED
|
@@ -73,7 +73,7 @@ class RebrandlyOTEL:
|
|
|
73
73
|
kind: SpanKind = SpanKind.INTERNAL,
|
|
74
74
|
message=None):
|
|
75
75
|
"""Create a span using context manager."""
|
|
76
|
-
with self.tracer.start_span(name, attributes=attributes, kind=kind) as span:
|
|
76
|
+
with self.tracer.start_span(name=name, attributes=attributes, kind=kind) as span:
|
|
77
77
|
try:
|
|
78
78
|
yield span
|
|
79
79
|
span.set_status(Status(StatusCode.OK))
|
|
@@ -510,7 +510,13 @@ class RebrandlyOTEL:
|
|
|
510
510
|
attributes=combined_attributes,
|
|
511
511
|
kind=kind
|
|
512
512
|
) as span:
|
|
513
|
-
|
|
513
|
+
try:
|
|
514
|
+
yield span
|
|
515
|
+
span.set_status(Status(StatusCode.OK))
|
|
516
|
+
except Exception as e:
|
|
517
|
+
span.record_exception(e)
|
|
518
|
+
span.set_status(Status(StatusCode.ERROR, str(e)))
|
|
519
|
+
raise
|
|
514
520
|
|
|
515
521
|
|
|
516
522
|
# Create Singleton instance
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rebrandly_otel
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.6
|
|
4
4
|
Summary: Python OTEL wrapper by Rebrandly
|
|
5
5
|
Home-page: https://github.com/rebrandly/rebrandly-otel-python
|
|
6
6
|
Author: Antonio Romano
|
|
@@ -502,6 +502,42 @@ Environment configuration:
|
|
|
502
502
|
### More examples
|
|
503
503
|
You can find More examples [here](examples)
|
|
504
504
|
|
|
505
|
+
## Testing
|
|
506
|
+
|
|
507
|
+
### Running Tests
|
|
508
|
+
|
|
509
|
+
The test suite uses [pytest](https://docs.pytest.org/).
|
|
510
|
+
|
|
511
|
+
Run all tests:
|
|
512
|
+
```bash
|
|
513
|
+
pytest
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Run specific test file:
|
|
517
|
+
```bash
|
|
518
|
+
pytest tests/test_flask_support.py -v
|
|
519
|
+
pytest tests/test_fastapi_support.py -v
|
|
520
|
+
pytest tests/test_usage.py -v
|
|
521
|
+
pytest tests/test_pymysql_instrumentation.py -v
|
|
522
|
+
pytest tests/test_metrics_and_logs.py -v
|
|
523
|
+
pytest tests/test_decorators.py -v
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Run with coverage:
|
|
527
|
+
```bash
|
|
528
|
+
pytest --cov=src --cov-report=html
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Test Coverage
|
|
532
|
+
|
|
533
|
+
The test suite includes:
|
|
534
|
+
- **Integration tests** (`test_usage.py`): Core OTEL functionality, Lambda handlers, message processing
|
|
535
|
+
- **Flask integration tests** (`test_flask_support.py`): Flask setup and hooks
|
|
536
|
+
- **FastAPI integration tests** (`test_fastapi_support.py`): FastAPI setup and middleware
|
|
537
|
+
- **PyMySQL instrumentation tests** (`test_pymysql_instrumentation.py`): Database connection instrumentation, query tracing, helper functions
|
|
538
|
+
- **Metrics and logs tests** (`test_metrics_and_logs.py`): Custom metrics creation (counter, histogram, gauge), logging levels (info, warning, debug, error)
|
|
539
|
+
- **Decorators tests** (`test_decorators.py`): Lambda handler decorator, AWS message handler decorator, traces decorator, aws_message_span context manager
|
|
540
|
+
|
|
505
541
|
## License
|
|
506
542
|
|
|
507
543
|
Rebrandly Python SDK is released under the MIT License.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
rebrandly_otel/__init__.py,sha256=dEcTvHbhNNp0XD_7jojxeHXNa1QDCI9HxayeICaK_WY,491
|
|
2
|
+
rebrandly_otel/fastapi_support.py,sha256=M1FHkM9Uv6pga6s8F3O-IeXAXzc4EMPAXAStRk7bGu4,8222
|
|
3
|
+
rebrandly_otel/flask_support.py,sha256=wn_Esiu4cy48f_rD-kwIypRKeJ8D1pT6x4WZacEQmZY,6321
|
|
4
|
+
rebrandly_otel/http_utils.py,sha256=5mHJQCJ-5FDFNmTRPaErtdQLAEzCbcDJqoiGzjgKe0w,741
|
|
5
|
+
rebrandly_otel/logs.py,sha256=9uwWbQ9h9YcxF7-2vtsYucaMGCqMoPnO2vWf6qkyGgI,5328
|
|
6
|
+
rebrandly_otel/metrics.py,sha256=jZPygTY7vie33sadXc7P1DwLTKe9tJvAWSZuGHW1xQg,7743
|
|
7
|
+
rebrandly_otel/otel_utils.py,sha256=vr5ygRXY2If-c2Vq2ectupTm1AHgSPkflEw25O5T7NE,6162
|
|
8
|
+
rebrandly_otel/pymysql_instrumentation.py,sha256=lS_V5DcsnpQ3f2PoNqeM7t3Jyiew2KNURM9iILfz8sM,6477
|
|
9
|
+
rebrandly_otel/rebrandly_otel.py,sha256=dnE8jkcnP3X7Eu_tpjWU96pYJ5dULV-QVK_Im_msdEM,22675
|
|
10
|
+
rebrandly_otel/traces.py,sha256=JY_3RWbzpUxzEx3GqTVgggsyA2DB4oR-zDftIFFJha4,7174
|
|
11
|
+
rebrandly_otel-0.2.6.dist-info/licenses/LICENSE,sha256=KMXHvTwP62S2q-SG7CFfMU_09rUwxiqlM0izaYGdcgY,1103
|
|
12
|
+
rebrandly_otel-0.2.6.dist-info/METADATA,sha256=rzUepZJY4gckBpN6NIIrMajNwIQITBvEH-h6bSjaKM0,15740
|
|
13
|
+
rebrandly_otel-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
+
rebrandly_otel-0.2.6.dist-info/top_level.txt,sha256=26PSC1gjVUl8tTH5QfKbFevjVV4E2yojoukEfiTScvM,15
|
|
15
|
+
rebrandly_otel-0.2.6.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
rebrandly_otel/__init__.py,sha256=dEcTvHbhNNp0XD_7jojxeHXNa1QDCI9HxayeICaK_WY,491
|
|
2
|
-
rebrandly_otel/fastapi_support.py,sha256=Fq0ggBvmz4nSGBw8p9PGIGcTcpwlbmt5BgLLbl1bf6s,8217
|
|
3
|
-
rebrandly_otel/flask_support.py,sha256=G0Q3apg4urtvHfXFb1uANomryAL7Mo2nPPULEe7j7WQ,6316
|
|
4
|
-
rebrandly_otel/http_utils.py,sha256=Cwo1Ku1-BMqRp37ycvHtbiArxEjFPYU_zkF1H9_7CIE,719
|
|
5
|
-
rebrandly_otel/logs.py,sha256=9uwWbQ9h9YcxF7-2vtsYucaMGCqMoPnO2vWf6qkyGgI,5328
|
|
6
|
-
rebrandly_otel/metrics.py,sha256=jZPygTY7vie33sadXc7P1DwLTKe9tJvAWSZuGHW1xQg,7743
|
|
7
|
-
rebrandly_otel/otel_utils.py,sha256=rZhrLUSlDGxlaCDQMPeL8JGMj3F2HUp5Knl2e1HD-Rk,5782
|
|
8
|
-
rebrandly_otel/pymysql_instrumentation.py,sha256=lS_V5DcsnpQ3f2PoNqeM7t3Jyiew2KNURM9iILfz8sM,6477
|
|
9
|
-
rebrandly_otel/rebrandly_otel.py,sha256=8ty2rxcuaYV5WsNye7odxXXuh91kpdd5RVGOGSvsT98,22430
|
|
10
|
-
rebrandly_otel/traces.py,sha256=JY_3RWbzpUxzEx3GqTVgggsyA2DB4oR-zDftIFFJha4,7174
|
|
11
|
-
rebrandly_otel-0.2.4.dist-info/licenses/LICENSE,sha256=KMXHvTwP62S2q-SG7CFfMU_09rUwxiqlM0izaYGdcgY,1103
|
|
12
|
-
rebrandly_otel-0.2.4.dist-info/METADATA,sha256=EYalPNbuHeVBQNN8XIp-b-nnLgO3rICy2C494Unv8BA,14509
|
|
13
|
-
rebrandly_otel-0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
14
|
-
rebrandly_otel-0.2.4.dist-info/top_level.txt,sha256=26PSC1gjVUl8tTH5QfKbFevjVV4E2yojoukEfiTScvM,15
|
|
15
|
-
rebrandly_otel-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|