-
Notifications
You must be signed in to change notification settings - Fork 656
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
Logs: SchemaURL is missing in the Resource when using OTLP exporter #3553
Comments
tigrannajaryan
changed the title
Logs: SchemaURL is missing in the Resource when using OTLP gRPC exporter
Logs: SchemaURL is missing in the Resource when using OTLP exporter
Nov 22, 2023
@tigrannajaryan @lzchen Looks like it's missing not only in logs, but also in traces and maybe in metrics (didn't check it) 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.exporter.otlp.proto.grpc.trace_exporter import (
OTLPSpanExporter,
)
from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
from opentelemetry.sdk._logs.export import (
BatchLogRecordProcessor,
ConsoleLogExporter,
)
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
BatchSpanProcessor,
ConsoleSpanExporter,
)
resource = Resource.create(
{
"service.name": "shoppingcart",
"service.instance.id": "instance-12",
},
"http://opentelemetry.io/schemas/1.0.0",
)
trace.set_tracer_provider(
TracerProvider(
resource=resource
)
)
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(OTLPSpanExporter())
)
logger_provider = LoggerProvider(
resource=resource
)
set_logger_provider(logger_provider)
exporter = OTLPLogExporter(insecure=True)
# exporter = ConsoleLogExporter()
logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter))
handler = LoggingHandler(level=logging.NOTSET, logger_provider=logger_provider)
# Attach OTLP handler to root logger
logging.getLogger().addHandler(handler)
# Log directly
logging.info("Jackdaws love my big sphinx of quartz.")
# Create different namespaced loggers
logger1 = logging.getLogger("myapp.area1")
logger2 = logging.getLogger("myapp.area2")
logger1.debug("Quick zephyrs blow, vexing daft Jim.")
logger1.info("How quickly daft jumping zebras vex.")
logger2.warning("Jail zesty vixen who grabbed pay from quack.")
logger2.error("The five boxing wizards jump quickly.")
# Trace context correlation
tracer = trace.get_tracer(__name__)
with tracer.start_as_current_span("foo"):
# Do something
logger2.error("Hyderabad, we have a major problem.")
logger_provider.shutdown() Resource SchemaURL is missing in logs and in spans:
|
Yeah, it's missed in metrics too, gonna make a pr with fixes soon |
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe your environment
Mac OS X
Python 3.9.6
Steps to reproduce
What is the expected behavior?
Resource's SchemaURL should be present.
What is the actual behavior?
Resource's SchemaURL is missing:
Additional context
Part of review open-telemetry/community#1751
The text was updated successfully, but these errors were encountered: