-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added OTEL and prometheus connectors
- Loading branch information
1 parent
2ffde28
commit 26879ce
Showing
10 changed files
with
376 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
max-line-length = 130 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
from temporalio.runtime import Runtime, TelemetryConfig, PrometheusConfig | ||
from opentelemetry.exporter.jaeger.thrift import JaegerExporter | ||
from opentelemetry.sdk.resources import SERVICE_NAME, Resource | ||
from opentelemetry.sdk.trace import TracerProvider | ||
from opentelemetry.sdk.trace.export import BatchSpanProcessor | ||
from opentelemetry import trace | ||
from .env import ( | ||
TELEMETRY_AGENT_HOST, | ||
TELEMETRY_AGENT_PORT, | ||
SERVICE_NAME as SN, | ||
PROMETHEUS_ENDPOINT_PORT, | ||
TELEMETRY_ENABLED, | ||
PROMETHEUS_ENDPOINT_ENABLED | ||
) | ||
|
||
|
||
def init_runtime_with_telemetry() -> Runtime: | ||
|
||
# Setup global tracer for workflow traces | ||
if TELEMETRY_ENABLED: | ||
provider = TracerProvider(resource=Resource.create({SERVICE_NAME: SN})) | ||
provider.add_span_processor( | ||
BatchSpanProcessor( | ||
JaegerExporter( | ||
agent_host_name=TELEMETRY_AGENT_HOST, | ||
agent_port=int(TELEMETRY_AGENT_PORT), | ||
) | ||
) | ||
) | ||
trace.set_tracer_provider(provider) | ||
|
||
# Metrics setup | ||
metrics_config: PrometheusConfig | None = None | ||
if PROMETHEUS_ENDPOINT_ENABLED: | ||
metrics_config = PrometheusConfig( | ||
bind_address=f"127.0.0.1:{PROMETHEUS_ENDPOINT_PORT}" | ||
) | ||
|
||
return Runtime(telemetry=TelemetryConfig( | ||
metrics=metrics_config | ||
) | ||
) | ||
|
||
|
||
runtime = init_runtime_with_telemetry() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
exporters: | ||
logging: | ||
loglevel: debug | ||
processors: | ||
batch: | ||
service: | ||
pipelines: | ||
metrics: | ||
receivers: [otlp] | ||
exporters: [logging] | ||
processors: [batch] |