Skip to content

HTTP semantic convention stability migration for aiohttp-client #2673

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 15 commits into from
Jul 15, 2024

Conversation

emdneto
Copy link
Member

@emdneto emdneto commented Jul 8, 2024

Description

Part of #2453
Closes #2675

Test snippet

import os
import aiohttp
import asyncio
from opentelemetry.instrumentation.aiohttp_client import (
        AioHttpClientInstrumentor
    )
import logging

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace.export import (
    BatchSpanProcessor,
    ConsoleSpanExporter,
)
# Specify "http", "http/dup" or ""
os.environ["OTEL_SEMCONV_STABILITY_OPT_IN"] = ""
AioHttpClientInstrumentor().instrument()

logging.basicConfig(level=logging.DEBUG)

provider = TracerProvider(resource=Resource({"service.name": "aiohttp-client"}))
processor = BatchSpanProcessor(ConsoleSpanExporter())
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
tracer = trace.get_tracer(__name__)

async def main():
    async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(1)) as session:
        async with session.get('http://httpbin.org/'):
            pass

asyncio.run(main())

default

    "attributes": {
        "http.method": "GET",
        "http.url": "http://httpbin.org/",
        "http.status_code": 200
    },

new semconv

    "attributes": {
        "http.request.method": "GET",
        "url.full": "http://httpbin.org/",
        "http.response.status_code": 200
    },

http/dup

    "attributes": {
        "http.method": "GET",
        "http.request.method": "GET",
        "http.url": "http://httpbin.org/",
        "url.full": "http://httpbin.org/",
        "http.status_code": 200,
        "http.response.status_code": 200
    },

@emdneto emdneto changed the title HTTP transition for aiohttp-client HTTP semantic convention stability migration for aiohttp-client Jul 9, 2024
@emdneto emdneto marked this pull request as ready for review July 9, 2024 19:02
@emdneto emdneto requested a review from a team July 9, 2024 19:02
emdneto and others added 3 commits July 13, 2024 20:36
Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just some non-blocking comment.s

@lzchen lzchen merged commit 7e48ee7 into open-telemetry:main Jul 15, 2024
379 checks passed
xrmx pushed a commit to xrmx/opentelemetry-python-contrib that referenced this pull request Jan 24, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-aiohttp-client: HTTP semantic convention stability migration
3 participants