I'm using the OpenTelemetry LoggingInstrumentor to push logs to SigNoz. The traces are being captured and displayed correctly in SigNoz, but the logs are not appearing in SigNoz. I have enabled automatic logging instrumentation using LoggingInstrumentor().instrument(set_logging_format=True), but there seems to be an issue with log ingestion.
I've verified that my OpenTelemetry setup is correctly configured for tracing, and the OTLP gRPC exporter is successfully sending trace data. However, it appears that the logs are not being forwarded properly to SigNoz. I suspect there might be a missing configuration, an issue with the log exporter, or an incompatibility between LoggingInstrumentor and SigNoz's log processing pipeline.
Expectation:
I expected that enabling OpenTelemetry's LoggingInstrumentor with LoggingInstrumentor().instrument(set_logging_format=True) would automatically capture and send logs to SigNoz, similar to how traces are being successfully pushed. I anticipated seeing both traces and logs in the SigNoz dashboard, allowing for better observability and correlation between logs and traces.
What I Tried: Configured OpenTelemetry for Logging:
Used LoggingInstrumentor().instrument(set_logging_format=True) to enable automatic log instrumentation. Ensured that OpenTelemetry SDK and the OTLP gRPC exporter were correctly set up. Verified Trace Data:
Checked that traces were successfully being sent and displayed in SigNoz, confirming that the OTLP exporter is functioning. Checked Logging Output Locally:
Ensured that logs were being generated and written to local log files or console
Code:
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.instrumentation.logging import LoggingInstrumentor
import logging
# Configure the tracer to use OTLP exporter
resource = Resource(attributes={
"service.name": "your_service_name"
})
provider = TracerProvider(resource=resource)
trace.set_tracer_provider(provider)
otlp_exporter = OTLPSpanExporter(
endpoint="***********:4317",
insecure=True
)
span_processor = BatchSpanProcessor(otlp_exporter)
provider.add_span_processor(span_processor)
# Initialize automatic logging instrumentation
LoggingInstrumentor().instrument(set_logging_format=True)
# Example of logging
logging.getLogger().setLevel(logging.INFO)
def my_function():
logging.info("This is an info log from my_function")
I'm using the OpenTelemetry LoggingInstrumentor to push logs to SigNoz. The traces are being captured and displayed correctly in SigNoz, but the logs are not appearing in SigNoz. I have enabled automatic logging instrumentation using LoggingInstrumentor().instrument(set_logging_format=True), but there seems to be an issue with log ingestion.
I've verified that my OpenTelemetry setup is correctly configured for tracing, and the OTLP gRPC exporter is successfully sending trace data. However, it appears that the logs are not being forwarded properly to SigNoz. I suspect there might be a missing configuration, an issue with the log exporter, or an incompatibility between LoggingInstrumentor and SigNoz's log processing pipeline.
Expectation:
I expected that enabling OpenTelemetry's LoggingInstrumentor with LoggingInstrumentor().instrument(set_logging_format=True) would automatically capture and send logs to SigNoz, similar to how traces are being successfully pushed. I anticipated seeing both traces and logs in the SigNoz dashboard, allowing for better observability and correlation between logs and traces.
What I Tried: Configured OpenTelemetry for Logging:
Used LoggingInstrumentor().instrument(set_logging_format=True) to enable automatic log instrumentation. Ensured that OpenTelemetry SDK and the OTLP gRPC exporter were correctly set up. Verified Trace Data:
Checked that traces were successfully being sent and displayed in SigNoz, confirming that the OTLP exporter is functioning. Checked Logging Output Locally:
Ensured that logs were being generated and written to local log files or console
Code:
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
from opentelemetry.instrumentation.logging import LoggingInstrumentor
import logging
# Configure the tracer to use OTLP exporter
resource = Resource(attributes={
"service.name": "your_service_name"
})
provider = TracerProvider(resource=resource)
trace.set_tracer_provider(provider)
otlp_exporter = OTLPSpanExporter(
endpoint="***********:4317",
insecure=True
)
span_processor = BatchSpanProcessor(otlp_exporter)
provider.add_span_processor(span_processor)
# Initialize automatic logging instrumentation
LoggingInstrumentor().instrument(set_logging_format=True)
# Example of logging
logging.getLogger().setLevel(logging.INFO)
def my_function():
logging.info("This is an info log from my_function")
Share
Improve this question
asked Jan 29 at 12:07
suriya kanthsuriya kanth
132 bronze badges
1 Answer
Reset to default 0you will have to create a provider and hanlder and attach it to the logger
import logging
from opentelemetry import trace
from opentelemetry._logs import set_logger_provider
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import (
OTLPLogExporter,
)
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from opentelemetry.sdk.resources import Resource
import json
import os
exporter = OTLPLogExporter(endpoint=os.getenv("OTLP_ENDPOINT", "localhost:4317"), insecure=json.loads(os.getenv("INSECURE", "true").lower()))
logger_provider = LoggerProvider(
resource=Resource.create(
{
"service.name": "hello"
},
),
)
set_logger_provider(logger_provider)
logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter))
handler = LoggingHandler(level=logging.INFO, logger_provider=logger_provider)
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(logging.INFO)
logging.info("hello info")
logging.warning("Jackdaws love my big sphinx of quartz.")
Also insted on configuring these you can use autoinstrumentation as well, that will capture traces and logs, https://signoz.io/docs/userguide/python-logs-auto-instrumentation/