chore(showcase): add tracing tests#1725
Conversation
| } else { | ||
| expectedName = "POST /v1beta1/{name=sequences/*}" | ||
| wantAttrs = map[string]any{ | ||
| "error.type": "context.deadlineExceededError", |
There was a problem hiding this comment.
@westarle Iserror.type: context.deadlineExceededError an implementation bug? Should the raw client exception by replaced with CLIENT_TIMEOUT as it is in gRPC?
There was a problem hiding this comment.
this seems like a bug, could you file one please?
There was a problem hiding this comment.
I verified via a local test that the correct mapping logic to CLIENT_TIMEOUT in auth/httptransport is executing. However, the outer otelhttp.NewTransport wrapper overwrites the error.type attribute with the raw Go error type after our custom transport returns.
| } else { | ||
| expectedName = "POST /v1beta1/{name=sequences/*}" | ||
| wantAttrs = map[string]any{ | ||
| "error.type": "context.deadlineExceededError", |
There was a problem hiding this comment.
this seems like a bug, could you file one please?
aec17e2 to
b6d0a91
Compare
In a followup, (1) I think we should assert on the "wrong" values. Also (2) I think with your new "constraints" concept, we should be able to assert on every attribute in the map and report any "new" attribute as a failure (so we remember to add an appropriate test.) |
234a8a6 to
d727d5b
Compare
Pushed fix for this in d727d5b |
This PR is based on @westarle 's work on westarle:gapic-generator-go:test-plan-go-tf1-logs. It adds the following:
showcase/go.mod(specificallygoogle.golang.org/api,cloud.google.com/go/auth, andotelgrpc). This was crucial because the older versions weren't correctly propagating telemetry attributes through the transitive chain.trace_test.goto be less strict about unexpected attributes. The upgraded dependencies now automatically addgcp.grpc.resend_countandrpc.response.status_codein some cases where the tests previously disallowed them. I removed them from theunexpectedAttrslists.telemetrybuild tag to exclude these tests frommake test.showcase/README.mdexplaining how the telemetry tests work, including thetelemetrybuild tag, environment variables, and how to find the traces in Cloud Trace.Verification
I successfully ran the new
make test-telemetrytarget on my cloudtop using my dev project. The integration test passed in ~36 seconds.I also visited Trace Explorer to verify that the spans were arriving as expected (I had to adjust the time range to "Last 1 hour" to see them). I filtered for the client spans wiht
AttemptSequenceand they looked as expected with the T4 telemetry attributes we were looking for. Here's an example of attributes from an error span:cloud.account.id cloudtop-prod-us-west
cloud.availability_zone us-west4-a
cloud.platform gcp_compute_engine
cloud.provider gcp
cloud.region us-west4
error.type CLIENT_TIMEOUT
exception.type *status.Error
gcp.client.artifact github.com/googleapis/gapic-showcase/client
gcp.client.language go
gcp.client.repo googleapis/google-cloud-go
gcp.client.service showcase
gcp.client.version UNKNOWN
gcp.gce.instance.hostname myproject.us-west4-a.c.cloudtop-prod-us-west.internal
gcp.gce.instance.name myproject
gcp.grpc.resend_count 0
gcp.project_id myproject-testing
gcp.resource.destination.id //localhost:7469/sequences/2
host.id xxxx
host.name myproject
host.type projects/xxxxxxxx/machineTypes/e2-custom-24-98304
rpc.method google.showcase.v1beta1.SequenceService/AttemptSequence
rpc.response.status_code DEADLINE_EXCEEDED
rpc.system.name grpc
server.address 127.0.0.1
server.port 7469
service.name test-app
status.message context deadline exceeded
telemetry.sdk.language go
telemetry.sdk.name opentelemetry
telemetry.sdk.version 1.43.0
url.domain showcase.googleapis.com
This proves that the generated client is correctly delegating to the modern transport wrappers under the hood and emitting the necessary telemetry, without us needing to change the generator structure itself