Skip to content

Commit

Permalink
Merge pull request #56 from community-of-python/allow-custom-service-…
Browse files Browse the repository at this point in the history
…name-otl

allow service name redefine for OTL
  • Loading branch information
lesnik512 authored Dec 11, 2024
2 parents 9f35371 + a396e42 commit 20c1d5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ class YourSettings(BaseServiceSettings):
service_name: str
service_version: str

opentelemetry_service_name: str | None = None
opentelemetry_container_name: str | None = None
opentelemetry_endpoint: str | None = None
opentelemetry_namespace: str | None = None
Expand All @@ -315,6 +316,7 @@ Parameters description:

- `service_name` - will be passed to the `Resource`.
- `service_version` - will be passed to the `Resource`.
- `opentelemetry_service_name` - if provided, will be passed to the `Resource` instead of `service_name`.
- `opentelemetry_endpoint` - will be passed to `OTLPSpanExporter` as endpoint.
- `opentelemetry_namespace` - will be passed to the `Resource`.
- `opentelemetry_insecure` - is opentelemetry connection secure.
Expand Down
4 changes: 3 additions & 1 deletion microbootstrap/instruments/opentelemetry_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class OpentelemetryConfig(BaseInstrumentConfig):
service_name: str = "micro-service"
service_version: str = "1.0.0"

opentelemetry_service_name: str | None = None
opentelemetry_container_name: str | None = None
opentelemetry_endpoint: str | None = None
opentelemetry_namespace: str | None = None
Expand Down Expand Up @@ -52,7 +53,8 @@ def teardown(self) -> None:
def bootstrap(self) -> None:
resource: typing.Final = resources.Resource.create(
attributes={
resources.SERVICE_NAME: self.instrument_config.service_name,
resources.SERVICE_NAME: self.instrument_config.opentelemetry_service_name
or self.instrument_config.service_name,
resources.TELEMETRY_SDK_LANGUAGE: "python",
resources.SERVICE_NAMESPACE: self.instrument_config.opentelemetry_namespace, # type: ignore[dict-item]
resources.SERVICE_VERSION: self.instrument_config.service_version,
Expand Down

0 comments on commit 20c1d5a

Please sign in to comment.