Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    davidychow87
    @davidychow87
    Hi, I am using open census for logging, and I noticed that there are duplicate logs being writting to app insights, is there any way to fix this?
    davidychow87
    @davidychow87
    Actually, it looks like it was because I registered the same logging handler twice, which brings me to another question: for azure functions, since the functions are hosted on the same vm, will logger = logging.getLogger(name) work? i.e. since it is on the same vm, will I have to do something like: logger = logging.getLogger(f'{name}-{uuid()}') to ensure that each instance of the logger doesn't get registered multiple handlers?
    Leighton Chen
    @lzchen
    You can use logging.getLogger(name) to use the name of the python module that the logger is running from
    i dont think name has anything to do with the vm
    Brandon
    @thecompsciguy_twitter
    I am using the opencensus library for metrics and was wondering if there are any examples on how to create custom dimensions? I am trying to use the tagmap and my custom dimension is not showing in app insights. Is tagmap the correct way to add custom dimensions?
    Leighton Chen
    @lzchen
    yes the tagmap is how you add custom dimensions to your metrics telemetry
    think of the tagmap as a "pool" of key-values that can be selected from
    For each "view" that you create, you can specify the keys t hat you want for that specific metric
    The corresponding metric telemetry will search the tagmap for that key and find that value, and then that keyvalue pair would be one of the custom dimensions the metric telemetry will have
    Brandon
    @thecompsciguy_twitter

    So in the carrots example in the read me, if I wanted to add an customDimension called “environment”, I would do the following:

    tag_key = tag_key.TagKey("environment")
    tag_map = tag_map_module.TagMap().insert(tag_key, tag_value.TagValue(“staging”))

    Then on calling the .record() method for the measure

    mmap.record(tag_map)

    This is what I have done and the code works I just dont see the custom dimension in app insights. Am I going about this the right way?

    Leighton Chen
    @lzchen
    Almost! For the CARROTS_VIEW, you need to pass in the key that you want to use in the record
    CARROTS_VIEW = view_module.View("carrots_view",
    "number of carrots",
    ["environment"],
    CARROTS_MEASURE,
    aggregation_module.CountAggregation())
    Brandon
    @thecompsciguy_twitter
    Yep! That was it. Thanks so much!
    Leighton Chen
    @lzchen
    Nice! Glad it worked!
    lakhotiaharshit
    @lakhotiaharshit

    Hi I am trying to use opencensus-ext-azure in the following way:

    import logging
    import logging.handlers
    from opencensus.ext.azure.log_exporter import AzureLogHandler
    
    
    log = logging.getLogger(__name__)
    
    
    root_logger = logging.getLogger()
    
    telemetry_handler = AzureLogHandler(
        connection_string='InstrumentationKey=00000-000-000-000-00000')
    telemetry_handler.setLevel(logging.INFO)
    root_logger.addHandler(telemetry_handler)
    
    
    def close_everything():
        log.info('closing everything')
        try:
            some_error
        except:
            log.exception('some exception', exc_info=False)
            pass
    
    import atexit
    atexit.register(close_everything)
    atexit.register(logging.shutdown)

    The issue is that python session hangs at exit(). I think line which is creating problem is log.exception('some exception', exc_info=False). Can you please help. Thanks !

    Leighton Chen
    @lzchen
    @lakhotiaharshit is exit() being called at the end of the script? I don't see it being executed
    lakhotiaharshit
    @lakhotiaharshit
    @lzchen Yes exit() is called at the end of the script
    Leighton Chen
    @lzchen
    also may i ask why you are setting the loghandler on the root logger instead of the log = logging.getlogger(__name__)?
    It also seems like close_everything isn't being called correct?
    Oh on exit I see nevermind LD
    lakhotiaharshit
    @lakhotiaharshit
    this is kind of init script of the package. I want to log all the messages from each module of the package that is why I use the root logger
    Leighton Chen
    @lzchen
    try removing logging.shutdown and see if the problem still persists
    As well, the AzureLogHandler registers a flush operation upon exit of the main script, how long is the session hanging for?
    lakhotiaharshit
    @lakhotiaharshit

    how long is the session hanging for?

    It never exited for few minutes. I have tried to manually flush before exiting but that didn't help either.

    Leighton Chen
    @lzchen
    @lakhotiaharshit can you file an issue on the OC github with details of your problem? https://github.com/census-instrumentation/opencensus-python/issues
    lakhotiaharshit
    @lakhotiaharshit
    @lzchen I made the issue census-instrumentation/opencensus-python#881 . Also just to give you a bit more idea on our exact use case, here is the QCoDeS/Qcodes#1968 where we are migrating from applicationinsights to opencensus. Thanks a lot for your help in advance.
    lakhotiaharshit
    @lakhotiaharshit
    @lzchen Things got fixed. try removing logging.shutdown your suggestion worked. In the background this was happening:
    1 ) logging.shutdown is called (this was the last thing we registered and atexit follows opposite order, which I was not aware of. I was thinking first close_everthing happens and logging.shutdown)
    2) Then close_everything is called
    3) Then logging.shutdown is called again (since this is registered as soon as logging is imported)
    I am closing my issue.
    Leighton Chen
    @lzchen
    @lakhotiaharshit Im glad your issue is solved :)
    Todor Popo
    @totopopov
    Hey, so I have attached python logging to Gunicorn logger and to flask workers but Application map still show only the gunicorn. Has anyone managed to resolve such cases ?
    1 reply
    Anmol Gupta
    @Anmol007

    Hi, I'm trying to log extra information in "customDimensions" of Application Insights Logs. I followed the example given in https://github.com/census-instrumentation/opencensus-python/tree/master/contrib/opencensus-ext-azure#custom-properties
    but the custom_dimensions don't appear in "customDimensions" of Application Insights Logs. Am I missing something?

    logging.info( "Logging Information", extra={ 'custom_dimensions': { 'test': 1234 } } )

    14 replies