Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastAPI liveness no response #97

Open
dpridan opened this issue Feb 13, 2024 · 1 comment
Open

FastAPI liveness no response #97

dpridan opened this issue Feb 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@dpridan
Copy link

dpridan commented Feb 13, 2024

Hey,
I want to monitor the liveness calls from my FastAPI app
but I get errors in the trace about No response although my service is up
with the error:
Some data could not be collected or transmitted. This is most likely due to a resource congestion on network, host or process level in your monitored environment (Diagnostic codes: C1, A5)

Thanks in advance for your help.

@dpridan dpridan added the bug Something isn't working label Feb 13, 2024
@wevertonmata
Copy link

wevertonmata commented Feb 27, 2024

I'm getting the same error

I try it:

  • api_main.py

I imported the first line

import autodynatrace

  • logger.py
import time
import logging
import sys
from autodynatrace.sdk import sdk as oneagent_sdk

class DynatraceAdapter(logging.LoggerAdapter):
    """Logging Adapter to add trace_id and span_id to log messages"""

    def process(self, msg, kwargs):
        """Enrich logs with dynatrace trace information"""
        ctx = oneagent_sdk.tracecontext_get_current()
        msg_out = f" {msg} [!dt dt.trace_id={ctx.trace_id},dt.span_id={ctx.span_id}] "
        return msg_out, kwargs


def get_logger(name, severity=logging.INFO):
    """Creates a custom logger"""
    formatter = logging.Formatter(
        "%(asctime)sZ - %(name)s - %(levelname)s - %(message)s"
    )
    formatter.converter = time.gmtime
    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(severity)
    handler.setFormatter(formatter)

    log = logging.getLogger(name)
    log.setLevel(severity)
    log.addHandler(handler)
    return DynatraceAdapter(log, {})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants