[Python] azure.monitor.opentelemetry - not logging anything

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    I have a simple python script and are following this sample: https://github.com/Azure/azure-sdk-...r-opentelemetry/samples/metrics/attributes.py

    Code:

    import logging
    from azure.monitor.opentelemetry import configure_azure_monitor
    from azure.identity import DefaultAzureCredential
    from opentelemetry import metrics

    large_attribute_set = {}
    for i in range(20):
    key = "key{}".format(i)
    val = "val{}".format(i)
    large_attribute_set[key] = val

    credential = DefaultAzureCredential()

    configure_azure_monitor(
    logger_name=__name__,
    credential=credential,
    connection_string="InstrumentationKey=xx-xx-xx-xx-xx;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=x-x-x-x-x",
    )

    logger = logging.getLogger(__name__)

    meter = metrics.get_meter_provider().get_meter("sample")
    counter = meter.create_counter("my_counter")
    counter.add(1)

    logger.info("info1", extra=large_attribute_set)
    logger.warning("warning1", extra=large_attribute_set)
    logger.error("error1", extra=large_attribute_set)
    logger.critical("critical1", extra=large_attribute_set)


    In visual studio code I have run: azd auth login

    I do not get any errors. However no logs either: [​IMG]

    I have following access to application insigths: [​IMG]

    Continue reading...

Compartilhe esta Página