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

feat(spans): Infer span.op if not defined #4056

Merged
merged 5 commits into from
Sep 24, 2024
Merged

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Sep 20, 2024

Add global option that allows inferring the span op, with rules like this:

{
    "span_op_defaults": {
       "rules": [{
            "condition": {
                "op": "not",
                "inner": {
                    "op": "eq",
                    "name": "span.data.messaging\\.system",
                    "value": null,
                },
            },
            "value": "message"
        }]
    }
}

ref: #3637

@jjbayer jjbayer marked this pull request as ready for review September 20, 2024 13:31
@jjbayer jjbayer requested a review from a team as a code owner September 20, 2024 13:31
Copy link
Member

@Dav1dde Dav1dde left a comment

Choose a reason for hiding this comment

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

Can we not build this into the existing Rule system or extend it? I'd prefer if we had a generic system instead of adding more specific stuff. Now it's the span.op in the future it might be span.foo. This is close to being a system which can write attributes based on rules.

Comment on lines +219 to +224
for rule in self.rules {
if rule.condition.matches(span) {
return rule.value.clone();
}
}
"default".to_owned()
Copy link
Member

Choose a reason for hiding this comment

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

Untested:

Suggested change
for rule in self.rules {
if rule.condition.matches(span) {
return rule.value.clone();
}
}
"default".to_owned()
self.rules.iter()
.find(|rule| rule.condition.matches(span))
.cloned()
.unwrap_or("default".to_owned())

Copy link
Member Author

Choose a reason for hiding this comment

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

I kind of like the for loop, even though it takes one more line.

@jjbayer
Copy link
Member Author

jjbayer commented Sep 23, 2024

I'd prefer if we had a generic system instead of adding more specific stuff. Now it's the span.op in the future it might be span.foo. This is close to being a system which can write attributes based on rules.

@Dav1dde I considered it, the question is always, where do we stop? This PR is already a generalization of the initial idea of slapping some hard coded rules onto span normalization. But I agree that I could at least make the target field (span.op) part of the configuration, and make it independent of spans (the selector has $span... in it anyway).

@Dav1dde
Copy link
Member

Dav1dde commented Sep 23, 2024

considered it, the question is always, where do we stop? This PR is already a generalization of the initial idea of slapping some hard coded rules onto span normalization.

Fair enough.

But I agree that I could at least make the target field (span.op) part of the configuration, and make it independent of spans (the selector has $span... in it anyway).

I'd like that, but that may require a Setter trait.

@jjbayer jjbayer merged commit 3973629 into master Sep 24, 2024
23 checks passed
@jjbayer jjbayer deleted the feat/span-op-inference branch September 24, 2024 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants