|
43 | 43 | ) |
44 | 44 | from opentelemetry.sdk.metrics.export import ( |
45 | 45 | AggregationTemporality, |
46 | | - ExponentialHistogram as ExponentialHistogramType, |
47 | 46 | Gauge, |
48 | | - Histogram as HistogramType, |
49 | 47 | MetricExporter, |
50 | 48 | MetricsData, |
51 | 49 | Sum, |
@@ -174,17 +172,17 @@ def truncate_trailing_zeros(lst: Sequence[int]) -> Sequence[int]: |
174 | 172 | if lst: |
175 | 173 | for i, value in enumerate(reversed(lst)): |
176 | 174 | if value != 0: |
177 | | - return lst[0:len(lst)-i] |
| 175 | + return lst[0 : len(lst) - i] |
178 | 176 | return [] |
179 | 177 |
|
180 | 178 |
|
181 | 179 | def create_exponential_histogram_buckets(offset, bucket_counts): |
182 | 180 | buckets = None |
183 | 181 | if truncated_bucket_counts := truncate_trailing_zeros(bucket_counts): |
184 | 182 | buckets = pb2.ExponentialHistogramDataPoint.Buckets( |
185 | | - offset=offset, |
186 | | - bucket_counts=truncated_bucket_counts, |
187 | | - ) |
| 183 | + offset=offset, |
| 184 | + bucket_counts=truncated_bucket_counts, |
| 185 | + ) |
188 | 186 | return buckets |
189 | 187 |
|
190 | 188 |
|
@@ -227,17 +225,12 @@ def encode_metrics(data: MetricsData) -> ExportMetricsServiceRequest: |
227 | 225 |
|
228 | 226 |
|
229 | 227 | def _encode_resource_metrics(resource_metrics, resource_metrics_dict): |
230 | | - |
231 | 228 | resource = resource_metrics.resource |
232 | | - |
233 | 229 | # It is safe to assume that each entry in data.resource_metrics is |
234 | 230 | # associated with an unique resource. |
235 | 231 | scope_metrics_dict = {} |
236 | | - |
237 | 232 | resource_metrics_dict[resource] = scope_metrics_dict |
238 | | - |
239 | 233 | for scope_metrics in resource_metrics.scope_metrics: |
240 | | - |
241 | 234 | instrumentation_scope = scope_metrics.scope |
242 | 235 |
|
243 | 236 | # The SDK groups metrics in instrumentation scopes already so |
@@ -324,9 +317,12 @@ def _encode_metric(metric, pb2_metric): |
324 | 317 |
|
325 | 318 | elif isinstance(metric.data, ExponentialHistogramType): |
326 | 319 | for data_point in metric.data.data_points: |
327 | | - |
328 | | - positive = create_exponential_histogram_buckets(data_point.positive.offset, data_point.positive.bucket_counts) |
329 | | - negative = create_exponential_histogram_buckets(data_point.negative.offset, data_point.negative.bucket_counts) |
| 320 | + positive = create_exponential_histogram_buckets( |
| 321 | + data_point.positive.offset, data_point.positive.bucket_counts |
| 322 | + ) |
| 323 | + negative = create_exponential_histogram_buckets( |
| 324 | + data_point.negative.offset, data_point.negative.bucket_counts |
| 325 | + ) |
330 | 326 |
|
331 | 327 | pt = pb2.ExponentialHistogramDataPoint( |
332 | 328 | attributes=_encode_attributes(data_point.attributes), |
|
0 commit comments