-
Notifications
You must be signed in to change notification settings - Fork 633
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup Prometheus Remote Write Exporter
- Loading branch information
Showing
9 changed files
with
411 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
exporter/opentelemetry-exporter-prometheus-remote-write/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Changelog | ||
|
||
## Unreleased |
23 changes: 23 additions & 0 deletions
23
exporter/opentelemetry-exporter-prometheus-remote-write/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
OpenTelemetry Prometheus Remote Write Exporter | ||
============================================== | ||
|
||
This library allows exporting metric data to `Prometheus Write Integrated Backends | ||
<https://prometheus.io/docs/operating/integrations/>`_. Development is currently in progress. | ||
|
||
Installation | ||
------------ | ||
|
||
:: | ||
|
||
pip install opentelemetry-exporter-prometheus-remote-write | ||
|
||
|
||
.. _Prometheus: https://prometheus.io/ | ||
.. _OpenTelemetry: https://github.com/open-telemetry/opentelemetry-python/ | ||
|
||
|
||
References | ||
---------- | ||
|
||
* `Datadog <https://prometheus.io/>`_ | ||
* `OpenTelemetry Project <https://opentelemetry.io/>`_ |
50 changes: 50 additions & 0 deletions
50
exporter/opentelemetry-exporter-prometheus-remote-write/setup.cfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
[metadata] | ||
name = opentelemetry-exporter-prometheus-remote-write | ||
description = Prometheus Remote Write Metrics Exporter for OpenTelemetry | ||
long_description = file: README.rst | ||
long_description_content_type = text/x-rst | ||
author = OpenTelemetry Authors | ||
author_email = cncf-opentelemetry-contributors@lists.cncf.io | ||
url = https://github.com/open-telemetry/opentelemetry-python/exporter/opentelemetry-exporter-datadog | ||
platforms = any | ||
license = Apache-2.0 | ||
classifiers = | ||
Development Status :: 4 - Beta | ||
Intended Audience :: Developers | ||
License :: OSI Approved :: Apache Software License | ||
Programming Language :: Python | ||
Programming Language :: Python :: 3 | ||
Programming Language :: Python :: 3.5 | ||
Programming Language :: Python :: 3.6 | ||
Programming Language :: Python :: 3.7 | ||
Programming Language :: Python :: 3.8 | ||
|
||
[options] | ||
python_requires = >=3.5 | ||
package_dir= | ||
=src | ||
packages=find_namespace: | ||
install_requires = | ||
ddtrace>=0.34.0 | ||
opentelemetry-api == 0.16.dev0 | ||
opentelemetry-sdk == 0.16.dev0 | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
[options.extras_require] | ||
test = |
32 changes: 32 additions & 0 deletions
32
exporter/opentelemetry-exporter-prometheus-remote-write/setup.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
|
||
import setuptools | ||
|
||
BASE_DIR = os.path.dirname(__file__) | ||
VERSION_FILENAME = os.path.join( | ||
BASE_DIR, | ||
"src", | ||
"opentelemetry", | ||
"exporter", | ||
"prometheus_remote_write", | ||
"version.py", | ||
) | ||
PACKAGE_INFO = {} | ||
with open(VERSION_FILENAME) as f: | ||
exec(f.read(), PACKAGE_INFO) | ||
|
||
setuptools.setup(version=PACKAGE_INFO["__version__"]) |
132 changes: 132 additions & 0 deletions
132
...er-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
from typing import Dict, Sequence | ||
|
||
from opentelemetry.sdk.metrics.export import ( | ||
MetricRecord, | ||
MetricsExporter, | ||
MetricsExportResult, | ||
) | ||
|
||
|
||
class TimeSeries: | ||
""" | ||
TimeSeries class used to store timeseries labels and samples that need to be sent | ||
Args: | ||
labels: timeseries labels | ||
samples: timeseries samples | ||
""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
|
||
class Config: | ||
""" | ||
Configuration containing all necessary information to make remote write requests | ||
Args: | ||
endpoint: url where data will be sent | ||
basic_auth: username and password for authentication (Optional) | ||
bearer_token: token used for authentication (Optional) | ||
bearer_token_file: filepath to file containing authentication token (Optional) | ||
headers: additional headers for remote write request (Optional) | ||
""" | ||
|
||
def __init__( | ||
self, | ||
endpoint: str, | ||
basic_auth: Dict = None, | ||
bearer_token: str = None, | ||
bearer_token_file: str = None, | ||
headers: Dict = None, | ||
): | ||
pass | ||
|
||
def validate(self): | ||
pass | ||
|
||
|
||
class PrometheusRemoteWriteMetricsExporter(MetricsExporter): | ||
""" | ||
Prometheus remote write metric exporter for OpenTelemetry. | ||
Args: | ||
config: configuration containing all necessary information to make remote write requests | ||
""" | ||
|
||
def __init__(self, config: Config): | ||
pass | ||
|
||
def export( | ||
self, metric_records: Sequence[MetricRecord] | ||
) -> MetricsExportResult: | ||
pass | ||
|
||
def shutdown(self) -> None: | ||
pass | ||
|
||
def convert_to_timeseries( | ||
self, metric_records: Sequence[MetricRecord] | ||
) -> Sequence[TimeSeries]: | ||
pass | ||
|
||
def convert_from_sum(self, sum_record: MetricRecord) -> TimeSeries: | ||
pass | ||
|
||
def convert_from_min_max_sum_count( | ||
self, min_max_sum_count_record: MetricRecord | ||
) -> TimeSeries: | ||
pass | ||
|
||
def convert_from_histogram( | ||
self, histogram_record: MetricRecord | ||
) -> TimeSeries: | ||
pass | ||
|
||
def convert_from_last_value( | ||
self, last_value_record: MetricRecord | ||
) -> TimeSeries: | ||
pass | ||
|
||
def convert_from_value_observer( | ||
self, value_observer_record: MetricRecord | ||
) -> TimeSeries: | ||
pass | ||
|
||
def convert_from_summary(self, summary_record: MetricRecord) -> TimeSeries: | ||
pass | ||
|
||
def sanitize_label(self, label: str) -> str: | ||
pass | ||
|
||
def build_message(self, data: Sequence[TimeSeries]) -> str: | ||
pass | ||
|
||
def get_headers(self) -> Dict: | ||
pass | ||
|
||
def send_message(self, message: str, headers: Dict) -> int: | ||
pass | ||
|
||
|
||
def parse_config() -> Config: | ||
""" | ||
Method that parses yaml file to generate a valid remote write exporter config | ||
Args: | ||
path: filepath to yaml configuration file | ||
""" |
15 changes: 15 additions & 0 deletions
15
...ter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/version.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
__version__ = "0.16.dev0" |
13 changes: 13 additions & 0 deletions
13
exporter/opentelemetry-exporter-prometheus-remote-write/tests/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
74 changes: 74 additions & 0 deletions
74
exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import unittest | ||
|
||
|
||
# Series of test cases to ensure config validation works as intended | ||
class TestConfig(unittest.TestCase): | ||
def test_valid_standard_config(self): | ||
pass | ||
|
||
def test_valid_basic_auth_config(self): | ||
pass | ||
|
||
def test_valid_bearer_token_config(self): | ||
pass | ||
|
||
def test_valid_quantiles_config(self): | ||
pass | ||
|
||
def test_valid_histogram_boundaries_config(self): | ||
pass | ||
|
||
def test_valid_tls_config(self): | ||
pass | ||
|
||
def test_invalid_no_url_config(self): | ||
pass | ||
|
||
def test_invalid_no_name_config(self): | ||
pass | ||
|
||
def test_invalid_no_remote_timeout_config(self): | ||
pass | ||
|
||
def test_invalid_no_username_config(self): | ||
pass | ||
|
||
def test_invalid_no_password_config(self): | ||
pass | ||
|
||
def test_invalid_conflicting_passwords_config(self): | ||
pass | ||
|
||
def test_invalid_conflicting_bearer_tokens_config(self): | ||
pass | ||
|
||
def test_invalid_conflicting_auth_config(self): | ||
pass | ||
|
||
def test_invalid_quantiles_config(self): | ||
pass | ||
|
||
def test_invalid_histogram_boundaries_config(self): | ||
pass | ||
|
||
# Verifies that valid yaml file is parsed correctly | ||
def test_valid_yaml_file(self): | ||
pass | ||
|
||
# Ensures invalid filepath raises error when parsing | ||
def test_invalid_yaml_file(self): | ||
pass |
Oops, something went wrong.