Skip to content
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

Update log symbol names #2943

Merged
merged 5 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.13.0...HEAD)

- Update log symbol names
([#2943](https://github.com/open-telemetry/opentelemetry-python/pull/2943))
- Update explicit histogram bucket boundaries
([#2947](https://github.com/open-telemetry/opentelemetry-python/pull/2947))
- `exporter-otlp-proto-http`: add user agent string
Expand All @@ -17,7 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.13.0-0.34b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.13.0) - 2022-09-26



- Add a configurable max_export_batch_size to the gRPC metrics exporter
([#2809](https://github.com/open-telemetry/opentelemetry-python/pull/2809))
- Remove support for 3.6
Expand Down
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
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