DataDog / dd-trace-py

Datadog Python APM Client
https://ddtrace.readthedocs.io/
Other
519 stars 407 forks source link

All logs are being sending as error not info #9846

Open StephanyBatista opened 1 month ago

StephanyBatista commented 1 month ago

Which version of dd-trace-py are you using?

Version 2.9.2

Which version of pip are you using?

pip 23.0.1

Which libraries and their versions are you using?

Flask==1.1.1 Flask-Cors==3.0.8 Flask-RESTful==0.3.7 greenlet==0.4.15; platform_python_implementation == "CPython" gunicorn==19.9.0 werkzeug==0.15.6 gevent==1.4.0 ddtrace==2.9.2 ; python_version >= "3.8" and python_version < "4.0" requests==2.22.0 simplejson==3.13.2 psycopg2==2.8.6 jsonschema==2.6.0 simple-salesforce==0.74.3 sendgrid==5.3.0 cryptography==2.8 six==1.14.0 cffi==1.14.0 pycparser==2.20 monthdelta==0.9.1 python-pdf==0.37 pdfkit==0.6.1 wkhtmltopdf-pack-ng==0.12.3.0 itsdangerous==2.0.1 jinja2<3.1.0

How can we reproduce your problem?

I'm using a container as the below dockerfile

FROM python:3.8-buster

ARG VERSION

RUN mkdir -p /root/.opencensus/.azure/gunicorn

COPY --from=datadog/serverless-init:1 /datadog-init /usr/bin/datadog-init

ADD requirements.txt .
RUN pip install -r requirements.txt

ENTRYPOINT ["/usr/bin/datadog-init"]

RUN mkdir /code
WORKDIR /code
ADD src /code/
ADD . /code/

RUN echo ${VERSION}
ENV DD_VERSION=${VERSION}
ENV DD_SERVICE={MY_SERVICE}
ENV DD_ENV=production
ENV DD_VERSION=test-log-dd2
ENV DD_API_KEY={MY_KEY}
ENV DD_TRACE_ENABLED=true
ENV DD_LOG_LEVEL=debug
ENV DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL=true
ENV DD_LOGS_ENABLED=true

COPY init.sh /usr/local/bin/

RUN chmod u+x /usr/local/bin/init.sh

CMD ["/usr/local/bin/init.sh"] #here we use the instruction ddtrace-run gunicorn ...

And to test the app sending logs to DataDog I have the code below

import logging
import flask_restful as restful
from flask_restful import reqparse
from flask import jsonify

from helpers import authentication_required
from services import PgSQLSfService, complete_contract_info

FORMAT = ('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] '
          '[test] '
          '- %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)  

class GetAllContracts(restful.Resource):

    def get(self, **kwargs):
        print('test 343')
        log.info('Info test')
        log.debug('Debug test')

        return jsonify({"success": True})

What is the result that you get?

Inside DataDog I see all logs as error

image

What is the result that you expected?

See logs as info not error

emmettbutler commented 1 month ago

Thank you for the report, @StephanyBatista. We'll look into it.

StephanyBatista commented 1 month ago

Some news?