|
| 1 | +# Copyright The OpenTelemetry Authors |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | + |
| 16 | +from typing import Dict, Sequence |
| 17 | + |
| 18 | +from opentelemetry.sdk.metrics.export import ( |
| 19 | + MetricRecord, |
| 20 | + MetricsExporter, |
| 21 | + MetricsExportResult, |
| 22 | +) |
| 23 | + |
| 24 | + |
| 25 | +class TimeSeries: |
| 26 | + """ |
| 27 | + TimeSeries class used to store timeseries labels and samples that need to be sent |
| 28 | + Args: |
| 29 | + labels: timeseries labels |
| 30 | + samples: timeseries samples |
| 31 | + """ |
| 32 | + |
| 33 | + def __init__(self): |
| 34 | + pass |
| 35 | + |
| 36 | + |
| 37 | +class Config: |
| 38 | + """ |
| 39 | + Configuration containing all necessary information to make remote write requests |
| 40 | +
|
| 41 | + Args: |
| 42 | + endpoint: url where data will be sent |
| 43 | + basic_auth: username and password for authentication (Optional) |
| 44 | + bearer_token: token used for authentication (Optional) |
| 45 | + bearer_token_file: filepath to file containing authentication token (Optional) |
| 46 | + headers: additional headers for remote write request (Optional) |
| 47 | + """ |
| 48 | + |
| 49 | + def __init__( |
| 50 | + self, |
| 51 | + endpoint: str, |
| 52 | + basic_auth: Dict = None, |
| 53 | + bearer_token: str = None, |
| 54 | + bearer_token_file: str = None, |
| 55 | + headers: Dict = None, |
| 56 | + ): |
| 57 | + pass |
| 58 | + |
| 59 | + def validate(self): |
| 60 | + pass |
| 61 | + |
| 62 | + |
| 63 | +class PrometheusRemoteWriteMetricsExporter(MetricsExporter): |
| 64 | + """ |
| 65 | + Prometheus remote write metric exporter for OpenTelemetry. |
| 66 | +
|
| 67 | + Args: |
| 68 | + config: configuration containing all necessary information to make remote write requests |
| 69 | + """ |
| 70 | + |
| 71 | + def __init__(self, config: Config): |
| 72 | + pass |
| 73 | + |
| 74 | + def export( |
| 75 | + self, metric_records: Sequence[MetricRecord] |
| 76 | + ) -> MetricsExportResult: |
| 77 | + pass |
| 78 | + |
| 79 | + def shutdown(self) -> None: |
| 80 | + pass |
| 81 | + |
| 82 | + def convert_to_timeseries( |
| 83 | + self, metric_records: Sequence[MetricRecord] |
| 84 | + ) -> Sequence[TimeSeries]: |
| 85 | + pass |
| 86 | + |
| 87 | + def convert_from_sum(self, sum_record: MetricRecord) -> TimeSeries: |
| 88 | + pass |
| 89 | + |
| 90 | + def convert_from_min_max_sum_count( |
| 91 | + self, min_max_sum_count_record: MetricRecord |
| 92 | + ) -> TimeSeries: |
| 93 | + pass |
| 94 | + |
| 95 | + def convert_from_histogram( |
| 96 | + self, histogram_record: MetricRecord |
| 97 | + ) -> TimeSeries: |
| 98 | + pass |
| 99 | + |
| 100 | + def convert_from_last_value( |
| 101 | + self, last_value_record: MetricRecord |
| 102 | + ) -> TimeSeries: |
| 103 | + pass |
| 104 | + |
| 105 | + def convert_from_value_observer( |
| 106 | + self, value_observer_record: MetricRecord |
| 107 | + ) -> TimeSeries: |
| 108 | + pass |
| 109 | + |
| 110 | + def convert_from_summary(self, summary_record: MetricRecord) -> TimeSeries: |
| 111 | + pass |
| 112 | + |
| 113 | + def sanitize_label(self, label: str) -> str: |
| 114 | + pass |
| 115 | + |
| 116 | + def build_message(self, data: Sequence[TimeSeries]) -> str: |
| 117 | + pass |
| 118 | + |
| 119 | + def get_headers(self) -> Dict: |
| 120 | + pass |
| 121 | + |
| 122 | + def send_message(self, message: str, headers: Dict) -> int: |
| 123 | + pass |
| 124 | + |
| 125 | + |
| 126 | +def parse_config() -> Config: |
| 127 | + """ |
| 128 | + Method that parses yaml file to generate a valid remote write exporter config |
| 129 | +
|
| 130 | + Args: |
| 131 | + path: filepath to yaml configuration file |
| 132 | + """ |
0 commit comments