Skip to content

Commit a0f1b44

Browse files
authored
Add autoinstrumentation entrypoint for monitoring exporter (#275)
1 parent b0ca7de commit a0f1b44

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

opentelemetry-exporter-gcp-monitoring/setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,9 @@ where = src
3636

3737
[options.extras_require]
3838
test =
39+
40+
[options.entry_points]
41+
opentelemetry_metrics_exporter =
42+
gcp_monitoring = opentelemetry.exporter.cloud_monitoring:CloudMonitoringMetricsExporter
43+
opentelemetry_environment_variables =
44+
gcp_monitoring = opentelemetry.exporter.cloud_monitoring.environment_variables
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2023 Google LLC
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+
# https://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+
OTEL_EXPORTER_GCP_MONITORING_PROJECT_ID = (
16+
"OTEL_EXPORTER_GCP_MONITORING_PROJECT_ID"
17+
)
18+
"""
19+
.. envvar:: OTEL_EXPORTER_GCP_MONITORING_PROJECT_ID
20+
21+
GCP project ID for the exporter to send metrics to. Equivalent to constructor parameter to
22+
:class:`opentelemetry.exporter.cloud_monitoring.CloudMonitoringMetricsExporter`.
23+
"""
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2023 Google LLC
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+
# https://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+
from unittest import TestCase
16+
17+
from opentelemetry.exporter.cloud_monitoring import (
18+
CloudMonitoringMetricsExporter,
19+
)
20+
21+
# private import for testing only
22+
from opentelemetry.sdk._configuration import _import_exporters
23+
24+
25+
class TestCloudTraceAutoInstrument(TestCase):
26+
def test_loads_cloud_trace_exporter(self):
27+
"""Test that OTel configuration internals can load the exporter from entrypoint by
28+
name"""
29+
_, metric_exporters, _ = _import_exporters(
30+
trace_exporter_names=[],
31+
log_exporter_names=[],
32+
metric_exporter_names=["gcp_monitoring"],
33+
)
34+
self.assertEqual(
35+
metric_exporters,
36+
{"gcp_monitoring": CloudMonitoringMetricsExporter},
37+
)

0 commit comments

Comments
 (0)