Skip to content

Conversation

@bessey
Copy link
Contributor

@bessey bessey commented Dec 13, 2021

Enable a developer to provide the platform trace API a fallback name to
use when a query name is not provided.

Note that this is a fallback, the query name is preferred when
available.

Testing is limited to Datadog and New Relic.

Support is within any tracer that delegates to
PlatformTracing#transaction_name, which appears to include AppSignal
and Scout. Not sure if that is exhaustive.

Fixes #3769

@bessey bessey force-pushed the platform-tracing-operation-fallback branch from bd47bab to 0fc5cfb Compare December 13, 2021 14:57
@bessey bessey changed the base branch from master to 1.12.x December 13, 2021 14:57
@bessey
Copy link
Contributor Author

bessey commented Dec 13, 2021

@rmosolgo FYI I am finding that the test suite hangs on v1.13 when I run it locally with rake test, running with TESTOPTS="--verbose" I can see the output before it hangs is:

GraphQL::Dataloader::AsyncDataloader::With libev_scheduler#test_0001_runs IO in parallel by default

So perhaps I am missing a libev dependency and it doesn't handle it so gracefully.

So for now I am targetting v1.12 (actually, we have not yet upgraded to v1.13 so I would prefer to target v1.12 either way, but we can live on a fork until v1.13 if necessary).

Copy link
Owner

@rmosolgo rmosolgo left a comment

Choose a reason for hiding this comment

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

Looking good so far! If you don't mind adding some test for this behavior, that'd be great. Do you plan to use the .call feature? If not, I'd rather leave it out until someone actually needs it. (Just more for me to maintain, otherwise 😅 )

it hangs

Oh! I found that GitHub actions failed when libev_scheduler was installed, too. Maybe that was why.

Comment on lines 111 to 120
if selected_op
op_type = selected_op.operation_type
op_name = selected_op.name || "anonymous"
elsif fallback_name = fallback_transaction_name(query.context)
return "GraphQL/#{fallback_name}"
else
op_type = "query"
op_name = "anonymous"
end
"GraphQL/#{op_type}.#{op_name}"
Copy link
Owner

Choose a reason for hiding this comment

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

sorry, personally, I have a hard time with multi-return methods, because I end up forgetting the different "exits" that the method has. if you don't mind:

Suggested change
if selected_op
op_type = selected_op.operation_type
op_name = selected_op.name || "anonymous"
elsif fallback_name = fallback_transaction_name(query.context)
return "GraphQL/#{fallback_name}"
else
op_type = "query"
op_name = "anonymous"
end
"GraphQL/#{op_type}.#{op_name}"
txn_name = if selected_op
op_type = selected_op.operation_type
op_name = selected_op.name || "anonymous"
"#{op_type}.#{op_name}"
elsif (fallback_name = fallback_transaction_name(query.context))
fallback_name
else
"query.anonymous"
end
"GraphQL/#{txn_name}"

@bessey bessey force-pushed the platform-tracing-operation-fallback branch from 8a511c1 to 74d0992 Compare December 13, 2021 18:02
@bessey
Copy link
Contributor Author

bessey commented Dec 14, 2021

Looking good so far! If you don't mind adding some test for this behavior, that'd be great. Do you plan to use the .call feature? If not, I'd rather leave it out until someone actually needs it. (Just more for me to maintain, otherwise sweat_smile )

You made me do what I should have from the beginning: measured :D

I wanted to avoid a SHA / SHA2 digest generation when it wouldn't be used. In practice, this is so close to instant its not worth the complexity

irb(main):003:0> string = "ANCASDJASFSDFSDF"*1000
=> "ANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCASDJASFSDFSDFANCA...
irb(main):008:0> Benchmark.measure { Digest::SHA2.hexdigest(string) }.real
=> 0.00020213398966006935

If I am not mistaken, that's 0.2ms. Will remove that change. And incorporate your other comment.

If you don't mind adding some test for this behavior, that'd be great

This is next on my to do, I have left some empty tests for now so we can agree on scope. Do these seem reasonable to you? One for my snowflake implementation in Datadog, and one for the general purpose implementation, in a tracer that relies on that implementation

@bessey bessey requested a review from rmosolgo December 17, 2021 16:40
Copy link
Owner

@rmosolgo rmosolgo left a comment

Choose a reason for hiding this comment

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

Yep, this scope LGTM 😎

@bessey bessey force-pushed the platform-tracing-operation-fallback branch from af77ff9 to 7fcaf4a Compare January 11, 2022 16:17
@bessey bessey changed the base branch from 1.12.x to master January 11, 2022 16:17
@bessey bessey force-pushed the platform-tracing-operation-fallback branch from 7fcaf4a to 778fc88 Compare January 11, 2022 16:20
Enable a developer to provide the platform trace API a fallback name to
use when a query name is not provided.

Note that this is a *fallback*, the query name is preferred when
available.

Testing is limited to Datadog and New Relic.

Support is within any tracer that delegates to
`PlatformTracing#transaction_name`, which appears to include AppSignal
and Scout. Not sure if that is exhaustive.
@bessey bessey force-pushed the platform-tracing-operation-fallback branch from 778fc88 to 9e93fe4 Compare January 11, 2022 16:24
@bessey bessey marked this pull request as ready for review January 11, 2022 16:24
@bessey bessey requested a review from rmosolgo January 11, 2022 16:24
@bessey
Copy link
Contributor Author

bessey commented Jan 11, 2022

I have implemented the specs and got it working on master rather than 1.12, ready for review!

Copy link
Owner

@rmosolgo rmosolgo left a comment

Choose a reason for hiding this comment

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

Thanks for this improvement!

@rmosolgo rmosolgo added this to the 1.13.5 milestone Jan 13, 2022
describe GraphQL::Tracing::DataDogTracing do
module DataDogTest
class Query < GraphQL::Schema::Object
add_field GraphQL::Types::Relay::NodeField
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
add_field GraphQL::Types::Relay::NodeField
include GraphQL::Types::Relay::HasNodeField

There was a bug here fixed in master since this branch came off: #3791

Copy link
Owner

Choose a reason for hiding this comment

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

I'll merge this and fix it on master

@rmosolgo rmosolgo merged commit 4596ef8 into rmosolgo:master Jan 13, 2022
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.

Tracing: Resource names for queries without operation names

2 participants