Skip to content

Commit

Permalink
Update log symbol names
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Sep 26, 2022
1 parent 42db164 commit 471cbc5
Show file tree
Hide file tree
Showing 11 changed files with 289 additions and 294 deletions.
18 changes: 8 additions & 10 deletions docs/examples/logs/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
OTLPLogExporter,
)
from opentelemetry.sdk._logs import (
LogEmitterProvider,
LoggerProvider,
LoggingHandler,
set_log_emitter_provider,
set_logger_provider,
)
from opentelemetry.sdk._logs.export import BatchLogProcessor
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
Expand All @@ -22,21 +22,19 @@
BatchSpanProcessor(ConsoleSpanExporter())
)

log_emitter_provider = LogEmitterProvider(
logger_provider = LoggerProvider(
resource=Resource.create(
{
"service.name": "shoppingcart",
"service.instance.id": "instance-12",
}
),
)
set_log_emitter_provider(log_emitter_provider)
set_logger_provider(logger_provider)

exporter = OTLPLogExporter(insecure=True)
log_emitter_provider.add_log_processor(BatchLogProcessor(exporter))
handler = LoggingHandler(
level=logging.NOTSET, log_emitter_provider=log_emitter_provider
)
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)
Expand All @@ -60,4 +58,4 @@
# Do something
logger2.error("Hyderabad, we have a major problem.")

log_emitter_provider.shutdown()
logger_provider.shutdown()
4 changes: 2 additions & 2 deletions opentelemetry-sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ sdk = "opentelemetry.sdk.environment_variables"
[project.entry-points.opentelemetry_id_generator]
random = "opentelemetry.sdk.trace.id_generator:RandomIdGenerator"

[project.entry-points.opentelemetry_log_emitter_provider]
sdk_log_emitter_provider = "opentelemetry.sdk._logs:LogEmitterProvider"
[project.entry-points.opentelemetry_logger_provider]
sdk_logger_provider = "opentelemetry.sdk._logs:LoggerProvider"

[project.entry-points.opentelemetry_logs_exporter]
console = "opentelemetry.sdk._logs.export:ConsoleLogExporter"
Expand Down
18 changes: 8 additions & 10 deletions opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
)
from opentelemetry.metrics import set_meter_provider
from opentelemetry.sdk._logs import (
LogEmitterProvider,
LoggerProvider,
LoggingHandler,
set_log_emitter_provider,
set_logger_provider,
)
from opentelemetry.sdk._logs.export import BatchLogProcessor, LogExporter
from opentelemetry.sdk._logs.export import BatchLogRecordProcessor, LogExporter
from opentelemetry.sdk.environment_variables import (
_OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED,
OTEL_EXPORTER_OTLP_LOGS_PROTOCOL,
Expand Down Expand Up @@ -212,18 +212,16 @@ def _init_logging(
auto_resource[
ResourceAttributes.TELEMETRY_AUTO_VERSION
] = auto_instrumentation_version
provider = LogEmitterProvider(resource=Resource.create(auto_resource))
set_log_emitter_provider(provider)
provider = LoggerProvider(resource=Resource.create(auto_resource))
set_logger_provider(provider)

for _, exporter_class in exporters.items():
exporter_args = {}
provider.add_log_processor(
BatchLogProcessor(exporter_class(**exporter_args))
provider.add_log_record_processor(
BatchLogRecordProcessor(exporter_class(**exporter_args))
)

handler = LoggingHandler(
level=logging.NOTSET, log_emitter_provider=provider
)
handler = LoggingHandler(level=logging.NOTSET, logger_provider=provider)

logging.getLogger().addHandler(handler)

Expand Down
Loading

0 comments on commit 471cbc5

Please sign in to comment.