Skip to content

Commit

Permalink
Update prometheus exporter package (fixes issues with build info gaug…
Browse files Browse the repository at this point in the history
…e when using OTEL) (#92)

* Update opentelemetry packages

* Update opentelemetry-exporter-prometheus to fix issues with build_info gauge when using otel tracker

* Revert lockfile

* Update opentelemetry-exporter-prometheus

* Remove the prometheus exporter "prefix" config option
  • Loading branch information
brettimus authored Nov 2, 2023
1 parent 5579b02 commit 0535e75
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 86 deletions.
97 changes: 17 additions & 80 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ classifiers = [
packages = [{ include = "autometrics", from = "src" }]

[tool.poetry.dependencies]
opentelemetry-exporter-prometheus = "^1.12.0rc1"
# The prometheus exporter is pinned to a beta version because of how opentelemetry-python has been releasing it.
# Technically, the version 1.12.0rc1 is the "latest" on pypi, but it's not the latest release.
# 0.41b0 includes the fix for exporting gauge values (previously they were always turned into counters).
opentelemetry-exporter-prometheus = "0.41b0"
opentelemetry-exporter-otlp-proto-http = { version = "^1.20.0", optional = true }
opentelemetry-exporter-otlp-proto-grpc = { version = "^1.20.0", optional = true }
opentelemetry-sdk = "^1.17.0"
Expand Down
5 changes: 1 addition & 4 deletions src/autometrics/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class PrometheusExporterOptions(PrometheusExporterBase, total=False):

address: str
port: int
prefix: str


PrometheusValidator = TypeAdapter(PrometheusExporterOptions)
Expand Down Expand Up @@ -108,9 +107,7 @@ def create_exporter(config: ExporterOptions) -> Optional[MetricReader]:
config.get("port", 9464),
config.get("address", "0.0.0.0"),
)
return PrometheusMetricReader(
config.get("prefix", ""),
)
return PrometheusMetricReader()
if config["type"] == "otlp-proto-http":
config = OtlpHttpExporterValidator.validate_python(config)
try:
Expand Down
2 changes: 1 addition & 1 deletion src/autometrics/tracker/opentelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, reader: Optional[MetricReader] = None):
),
)
resource = Resource.create(get_resource_attrs())
readers = [reader or PrometheusMetricReader("")]
readers = [reader or PrometheusMetricReader()]
meter_provider = MeterProvider(
views=[view],
resource=resource,
Expand Down

0 comments on commit 0535e75

Please sign in to comment.