Skip to content
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
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG NODENORM_BRANCH=main
WORKDIR /build/nodenorm
RUN git clone -b ${NODENORM_BRANCH} --recursive ${NODENORM_REPO} .
RUN git rev-parse HEAD > /build/nodenorm/version.txt
RUN pip wheel --wheel-dir=/build/wheels /build/nodenorm
RUN pip wheel --wheel-dir=/build/wheels /build/nodenorm[telemetry]

FROM caddy:2.8-builder AS caddy_builder
RUN xcaddy build
Expand Down
6 changes: 3 additions & 3 deletions docker/configuration/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
}
},
"telemetry": {
"OPENTELEMETRY_ENABLED": false,
"OPENTELEMETRY_ENABLED": true,
"OPENTELEMETRY_SERVICE_NAME": "NodeNorm",
"OPENTELEMETRY_JAEGER_HOST": "http://localhost",
"OPENTELEMETRY_JAEGER_PORT": 6831
"OPENTELEMETRY_JAEGER_HOST": "http://jaeger-otel-collector.sri",
"OPENTELEMETRY_JAEGER_PORT": 4318
}
}
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,12 @@ tests = [
]

telemetry = [
"opentelemetry-api>=1.21.0",
"opentelemetry-sdk>=1.21.0",
"opentelemetry-exporter-otlp>=1.21.0",
"opentelemetry.exporter.jaeger.thrift>=1.21.0",
"opentelemetry-instrumentation>=0.42b0",
"opentelemetry-instrumentation-tornado>=0.42b0",
"deprecated>=1.2.0"
"opentelemetry-api>=1.42.1",
"opentelemetry-sdk>=1.42.1",
"opentelemetry-exporter-otlp-proto-http>=1.42.1",
"opentelemetry-instrumentation>=0.63b1",
"opentelemetry-instrumentation-tornado>=0.63b1",
"deprecated>=1.3.1"
]


Expand Down
6 changes: 3 additions & 3 deletions src/nodenorm/config/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"elasticsearch": {
"ES_HOST": "http://localhost:9200",
"ES_INDEX": "nodenorm",
"ES_ALIAS": "nodenorm",
"ES_INDEX": "annotator-nodenorm",
"ES_ALIAS": "annotator-nodenorm",
"ES_DOC_TYPE": "node",
"ES_INDICES": {},
"ES_ARGS": {
Expand All @@ -27,6 +27,6 @@
"OPENTELEMETRY_ENABLED": false,
"OPENTELEMETRY_SERVICE_NAME": "NodeNorm",
"OPENTELEMETRY_JAEGER_HOST": "http://localhost",
"OPENTELEMETRY_JAEGER_PORT": 6831
"OPENTELEMETRY_JAEGER_PORT": 4318
}
}
20 changes: 12 additions & 8 deletions src/nodenorm/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def _is_open_telemetry_configurable(self) -> bool:

opentelemetry_module = "opentelemetry"
opentelemetry_installed = (
opentelemetry_module not in sys.modules and importlib.util.find_spec(opentelemetry_module) is None
opentelemetry_module in sys.modules or importlib.util.find_spec(opentelemetry_module) is not None
)

if not opentelemetry_enabled:
logger.debug(
logger.info(
"OPENTELEMETRY is disabled. If you wish to enable it, set the OPENTELEMETRY_ENABLED value to <True>"
)
return False
Expand All @@ -52,6 +52,10 @@ def _is_open_telemetry_configurable(self) -> bool:
)
return False

logger.info(
"OPENTELEMETRY is enabled. If you wish to disable it, set the OPENTELEMETRY_ENABLED value to <False>"
)

return opentelemetry_enabled and opentelemetry_installed

def configure_elasticsearch(self) -> types.SimpleNamespace:
Expand Down Expand Up @@ -98,19 +102,19 @@ def _validate_elasticsearch_index(self, elasticsearch_namespace: types.SimpleNam
def configure_telemetry(self):
"""Configure our opentelemetry for our web API."""
from opentelemetry.instrumentation.tornado import TornadoInstrumentor # pylint: disable=import-outside-toplevel
from opentelemetry.exporter.jaeger.thrift import JaegerExporter # pylint: disable=import-outside-toplevel
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter # pylint: disable=import-outside-toplevel
from opentelemetry.sdk.resources import SERVICE_NAME, Resource # pylint: disable=import-outside-toplevel
from opentelemetry.sdk.trace import TracerProvider # pylint: disable=import-outside-toplevel
from opentelemetry.sdk.trace.export import BatchSpanProcessor # pylint: disable=import-outside-toplevel
from opentelemetry import trace # pylint: disable=import-outside-toplevel

TornadoInstrumentor().instrument()

trace_exporter = JaegerExporter(
agent_host_name=self.config.telemetry["OPENTELEMETRY_JAEGER_HOST"],
agent_port=self.config.telemetry["OPENTELEMETRY_JAEGER_PORT"],
udp_split_oversized_batches=True,
)
jaeger_host = self.config.telemetry["OPENTELEMETRY_JAEGER_HOST"]
jaeger_port = self.config.telemetry["OPENTELEMETRY_JAEGER_PORT"]
otlp_endpoint = f"{jaeger_host}:{jaeger_port}/v1/traces"

trace_exporter = OTLPSpanExporter(endpoint=otlp_endpoint)

trace_provider = TracerProvider(
resource=Resource.create({SERVICE_NAME: self.config.telemetry["OPENTELEMETRY_SERVICE_NAME"]})
Expand Down