Skip to content

Commit

Permalink
WCM-605: Remove metric labels we don't care about, this also prevents…
Browse files Browse the repository at this point in the history
… combinatoric issues with prometheus more static label allocations
  • Loading branch information
wosc committed Jan 28, 2025
1 parent 7595875 commit 64f4946
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog/WCM-605.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WCM-605: Remove metric labels we don't care about, this also prevents combinatoric issues with prometheus more static label allocations
11 changes: 11 additions & 0 deletions core/src/zeit/cms/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def testing_tracer():


def _setup_instrumentors(provider):
from opentelemetry.instrumentation._semconv import _client_duration_attrs_new
from opentelemetry.instrumentation.requests import RequestsInstrumentor

from zeit.cms.relstorage import RelStorageInstrumentor
Expand All @@ -161,6 +162,16 @@ def _setup_instrumentors(provider):
# the first instrumentor we call will evaluate it.
os.environ['OTEL_SEMCONV_STABILITY_OPT_IN'] = 'http'

# Remove things like server.port and error.type that we don't care about.
# Also, this prevents errors because some combinations (e.g. URLs
# with/without port) can run afoul of the more static label allocation
# mechanics in the prometheus world, which then raises (sigh).
_client_duration_attrs_new[:] = [
'http.request.method',
'http.response.status_code',
'server.address',
]

RequestsInstrumentor().instrument(tracer_provider=provider)
RelStorageInstrumentor().instrument(tracer_provider=provider)
TransactionInstrumentor().instrument(tracer_provider=provider)
Expand Down

0 comments on commit 64f4946

Please sign in to comment.