otel-utils 0.1.11__tar.gz → 0.1.12__tar.gz
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 otel-utils might be problematic. Click here for more details.
- {otel_utils-0.1.11 → otel_utils-0.1.12}/PKG-INFO +50 -28
- {otel_utils-0.1.11 → otel_utils-0.1.12}/README.md +50 -28
- {otel_utils-0.1.11 → otel_utils-0.1.12}/pyproject.toml +1 -1
- {otel_utils-0.1.11 → otel_utils-0.1.12}/src/otel_utils/__init__.py +0 -0
- {otel_utils-0.1.11 → otel_utils-0.1.12}/src/otel_utils/configurator.py +0 -0
- {otel_utils-0.1.11 → otel_utils-0.1.12}/src/otel_utils/logging.py +0 -0
- {otel_utils-0.1.11 → otel_utils-0.1.12}/src/otel_utils/metrics.py +0 -0
- {otel_utils-0.1.11 → otel_utils-0.1.12}/src/otel_utils/tracing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: otel-utils
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.12
|
|
4
4
|
Summary: Utilidades simplificadas para instrumentación con OpenTelemetry
|
|
5
5
|
License: Proprietary
|
|
6
6
|
Author: Harold Portocarrero
|
|
@@ -38,31 +38,35 @@ A Python library designed to simplify application instrumentation using OpenTele
|
|
|
38
38
|
|
|
39
39
|
## Installation
|
|
40
40
|
|
|
41
|
-
To install the library from the private repository:
|
|
42
|
-
|
|
43
41
|
```bash
|
|
44
|
-
pip install
|
|
42
|
+
pip install otel-utils
|
|
45
43
|
```
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
git+ssh://git@github.com/your-organization/otel-utils.git@v0.1.0
|
|
50
|
-
```
|
|
45
|
+
## Basic Usage
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
## Initial Configuration
|
|
47
|
+
### Initial Configuration
|
|
54
48
|
```python
|
|
55
49
|
from otel_utils import OtelConfig, OtelConfigurator
|
|
56
50
|
|
|
57
51
|
config = OtelConfig(
|
|
58
52
|
service_name="my-service",
|
|
59
|
-
environment="production"
|
|
53
|
+
environment="production",
|
|
54
|
+
otlp_endpoint="http://localhost:4318", # Optional
|
|
55
|
+
protocol="http", # "http" or "grpc", default "grpc"
|
|
56
|
+
trace_sample_rate=1.0, # Sampling rate, default 1.0
|
|
57
|
+
metric_export_interval_ms=30000, # Metrics export interval
|
|
58
|
+
log_level=logging.INFO, # Logging level
|
|
59
|
+
enable_console_logging=True, # Enable console logging
|
|
60
|
+
additional_resources={ # Optional additional resources
|
|
61
|
+
"deployment.region": "us-east-1",
|
|
62
|
+
"team.name": "backend"
|
|
63
|
+
}
|
|
60
64
|
)
|
|
61
65
|
|
|
62
66
|
OtelConfigurator(config)
|
|
63
67
|
```
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
### Tracing
|
|
66
70
|
```python
|
|
67
71
|
from otel_utils import Tracer
|
|
68
72
|
|
|
@@ -80,7 +84,7 @@ with tracer.create_span("my_operation") as span:
|
|
|
80
84
|
# Your code here
|
|
81
85
|
```
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
### Metrics
|
|
84
88
|
```python
|
|
85
89
|
from otel_utils import Metrics
|
|
86
90
|
|
|
@@ -96,7 +100,7 @@ with metrics.measure_duration("request_duration"):
|
|
|
96
100
|
pass
|
|
97
101
|
```
|
|
98
102
|
|
|
99
|
-
|
|
103
|
+
### Structured Logging
|
|
100
104
|
```python
|
|
101
105
|
from otel_utils import StructuredLogger
|
|
102
106
|
|
|
@@ -107,15 +111,15 @@ with logger.operation_context("process_order", order_id="123"):
|
|
|
107
111
|
# Your code here
|
|
108
112
|
```
|
|
109
113
|
|
|
110
|
-
|
|
114
|
+
## OpenTelemetry Collector Integration
|
|
115
|
+
|
|
111
116
|
This library is designed to work seamlessly with the OpenTelemetry Collector. Telemetry data is sent using the OTLP protocol, which is the OpenTelemetry standard.
|
|
117
|
+
|
|
118
|
+
### Collector Configuration with HTTP
|
|
112
119
|
```yaml
|
|
113
|
-
# collector configuration example
|
|
114
120
|
receivers:
|
|
115
121
|
otlp:
|
|
116
122
|
protocols:
|
|
117
|
-
grpc:
|
|
118
|
-
endpoint: 0.0.0.0:4317
|
|
119
123
|
http:
|
|
120
124
|
endpoint: 0.0.0.0:4318
|
|
121
125
|
|
|
@@ -129,20 +133,40 @@ service:
|
|
|
129
133
|
exporters: [your-exporter]
|
|
130
134
|
```
|
|
131
135
|
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
### Collector Configuration with gRPC
|
|
137
|
+
```yaml
|
|
138
|
+
receivers:
|
|
139
|
+
otlp:
|
|
140
|
+
protocols:
|
|
141
|
+
grpc:
|
|
142
|
+
endpoint: 0.0.0.0:4317
|
|
143
|
+
|
|
144
|
+
exporters:
|
|
145
|
+
# configure your exporters here
|
|
146
|
+
|
|
147
|
+
service:
|
|
148
|
+
pipelines:
|
|
149
|
+
traces:
|
|
150
|
+
receivers: [otlp]
|
|
151
|
+
exporters: [your-exporter]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Best Practices
|
|
155
|
+
|
|
156
|
+
### Separation of Concerns
|
|
134
157
|
Keep instrumentation separate from business logic by creating domain-specific abstractions. Your business code should remain clean and focused on its primary responsibilities.
|
|
135
158
|
|
|
136
|
-
|
|
159
|
+
### Consistent Naming
|
|
137
160
|
Use coherent naming conventions for spans, metrics, and logs across your services. This makes it easier to correlate and analyze telemetry data.
|
|
138
161
|
|
|
139
|
-
|
|
162
|
+
### Relevant Context
|
|
140
163
|
Include useful contextual information in spans and logs, but be mindful of sensitive data. Focus on information that aids debugging and monitoring.
|
|
141
164
|
|
|
142
|
-
|
|
165
|
+
### Appropriate Granularity
|
|
143
166
|
Don't instrument everything. Focus on significant operations that provide value for monitoring and debugging. Consider the overhead and noise ratio when adding instrumentation.
|
|
144
167
|
|
|
145
|
-
|
|
168
|
+
## Development
|
|
169
|
+
|
|
146
170
|
To set up the development environment:
|
|
147
171
|
|
|
148
172
|
```bash
|
|
@@ -157,11 +181,9 @@ pip install -e ".[dev]"
|
|
|
157
181
|
pytest
|
|
158
182
|
```
|
|
159
183
|
|
|
160
|
-
|
|
184
|
+
## Contributing
|
|
185
|
+
|
|
161
186
|
1. Create a feature branch (`git checkout -b feature/new-feature`)
|
|
162
187
|
2. Commit your changes (`git commit -am 'Add new feature'`)
|
|
163
188
|
3. Push to the branch (`git push origin feature/new-feature`)
|
|
164
189
|
4. Create a Pull Request
|
|
165
|
-
|
|
166
|
-
I hope this documentation helps you understand and effectively use the OpenTelemetry Utils library. Each section is designed to guide you through the essential aspects of instrumenting your applications while maintaining clean and maintainable code.
|
|
167
|
-
Let me know if you need any clarification or have questions about specific features or use cases. We can explore any aspect of the library in more detail.
|
|
@@ -13,31 +13,35 @@ A Python library designed to simplify application instrumentation using OpenTele
|
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
|
-
To install the library from the private repository:
|
|
17
|
-
|
|
18
16
|
```bash
|
|
19
|
-
pip install
|
|
17
|
+
pip install otel-utils
|
|
20
18
|
```
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
git+ssh://git@github.com/your-organization/otel-utils.git@v0.1.0
|
|
25
|
-
```
|
|
20
|
+
## Basic Usage
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
## Initial Configuration
|
|
22
|
+
### Initial Configuration
|
|
29
23
|
```python
|
|
30
24
|
from otel_utils import OtelConfig, OtelConfigurator
|
|
31
25
|
|
|
32
26
|
config = OtelConfig(
|
|
33
27
|
service_name="my-service",
|
|
34
|
-
environment="production"
|
|
28
|
+
environment="production",
|
|
29
|
+
otlp_endpoint="http://localhost:4318", # Optional
|
|
30
|
+
protocol="http", # "http" or "grpc", default "grpc"
|
|
31
|
+
trace_sample_rate=1.0, # Sampling rate, default 1.0
|
|
32
|
+
metric_export_interval_ms=30000, # Metrics export interval
|
|
33
|
+
log_level=logging.INFO, # Logging level
|
|
34
|
+
enable_console_logging=True, # Enable console logging
|
|
35
|
+
additional_resources={ # Optional additional resources
|
|
36
|
+
"deployment.region": "us-east-1",
|
|
37
|
+
"team.name": "backend"
|
|
38
|
+
}
|
|
35
39
|
)
|
|
36
40
|
|
|
37
41
|
OtelConfigurator(config)
|
|
38
42
|
```
|
|
39
43
|
|
|
40
|
-
|
|
44
|
+
### Tracing
|
|
41
45
|
```python
|
|
42
46
|
from otel_utils import Tracer
|
|
43
47
|
|
|
@@ -55,7 +59,7 @@ with tracer.create_span("my_operation") as span:
|
|
|
55
59
|
# Your code here
|
|
56
60
|
```
|
|
57
61
|
|
|
58
|
-
|
|
62
|
+
### Metrics
|
|
59
63
|
```python
|
|
60
64
|
from otel_utils import Metrics
|
|
61
65
|
|
|
@@ -71,7 +75,7 @@ with metrics.measure_duration("request_duration"):
|
|
|
71
75
|
pass
|
|
72
76
|
```
|
|
73
77
|
|
|
74
|
-
|
|
78
|
+
### Structured Logging
|
|
75
79
|
```python
|
|
76
80
|
from otel_utils import StructuredLogger
|
|
77
81
|
|
|
@@ -82,15 +86,15 @@ with logger.operation_context("process_order", order_id="123"):
|
|
|
82
86
|
# Your code here
|
|
83
87
|
```
|
|
84
88
|
|
|
85
|
-
|
|
89
|
+
## OpenTelemetry Collector Integration
|
|
90
|
+
|
|
86
91
|
This library is designed to work seamlessly with the OpenTelemetry Collector. Telemetry data is sent using the OTLP protocol, which is the OpenTelemetry standard.
|
|
92
|
+
|
|
93
|
+
### Collector Configuration with HTTP
|
|
87
94
|
```yaml
|
|
88
|
-
# collector configuration example
|
|
89
95
|
receivers:
|
|
90
96
|
otlp:
|
|
91
97
|
protocols:
|
|
92
|
-
grpc:
|
|
93
|
-
endpoint: 0.0.0.0:4317
|
|
94
98
|
http:
|
|
95
99
|
endpoint: 0.0.0.0:4318
|
|
96
100
|
|
|
@@ -104,20 +108,40 @@ service:
|
|
|
104
108
|
exporters: [your-exporter]
|
|
105
109
|
```
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
### Collector Configuration with gRPC
|
|
112
|
+
```yaml
|
|
113
|
+
receivers:
|
|
114
|
+
otlp:
|
|
115
|
+
protocols:
|
|
116
|
+
grpc:
|
|
117
|
+
endpoint: 0.0.0.0:4317
|
|
118
|
+
|
|
119
|
+
exporters:
|
|
120
|
+
# configure your exporters here
|
|
121
|
+
|
|
122
|
+
service:
|
|
123
|
+
pipelines:
|
|
124
|
+
traces:
|
|
125
|
+
receivers: [otlp]
|
|
126
|
+
exporters: [your-exporter]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Best Practices
|
|
130
|
+
|
|
131
|
+
### Separation of Concerns
|
|
109
132
|
Keep instrumentation separate from business logic by creating domain-specific abstractions. Your business code should remain clean and focused on its primary responsibilities.
|
|
110
133
|
|
|
111
|
-
|
|
134
|
+
### Consistent Naming
|
|
112
135
|
Use coherent naming conventions for spans, metrics, and logs across your services. This makes it easier to correlate and analyze telemetry data.
|
|
113
136
|
|
|
114
|
-
|
|
137
|
+
### Relevant Context
|
|
115
138
|
Include useful contextual information in spans and logs, but be mindful of sensitive data. Focus on information that aids debugging and monitoring.
|
|
116
139
|
|
|
117
|
-
|
|
140
|
+
### Appropriate Granularity
|
|
118
141
|
Don't instrument everything. Focus on significant operations that provide value for monitoring and debugging. Consider the overhead and noise ratio when adding instrumentation.
|
|
119
142
|
|
|
120
|
-
|
|
143
|
+
## Development
|
|
144
|
+
|
|
121
145
|
To set up the development environment:
|
|
122
146
|
|
|
123
147
|
```bash
|
|
@@ -132,11 +156,9 @@ pip install -e ".[dev]"
|
|
|
132
156
|
pytest
|
|
133
157
|
```
|
|
134
158
|
|
|
135
|
-
|
|
159
|
+
## Contributing
|
|
160
|
+
|
|
136
161
|
1. Create a feature branch (`git checkout -b feature/new-feature`)
|
|
137
162
|
2. Commit your changes (`git commit -am 'Add new feature'`)
|
|
138
163
|
3. Push to the branch (`git push origin feature/new-feature`)
|
|
139
|
-
4. Create a Pull Request
|
|
140
|
-
|
|
141
|
-
I hope this documentation helps you understand and effectively use the OpenTelemetry Utils library. Each section is designed to guide you through the essential aspects of instrumenting your applications while maintaining clean and maintainable code.
|
|
142
|
-
Let me know if you need any clarification or have questions about specific features or use cases. We can explore any aspect of the library in more detail.
|
|
164
|
+
4. Create a Pull Request
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|