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

OTLP #283

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

OTLP #283

Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
Expand All @@ -24,7 +24,7 @@ jobs:
images:
ghcr.io/${{ github.repository }}
- name: Login to ghcr
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
python-version: [3.11.0]
steps:
- name: Checkout the repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Create environment variables
run: |
echo "PYTHONPATH=$PWD" >> $GITHUB_ENV

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ redis~=3.5.3
requests==2.28.1
uvicorn==0.17.6
uvloop==0.19.0
opentelemetry-sdk==1.16.0
opentelemetry-instrumentation-fastapi==0.37b0
opentelemetry-exporter-jaeger==1.16.0
opentelemetry-instrumentation-httpx==0.37b0
opentelemetry-sdk==1.27.0
opentelemetry-instrumentation-fastapi==0.48b0
opentelemetry-exporter-otlp-proto-grpc==1.27.0
opentelemetry-instrumentation-httpx==0.48b0
fakeredis<=2.10.2
networkx==3.2.1
26 changes: 10 additions & 16 deletions src/otel_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def configure_otel(service_name, APP):

from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import SERVICE_NAME as telemetery_service_name_key, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
Expand All @@ -19,20 +19,14 @@ def configure_otel(service_name, APP):
# these supresses such warnings.
logging.captureWarnings(capture=True)
warnings.filterwarnings("ignore",category=ResourceWarning)
jaeger_host = os.environ.get('JAEGER_HOST', 'jaeger-otel-agent')
jaeger_port = int(os.environ.get('JAEGER_PORT', '6831'))
trace.set_tracer_provider(
TracerProvider(
resource=Resource.create({telemetery_service_name_key: service_name})
)
jaeger_host = os.environ.get('JAEGER_HOST', 'jaeger-otel-collector')
jaeger_port = int(os.environ.get('JAEGER_PORT', '4317'))
jaeger_endpoint = f'{jaeger_host}:{jaeger_port}'
otlp_exporter = OTLPSpanExporter(endpoint=jaeger_endpoint)
tracer_provider = TracerProvider(
resource=Resource.create({telemetery_service_name_key: service_name})
)
jaeger_exporter = JaegerExporter(
agent_host_name=jaeger_host,
agent_port=jaeger_port,
)
trace.get_tracer_provider().add_span_processor(
BatchSpanProcessor(jaeger_exporter)
)
tracer = trace.get_tracer(__name__)
FastAPIInstrumentor.instrument_app(APP, tracer_provider=trace, excluded_urls="docs,openapi.json")
tracer_provider.add_span_processor(BatchSpanProcessor(otlp_exporter))
trace.set_tracer_provider(tracer_provider)
FastAPIInstrumentor.instrument_app(APP, tracer_provider=tracer_provider, excluded_urls="docs,openapi.json")
HTTPXClientInstrumentor().instrument()