question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adding account info into labels

See original GitHub issue

setup:

  1. using make_app() factory pattern

question:

  1. I want to add a label containing account_id :
def make_app():
   metrics._static_labels = {"account_id": current_user.id}
   metrics.init_app(app)
   return app

but obviously, I get current_user :None because metrics.init_app(app) and make_app() is called before the app get account info .

any idea on how to set label containing account_id in make_app() ?

I have tried using lambda: request.account.id but it doesn’t give me the result, rather it gave a function object

  1. I have tried using lambda: request.account.id -> returns <function make_app.<locals>.<lambda> at 0x7f28b6d4b730>
  2. tried PrometheusMetrics(app, group_by=custom_rule) -> but this is about we add another default metrics, not a label.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bilalbayasutcommented, Jul 11, 2020

thank you, you rock! @rycus86

1reaction
rycus86commented, Jul 10, 2020

Managed to make this work now, the account_id: lamdba: request.account.id form should work. Also renamed static_labels to default_labels (though the former will still work).

Hopefully this helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Print labels for your mailing list - Microsoft Support
In the Mail Merge menu, select Labels. · Choose Select recipients > Browse to upload the mailing list. · Select Arrange your labels...
Read more >
Create labels to organize Gmail - Computer - Google Support
Label a message you're writing. On your computer, go to Gmail. Click Compose. ... Click Label, then select labels you want to add....
Read more >
How to Make Address Address Labels with Mail Merge using ...
Use Mail Merge to Create Mailing Labels in Word from an Excel Data Set · How to print mailing labels from Excel ·...
Read more >
Mail Merge Address Labels (FREE) with Google Docs, Sheets ...
Generate mailing lables from a spreadsheet of addresses for free using Google Docs, Google Sheets, and Autocrat (free add on ).
Read more >
Print mailing labels, envelopes, and contact lists in Contacts ...
Click Layout or Label to customize mailing labels. Layout: Choose a page type, such as Avery Standard or A4. Or choose Define Custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found