suriya kanth
01/30/2025, 4:35 AMCode:
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(<http://logging.INFO|logging.INFO>)
def my_function():
<http://logging.info|logging.info>("This is an info log from my_function")
suriya kanth
01/30/2025, 10:10 AMVikrant Gupta
01/30/2025, 10:16 AMnitya-signoz
01/30/2025, 10:17 AMnitya-signoz
01/30/2025, 10:18 AMsuriya kanth
01/30/2025, 10:23 AMSigNoz is an open-source APM. It helps developers monitor their applications & troubleshoot problems, an open-source alternative to DataDog, NewRelic, etc.
Powered by