Skip to content

[WIP] Add Falcon enrich_metric_attributes if Labeler contains custom attributes#4309

Draft
tammy-baylis-swi wants to merge 16 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:falcon-enrich-metric-attributes
Draft

[WIP] Add Falcon enrich_metric_attributes if Labeler contains custom attributes#4309
tammy-baylis-swi wants to merge 16 commits intoopen-telemetry:mainfrom
tammy-baylis-swi:falcon-enrich-metric-attributes

Conversation

@tammy-baylis-swi
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi commented Mar 5, 2026

Description

Updates Falcon instrumentor to use Labeler enrich_metric_attributes before adding/recording each metric, old and new semconv: HTTP server duration, active requests counter. Has no effect if Labeler is not called by instrumented code or custom distro.

Depends on

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • tox -e py312-test-instrumentation-falcon-0
  • Install FalconInstrumentor and manually instrument Django app with http/dup opt-in; use Labeler to add attrs such as user_id

Example app-side call to add attributes with Labeler:

class UsersResource:
	def on_get(self, req, resp, user_id):
		labeler = get_labeler()
		labeler.add("user_id", user_id)
		labeler.add("user_type", "registered")
		labeler.add_attributes(
			{"feature_flag": "new_ui", "experiment_group": "control"}
		)
		resp.text = f"User profile for {escape(user_id)}"

app.add_route("/users/{user_id}/", UsersResource())

Example otelcol debug HTTP server duration metrics from instrumentation:

InstrumentationScope opentelemetry.instrumentation.falcon 0.62b0.dev

Metric #2
Descriptor:
     -> Name: http.server.request.duration
     -> Description: Duration of HTTP server requests.
     -> Unit: s
     -> DataType: Histogram
     -> AggregationTemporality: Cumulative
HistogramDataPoints #0
Data point attributes:
     -> http.request.method: Str(GET)
     -> url.scheme: Str(http)
     -> network.protocol.version: Str(1.1)
     -> http.response.status_code: Int(200)
     -> http.route: Str(/users/{user_id}/)
     -> user_id: Str(123)
     -> user_type: Str(registered)
     -> feature_flag: Str(new_ui)
     -> experiment_group: Str(control)

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant