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

Link and Resource attribute count limits don't work #2041

Closed
owais opened this issue Aug 17, 2021 · 0 comments · Fixed by #2044
Closed

Link and Resource attribute count limits don't work #2041

owais opened this issue Aug 17, 2021 · 0 comments · Fixed by #2044
Assignees
Labels
bug Something isn't working

Comments

@owais
Copy link
Contributor

owais commented Aug 17, 2021

Describe your environment

Current implementation does not respect link and resource (span) attribute limits.

Steps to reproduce

from opentelemetry import trace
from opentelemetry.sdk.trace import Resource, TracerProvider, SpanLimits
from opentelemetry.sdk.trace.export import (
    SimpleSpanProcessor,
    ConsoleSpanExporter,
)

attributes = {"k1": "v1", "k2": "v2"}

provider = TracerProvider(
    resource=Resource.create(attributes=attributes.copy()),
    span_limits=SpanLimits(max_attributes=1, max_link_attributes=1),
)
processor = SimpleSpanProcessor(ConsoleSpanExporter())
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)


tracer = trace.get_tracer(__name__)

link = trace.Link(
    context=trace.INVALID_SPAN.get_span_context(), attributes=attributes.copy()
)

with tracer.start_as_current_span("s1", links=[link], attributes=attributes.copy()):
    pass

Run it:

❯ python main.py
{
    "name": "s1",
    "context": {
        "trace_id": "0xc20060d23fb374cc0e9441de3cf643b4",
        "span_id": "0xddddbe3ecde87eff",
        "trace_state": "[]"
    },
    "kind": "SpanKind.INTERNAL",
    "parent_id": null,
    "start_time": "2021-08-17T09:11:56.024238Z",
    "end_time": "2021-08-17T09:11:56.024257Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {
        "k3": "v3"
    },
    "events": [],
    "links": [
        {
            "context": {
                "trace_id": "0x00000000000000000000000000000000",
                "span_id": "0x0000000000000000",
                "trace_state": "[]"
            },
            "attributes": {
                "k1": "v1",
                "k2": "v2",
                "k3": "v3"
            }
        }
    ],
    "resource": {
        "telemetry.sdk.language": "python",
        "telemetry.sdk.name": "opentelemetry",
        "telemetry.sdk.version": "1.4.1",
        "k1": "v1",
        "k2": "v2",
        "k3": "v3",
        "service.name": "unknown_service"
    }
}

What is the expected behavior?
Resource and Link should have a single attribute just like the span.

What is the actual behavior?
Attribute count limits are not respected for resource and links as both of them contain more attributes than the limit (1).

@owais owais added the bug Something isn't working label Aug 17, 2021
@owais owais self-assigned this Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit to owais/opentelemetry-python that referenced this issue Aug 17, 2021
owais added a commit that referenced this issue Aug 19, 2021
owais added a commit that referenced this issue Aug 24, 2021
* Added support for `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`

Fixes #2045
Fixes #2043
Fixes #2042
Fixes #2041

* SpanLimit: Treat empty value env vars as unset

Fixes #2052

* Update CHANGELOG.md

Co-authored-by: Leighton Chen <lechen@microsoft.com>

Co-authored-by: Leighton Chen <lechen@microsoft.com>
owais added a commit that referenced this issue Aug 24, 2021
* Added support for `OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT`

Fixes #2045
Fixes #2043
Fixes #2042
Fixes #2041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant