OpenTelemetry Google Cloud Monitoring Exporter
==============================================
.. image:: https://badge.fury.io/py/opentelemetry-exporter-gcp-monitoring.svg
:target: https://badge.fury.io/py/opentelemetry-exporter-gcp-monitoring
.. image:: https://readthedocs.org/projects/google-cloud-opentelemetry/badge/?version=latest
:target: https://google-cloud-opentelemetry.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
This library provides support for exporting metrics to Google Cloud
Monitoring.
For resource detection and GCP trace context propagation, see
`opentelemetry-tools-google-cloud
<https://pypi.org/project/opentelemetry-tools-google-cloud/>`_. For the
Google Cloud Trace exporter, see `opentelemetry-exporter-gcp-trace
<https://pypi.org/project/opentelemetry-exporter-gcp-trace/>`_.
Installation
------------
.. code:: bash
pip install opentelemetry-exporter-gcp-monitoring
Usage
-----
.. code:: python
import time
from opentelemetry import metrics
from opentelemetry.exporter.cloud_monitoring import (
CloudMonitoringMetricsExporter,
)
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader
from opentelemetry.sdk.resources import Resource
metrics.set_meter_provider(
MeterProvider(
metric_readers=[
PeriodicExportingMetricReader(
CloudMonitoringMetricsExporter(), export_interval_millis=5000
)
],
resource=Resource.create(
{
"service.name": "basic_metrics",
"service.namespace": "examples",
"service.instance.id": "instance123",
}
),
)
)
meter = metrics.get_meter(__name__)
# Creates metric workload.googleapis.com/request_counter with monitored resource generic_task
requests_counter = meter.create_counter(
name="request_counter",
description="number of requests",
unit="1",
)
staging_labels = {"environment": "staging"}
for i in range(20):
requests_counter.add(25, staging_labels)
time.sleep(5)
References
----------
* `Cloud Monitoring <https://cloud.google.com/monitoring>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_
Raw data
{
"_id": null,
"home_page": "https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/tree/main/opentelemetry-exporter-gcp-monitoring",
"name": "opentelemetry-exporter-gcp-monitoring",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Google",
"author_email": "opentelemetry-pypi@google.com",
"download_url": "https://files.pythonhosted.org/packages/64/30/961c17b38cde8b0aa69fed9c4a3c69ce9d7bf341294b6fad0e751d37fd28/opentelemetry_exporter_gcp_monitoring-1.7.0a0.tar.gz",
"platform": "any",
"description": "OpenTelemetry Google Cloud Monitoring Exporter\n==============================================\n\n.. image:: https://badge.fury.io/py/opentelemetry-exporter-gcp-monitoring.svg\n :target: https://badge.fury.io/py/opentelemetry-exporter-gcp-monitoring\n\n.. image:: https://readthedocs.org/projects/google-cloud-opentelemetry/badge/?version=latest\n :target: https://google-cloud-opentelemetry.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\nThis library provides support for exporting metrics to Google Cloud\nMonitoring.\n\nFor resource detection and GCP trace context propagation, see\n`opentelemetry-tools-google-cloud\n<https://pypi.org/project/opentelemetry-tools-google-cloud/>`_. For the\nGoogle Cloud Trace exporter, see `opentelemetry-exporter-gcp-trace\n<https://pypi.org/project/opentelemetry-exporter-gcp-trace/>`_.\n\nInstallation\n------------\n\n.. code:: bash\n\n pip install opentelemetry-exporter-gcp-monitoring\n\nUsage\n-----\n\n.. code:: python\n\n import time\n\n from opentelemetry import metrics\n from opentelemetry.exporter.cloud_monitoring import (\n CloudMonitoringMetricsExporter,\n )\n from opentelemetry.sdk.metrics import MeterProvider\n from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader\n from opentelemetry.sdk.resources import Resource\n\n metrics.set_meter_provider(\n MeterProvider(\n metric_readers=[\n PeriodicExportingMetricReader(\n CloudMonitoringMetricsExporter(), export_interval_millis=5000\n )\n ],\n resource=Resource.create(\n {\n \"service.name\": \"basic_metrics\",\n \"service.namespace\": \"examples\",\n \"service.instance.id\": \"instance123\",\n }\n ),\n )\n )\n meter = metrics.get_meter(__name__)\n\n # Creates metric workload.googleapis.com/request_counter with monitored resource generic_task\n requests_counter = meter.create_counter(\n name=\"request_counter\",\n description=\"number of requests\",\n unit=\"1\",\n )\n\n staging_labels = {\"environment\": \"staging\"}\n\n for i in range(20):\n requests_counter.add(25, staging_labels)\n time.sleep(5)\n\n\nReferences\n----------\n\n* `Cloud Monitoring <https://cloud.google.com/monitoring>`_\n* `OpenTelemetry Project <https://opentelemetry.io/>`_\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Google Cloud Monitoring exporter for OpenTelemetry",
"version": "1.7.0a0",
"project_urls": {
"Homepage": "https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/tree/main/opentelemetry-exporter-gcp-monitoring"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4ee6a5ac64fbd402decb3e35f4547e41d11fe0965b6f651dff38c0edf8226b1f",
"md5": "026af884dacd48ebd3ebdbd80373d8fb",
"sha256": "494848ecd0e476d20d81b504a79c2df03c3c6f97b2bd42bd739f942976f08bf2"
},
"downloads": -1,
"filename": "opentelemetry_exporter_gcp_monitoring-1.7.0a0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "026af884dacd48ebd3ebdbd80373d8fb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12953,
"upload_time": "2024-08-27T19:25:47",
"upload_time_iso_8601": "2024-08-27T19:25:47.448676Z",
"url": "https://files.pythonhosted.org/packages/4e/e6/a5ac64fbd402decb3e35f4547e41d11fe0965b6f651dff38c0edf8226b1f/opentelemetry_exporter_gcp_monitoring-1.7.0a0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6430961c17b38cde8b0aa69fed9c4a3c69ce9d7bf341294b6fad0e751d37fd28",
"md5": "118fa640fa9310a9db49b3c7a1623848",
"sha256": "e3a3bab8e78f953070a583468d9c1855b61f9d0c5f39b4f34b9b8fd671863c55"
},
"downloads": -1,
"filename": "opentelemetry_exporter_gcp_monitoring-1.7.0a0.tar.gz",
"has_sig": false,
"md5_digest": "118fa640fa9310a9db49b3c7a1623848",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 19719,
"upload_time": "2024-08-27T19:25:52",
"upload_time_iso_8601": "2024-08-27T19:25:52.727751Z",
"url": "https://files.pythonhosted.org/packages/64/30/961c17b38cde8b0aa69fed9c4a3c69ce9d7bf341294b6fad0e751d37fd28/opentelemetry_exporter_gcp_monitoring-1.7.0a0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-27 19:25:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "GoogleCloudPlatform",
"github_project": "opentelemetry-operations-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "opentelemetry-exporter-gcp-monitoring"
}