Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
335 stars 103 forks source link

[BUG] Custom dimensions not showing in App Insights #1327

Closed WiseCues closed 10 months ago

WiseCues commented 11 months ago

Trying to log custom dimensions from an http trigger functions.

import logging

logging.basicConfig(level=logging.DEBUG)

@app.route(route="test", methods=['GET']) def test(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:

properties = {'custom_dimensions': {
    'key_1': 'value_1', 'key_2': 'value_2'}

}

logging.info(
    'test',
    extra=properties
)

return func.HttpResponse(
    "All good",
    mimetype="application/json",
    status_code=200
)

Here are the custom dimensions shown in App Insight for this code:

customDimensions {"HostInstanceId":"e5121470-c5a1-4596-84fb-72879f1e9185","InvocationId":"25e10fbc-0683-480e-b32c-717815d3a9ab","LogLevel":"Information","ProcessId":"61","Category":"Function.test.User"}

Using

properties = {'key_1': 'value_1', 'key_2': 'value_2'}

doesn't work either.

Thanks

pdthummar commented 11 months ago

@wiseskus. Thanks for creating issue. To activate debug logging, set PYTHON_ENABLE_DEBUG_LOGGING=1, which triggers debug-level logging. If this setting is absent or set to 0, the Python worker will transmit only information and higher-level logs to the Functions host. Utilize this configuration for debugging or tracing your Python function executions. For additional information, please refer the documentation below.

Ref doc: python_enable_debug_logging, configure-log-levels

WiseCues commented 11 months ago

Hi, Where/how do I "activate debug logging, set PYTHON_ENABLE_DEBUG_LOGGING=1"? Thanks, JD


From: pdthummar @.> Sent: Friday, October 20, 2023 2:13 PM To: Azure/azure-functions-python-worker @.> Cc: jean david Ruvini @.>; Mention @.> Subject: Re: [Azure/azure-functions-python-worker] [BUG] Custom dimensions not showing in App Insights (Issue #1327)

@wiseskushttps://github.com/wiseskus. Thanks for creating issue. To activate debug logging, set PYTHON_ENABLE_DEBUG_LOGGING=1, which triggers debug-level logging. If this setting is absent or set to 0, the Python worker will transmit only information and higher-level logs to the Functions host. Utilize this configuration for debugging or tracing your Python function executions. For additional information, please refer the documentation below.

Ref doc: python_enable_debug_logginghttps://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#python_enable_debug_logging, configure-log-levelshttps://learn.microsoft.com/en-us/azure/azure-functions/configure-monitoring?tabs=v2#configure-log-levels

— Reply to this email directly, view it on GitHubhttps://github.com/Azure/azure-functions-python-worker/issues/1327#issuecomment-1773402563, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BCYLMVJ3PYMC2OHEKQPSEKTYALSQXAVCNFSM6AAAAAA6C4TV46VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZTGQYDENJWGM. You are receiving this because you were mentioned.Message ID: @.***>

pdthummar commented 11 months ago

@wiseskus This Doc will help you for setting up the App setting. Thanks

microsoft-github-policy-service[bot] commented 11 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

microsoft-github-policy-service[bot] commented 11 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.